-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
60 lines (46 loc) · 1.25 KB
/
main.js
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
55
56
57
58
59
60
const { app, BrowserWindow, ipcMain } = require("electron");
const electron = require("electron");
const path = require("path");
const Store = require("electron-store");
const server = require("./server");
const store = new Store();
let mainWindow;
const createWindow = () => {
mainWindow = new BrowserWindow({
width: 1600,
height: 1000,
webPreferences: {
nodeIntegration: true,
hardwareAcceleration: true,
},
});
const apiKeys = store.get("apiKeys") || {};
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
electron.shell.openExternal(url);
return { action: "deny" };
});
mainWindow.webContents.on("did-finish-load", () => {
mainWindow.webContents.send("apiKeys", apiKeys);
});
ipcMain.on("updateApiKeys", (event, updatedApiKeys) => {
store.set("apiKeys", updatedApiKeys);
});
mainWindow.loadFile(path.join(__dirname, "react-app/build", "index.html"));
};
server();
app.on("ready", createWindow);
app.on("window-all-closed", () => {
app.quit();
});
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
});
process.on("uncaughtException", (error) => {
console.error("Uncaught exception:", error);
app.quit();
});
process.on("SIGTERM", () => {
app.quit();
});