const { app, BrowserWindow } = require('electron'); const path = require('path'); function createWindow () { const win = new BrowserWindow({ width: 2000, height: 1800, minWidth: 400, minHeight: 500, center: true, webPreferences: { nodeIntegration: true, contextIsolation: false, enableRemoteModule: true } }); // 判断是否为开发环境 // const isDev = process.env.NODE_ENV === 'development' || !app.isPackaged; // // if (isDev) { // 开发环境:加载 Vue CLI 开发服务器 win.loadURL('http://localhost:8080'); // 开发环境下打开开发者工具 // win.webContents.openDevTools(); // } else { // // 生产环境:加载构建后的文件 // win.loadFile(path.join(__dirname, 'dist', 'index.html')); // } } app.whenReady().then(createWindow); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } }); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } });