const { app, BrowserWindow, ipcMain, Menu } = require('electron') const path = require('path') var index = 0; var mainWindow = null; var config = [ { path: 'page/login.html', windowConfig: { title: '乐聊 - 登录', width: 316, height: 507, resizable: false, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, contextIsolation: false } } }, { path: 'page/index.html', windowConfig: { title: '', icon: null, width: 800, height: 600, autoHideMenuBar: true, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, contextIsolation: false } } } ]; const createWindow = () => { Menu.setApplicationMenu(null); mainWindow = new BrowserWindow(config[index].windowConfig) mainWindow.webContents.openDevTools(); mainWindow.loadFile(config[index].path) } ipcMain.on("GoToIndex",(action, res) => { mainWindow.close(); index = 1; createWindow() }) app.whenReady().then(() => { createWindow() }) app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit() })