const { app, BrowserWindow, session } = require('electron'); const path = require('path'); function createWindow() { const mainWindow = new BrowserWindow({ width: 1600, height: 1200, webPreferences: { nodeIntegration: true, contextIsolation: false, webviewTag: true } }); mainWindow.loadFile('index.html'); // 开发时打开开发者工具 // mainWindow.webContents.openDevTools(); } app.whenReady().then(() => { createWindow(); app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createWindow(); }); }); app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit(); });