import { app, BrowserWindow } from 'electron' import path from 'path' import { fileURLToPath } from 'url' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) function createWindow() { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js'), // preload 文件 contextIsolation: true, nodeIntegration: false } }) if (process.env.NODE_ENV === 'development') { win.loadURL('http://localhost:5173') } else { win.loadFile(path.join(__dirname, 'dist/index.html')) } } app.whenReady().then(createWindow)