function createWindow () { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } })
//webcontents
win.webContents.on("did-finish-load",()=>{ console.log("did-finish-load"); })
win.webContents.on("dom-ready",()=>{ console.log("dom-ready"); })
win.loadFile('index.html') } //加载完成事件 app.whenReady().then(()=>{ console.log("------whenReady------"); createWindow()}) //所有窗口被关闭 app.on('window-all-closed', () => { console.log("'window-all-closed"); if (process.platform !== 'darwin') { app.quit() } })
app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow() } })
// ready:当electron完成初始化时被触发
// window-all-closed:所有窗口被关闭
// before-quit:应用程序开始关闭窗口之前被触发
// will-quit:当所有窗口都已经关闭并且应用程序将退出时发出
// quit:在应用程序退出时发出 // https://www.electronjs.org/docs/all 文档