MikiVL 68f90f4e4c chore: Electron 主进程脚手架
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 13:32:43 +08:00

35 lines
790 B
JavaScript

const { app, BrowserWindow } = require("electron");
const path = require("path");
const isDev = process.env.NODE_ENV === "development";
function createWindow() {
const win = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
contextIsolation: true,
nodeIntegration: false,
},
});
if (isDev) {
win.loadURL("http://localhost:5173");
win.webContents.openDevTools();
} else {
win.loadFile(path.join(__dirname, "../renderer/dist/index.html"));
}
}
app.whenReady().then(() => {
require("./db/init");
require("./ipc/templateIpc");
require("./ipc/generateIpc");
createWindow();
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
});