1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const node_path_1 = __importDefault(require("node:path"));
const db_1 = require("./db");
const handlers_1 = require("./ipc/handlers");
const isDev = !electron_1.app.isPackaged;
let mainWindow = null;
function createWindow() {
mainWindow = new electron_1.BrowserWindow({
width: 1400,
height: 900,
minWidth: 1000,
minHeight: 600,
show: false,
titleBarStyle: "hiddenInset",
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
preload: node_path_1.default.join(__dirname, "preload.js"),
},
});
(0, handlers_1.registerIpcHandlers)(mainWindow);
if (isDev) {
const url = process.env.VITE_DEV_SERVER_URL ?? "http://localhost:5173";
mainWindow.loadURL(url).finally(() => {
mainWindow.show();
mainWindow.webContents.openDevTools({ mode: "detach" });
});
}
else {
const indexHtml = node_path_1.default.join(electron_1.app.getAppPath(), "renderer", "dist", "index.html");
mainWindow.loadFile(indexHtml).finally(() => mainWindow.show());
}
}
electron_1.app.whenReady().then(() => {
// Initialize database
(0, db_1.getDb)();
createWindow();
electron_1.app.on("activate", () => {
if (electron_1.BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
electron_1.app.on("window-all-closed", () => {
(0, db_1.closeDb)();
if (process.platform !== "darwin") {
electron_1.app.quit();
}
});
|