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') }) })

 

 

持續更新


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM