Coder Social home page Coder Social logo

simple_pdf_translator_plugins's Introduction

PDF划词翻译插件开发

具体插件开发样例可参考目录baidu下百度翻译开发,开发完成后采用webpack打包,最后将打包好的js放到软件开发plugins目录下,随软件一起打包进入app.asar并随软件更新进行下发。

注意:

1、module.exports 需要导出一函数并且传入参数ctx,这里ctx即为上下文环境,由软件进行提供,内部实现了ctx.log(log:string)日志函数、ctx.getConfig(key:string)获取配置函数、ctx.setConfig(key:string,value:object)保存配置函数、ctx.finishTranslate(translatr_str:string)翻译完成回调函数。

2、module.exports 导出的函数需返回TranslateName翻译英文标注名称、TranslateZhName翻译中文名称、TranslateConfig翻译配置要求、TranslateRegister翻译注册函数、TranslateFunction翻译函数等参数。

3、TranslateConfig翻译配置要求模板如下,前端ui会根据配置要求生成相应的输入框并保存到相应文件中。

  const config = [
    {
      name: 'appid', //名称
      type: 'input', //数字
      default: userConfig.appid || '', //默认值
      message: 'appid不能为空', //提示文字
      required: true //是否必须
    },
    {
      name: 'secretkey', 
      type: 'password', //输入密钥
      default: userConfig.secretkey || '',
      message: 'secretkey不能为空',
      required: true
    }  
  ]

4、用户配置完成后会对插件重新加载,插件开发过程中无需考虑配置重新加载。

5、插件机制主要参考picgo的插件开发,可参考picgo插件开发的相关文章,https://picgo.github.io/PicGo-Core-Doc/zh/dev-guide/cli.html

6、目前插件机制依赖于软件进行下发(将插件打包进入app.asar并在运行时加载),后期考虑进行利用npm库来进行插件加载与升级。

simple_pdf_translator_plugins's People

Contributors

wcx1024979076 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.