import { app, BrowserWindow } from 'electron'; import path from 'path'; import { fileURLToPath } from 'url'; const isDev = !app.isPackaged; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); function createWindow() { const win = new BrowserWindow({ width: 1024, height: 768, webPreferences: { preload: path.join(__dirname, 'preload.cjs'), contextIsolation: true, nodeIntegration: false } }); if (isDev) { const devUrl = process.env.ELECTRON_START_URL || 'http://localhost:5173'; win.loadURL(devUrl); win.webContents.openDevTools(); } else { win.loadFile(path.join(__dirname, '..', 'dist', 'index.html')); } } app.whenReady().then(createWindow); app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); }); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); });