forked from koodo-reader/koodo-reader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.ts
67 lines (63 loc) · 1.41 KB
/
main.ts
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
61
62
63
64
65
66
67
const {
app,
BrowserWindow,
dialog,
shell,
remote,
ipcMain,
} = require("electron");
const isDev = require("electron-is-dev");
const path = require("path");
const fontList = require("font-list");
let mainWin;
let splash;
app.on("ready", () => {
mainWin = new BrowserWindow({
titleBarStyle: "hidden",
width: 1030,
height: 660,
webPreferences: { webSecurity: false, nodeIntegration: true },
show: false,
// transparent: true,
});
splash = new BrowserWindow({
width: 510,
height: 323,
frame: false,
transparent: true,
alwaysOnTop: true,
});
splash.loadURL(
isDev
? path.join(__dirname, "/public/assets/launch-page.html")
: `file://${path.join(__dirname, "./build/assets/launch-page.html")}`
);
if (!isDev) {
const { Menu } = require("electron");
Menu.setApplicationMenu(null);
}
const urlLocation = isDev
? "http://localhost:3000/"
: `file://${path.join(__dirname, "./build/index.html")}`;
mainWin.loadURL(urlLocation);
mainWin.once("ready-to-show", () => {
splash.destroy();
mainWin.show();
});
mainWin.on("close", () => {
mainWin = null;
});
ipcMain.on("fonts-ready", (event, arg) => {
fontList
.getFonts()
.then((fonts) => {
event.returnValue = fonts;
})
.catch((err) => {
console.log(err);
});
});
});
app.on("window-all-closed", () => {
app.quit();
});