-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
44 lines (34 loc) · 907 Bytes
/
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
const { app, BrowserWindow, ipcMain } = require("electron");
try {
require("electron-reloader")(module, { ignore: ["src"] });
} catch {}
require("electron-store").initRenderer();
require("electron-context-menu")();
const windows = {
main: {
file: "mainForm.html",
instance: undefined,
},
keywords: {
file: "keywordsForm.html",
instnace: undefined,
},
};
function createWindow(name) {
if (windows[name].instance) return;
const window = new BrowserWindow({
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false,
},
});
window.loadFile(windows[name].file);
windows[name].instance = window;
window.on("closed", () => {
windows[name].instance = undefined;
});
}
app.on("ready", () => createWindow("main"));
ipcMain.on("open-keywords", () => createWindow("keywords"));