46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
|
const { app, BrowserWindow, shell, Menu } = require('electron')
|
||
|
|
||
|
const createWindow = () => {
|
||
|
let mainWin = new BrowserWindow({
|
||
|
width: 800,
|
||
|
height: 400,
|
||
|
show: false,
|
||
|
webPreferences: {
|
||
|
enableRemoteModule: true,
|
||
|
nodeIntegration: true
|
||
|
}
|
||
|
})
|
||
|
|
||
|
let tmp = [
|
||
|
{
|
||
|
label: '菜单',
|
||
|
submenu: [
|
||
|
{
|
||
|
label: '关于',
|
||
|
click() {
|
||
|
shell.openExternal('https://cantyonion.site')
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
label: '打开',
|
||
|
click() {
|
||
|
BrowserWindow.getFocusedWindow().webContents.send('open')
|
||
|
}
|
||
|
},
|
||
|
]
|
||
|
}
|
||
|
]
|
||
|
|
||
|
let menu = Menu.buildFromTemplate(tmp)
|
||
|
Menu.setApplicationMenu(menu)
|
||
|
|
||
|
mainWin.loadFile('index.html')
|
||
|
mainWin.on('ready-to-show', mainWin.show)
|
||
|
mainWin.on('close', () => {
|
||
|
mainWin = null
|
||
|
})
|
||
|
}
|
||
|
|
||
|
app.on('ready', createWindow)
|
||
|
app.on('window-all-closed', app.quit)
|