30 lines
647 B
JavaScript
30 lines
647 B
JavaScript
|
const { app, BrowserWindow } = require('electron')
|
||
|
|
||
|
function createWindow() {
|
||
|
let mainWin = new BrowserWindow({
|
||
|
show: false, // 防止首页白屏
|
||
|
width: 800,
|
||
|
height: 400,
|
||
|
webPreferences: {
|
||
|
nodeIntegration: true,
|
||
|
enableRemoteModule: true
|
||
|
}
|
||
|
})
|
||
|
|
||
|
// 防止首页白屏,否则不显示
|
||
|
mainWin.on('ready-to-show', () => {
|
||
|
mainWin.show()
|
||
|
})
|
||
|
|
||
|
mainWin.loadFile('index.html')
|
||
|
|
||
|
mainWin.on('close', () => {
|
||
|
mainWin = null // 删除引用,释放空间
|
||
|
})
|
||
|
}
|
||
|
|
||
|
app.on('ready', createWindow)
|
||
|
app.on('window-all-closed', () => {
|
||
|
app.quit()
|
||
|
})
|