const pluginId = '2021001130678316';
let pluginInstance = null;

const loadOcr = () => new Promise(resolve => {
  if (pluginInstance) {
    return resolve(pluginInstance);
  }

  my.loadPlugin({
    plugin: `${pluginId}@*`,
    success: () => {
      // 储存插件实列
      // eslint-disable-next-line no-undef
      pluginInstance = requirePlugin(`dynamic-plugin://${pluginId}`);
      resolve(pluginInstance);
    }
  });
});

export default loadOcr;