zoukankan      html  css  js  c++  java
  • electron vue 开发客户端程序

    文档知识点

    https://electronjs.org/docs/tutorial/about

    (1)Electron通过将ChromiumNode.js合并到同一个运行时环境中,并将其打包为Mac,Windows和Linux系统下的应用来实现这一目的。

    即electron内置了浏览器和node环境。

    Electron包括2个进程:main-process ,render-process。

    main-process:控制应用的生命周期

     render-process:浏览器渲染。

    这2个进行之间通过IPC进行通信。

    (2) 通信过程待研究

    https://electronjs.org/docs/faq#how-to-share-data-between-web-pages

    开发小tips

    (1)main 进程热更新

    webpack配置:

    function startMain () {
      return new Promise((resolve, reject) => {
        mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main)
    
        const compiler = webpack(mainConfig)
    
        compiler.plugin('watch-run', (compilation, done) => {
          logStats('Main', chalk.white.bold('compiling...'))
          hotMiddleware.publish({ action: 'compiling' })
          done()
        })
    
        compiler.watch({}, (err, stats) => {
          if (err) {
            console.log(err)
            return
          }
    
          logStats('Main', stats)
    
          if (electronProcess && electronProcess.kill) {
            manualRestart = true
            process.kill(electronProcess.pid)
            electronProcess = null
            startElectron()
    
            setTimeout(() => {
              manualRestart = false
            }, 5000)
          }
    
          resolve()
        })
      })
    }

    main进程的热更新使用的webpack的watch-run插件,所以main进程修改后会热更新。render进程热更新大家很熟悉了。

    (2)main进程log记录

    electron-log 插件可以打印main主进程信息。

    https://github.com/megahertz/electron-log

    需要说明的事:默认只有error信息可以打印到文件中。

     app.get('/situation/open/getJsonFiles', (req, res) => {
        // 默认情况下只打印error信息,所以使用log.error打印所需的信息即可
        log.error('Hello, log2')
        readJsonFiles(app).then(ele => {
          res.send(ele)
        }).catch(err => {
          res.send(err, '---ree')
        })
      })

    持续更新

  • 相关阅读:
    中国软件技术篇
    create pdf
    我来了
    补丁号
    rdlc里面用VB语法对数值型数据进行Format
    WinForm中有些控件不能添加ToolTip关联的解决方法
    javascript弹出对话框
    省市县关联菜单
    委托与事件
    ASP.NET多文件上传方案
  • 原文地址:https://www.cnblogs.com/mengfangui/p/10081566.html
Copyright © 2011-2022 走看看