- 开始一个项目
npm init
npm install --save-dev electron electron-builder
2.修改package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
}
3 项目根目录 新建 main.js内容如下
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('dist/index.html') // 假设Vue项目的打包输出在dist目录下
}
app.whenReady().then(createWindow)
4 打包
npm run dist
网友评论