运行脚本
yarn electron-start
弹窗报错
配置如下
电脑
package.json
{
"scripts": {
"electron-start": "nodemon --watch ./main.js --exec 'electron .'"
},
"devDependencies": {
"@types/lodash": "^4.14.123",
"http-proxy-middleware": "^0.19.1",
"electron": "^4.1.3",
"electron-builder": "^20.40.2",
"nodemon": "^1.18.10"
},
"dependencies":{
"electron-store": "^3.2.0",
}
}
main.js
const { app, BrowserWindow } = require('electron')
class AppWindow extends BrowserWindow {
constructor(config, fileLocation) {
const basicConfig = {
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
}
const finalConfig = { ...basicConfig, ...config }
super(finalConfig)
this.loadFile(fileLocation)
this.once('ready-to-show', () => {
this.show()
})
}
}
app.on('ready', () => {
new AppWindow({}, './renderer/index.html')
})