const { app, BrowserWindow } = require('electron'); const path = require('path'); let mainWindow; function createWindow() { mainWindow = new BrowserWindow({ width: 1400, height: 900, minWidth: 1024, minHeight: 680, title: '影视星河设备管理系统', icon: path.join(__dirname, 'icon.ico'), webPreferences: { nodeIntegration: false, contextIsolation: true }, autoHideMenuBar: true }); // 加载本地服务器 mainWindow.loadURL('http://localhost:3001'); mainWindow.on('closed', () => { mainWindow = null; }); } app.whenReady().then(() => { // 启动后端服务器 require('../server.js'); // 等待服务器启动后创建窗口 setTimeout(createWindow, 1500); }); app.on('window-all-closed', () => { app.quit(); }); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } });