-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (57 loc) · 1.8 KB
/
app.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
61
62
63
64
65
66
67
68
69
const { app, BrowserWindow, ipcMain } = require("electron");
const electronPug = require("electron-pug");
const path = require("path");
const url = require("url");
let mainWindow;
const width = 480;
const height = 620;
app.on("ready", () => {
setTimeout(() => {
const woptions = {
webPreferences: {
nodeIntegration: true,
devTools: false
},
show: false,
frame: false,
transparent: true,
width,
minWidth: width,
maxWidth: width,
height,
minHeight: height,
maxHeight: height,
icon: path.join(__dirname, "images", "favicon.png")
};
electronPug({ pretty: true })
.then(() => {
// pug.on("error", console.error);
mainWindow = new BrowserWindow(woptions);
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, "views", "index.pug"),
protocol: "file:",
slashes: true
}));
mainWindow.on("closed", () => {
app.quit();
});
mainWindow.once("ready-to-show", () => {
mainWindow.show();
});
mainWindow.on("maximize", () => console.log("full-screen"));
mainWindow.setFullScreenable(false);
mainWindow.setMaximizable(false);
mainWindow.setResizable(false);
})
.catch(console.error);
}, 100);
});
ipcMain.on("window:minimize", () => {
const window = BrowserWindow.getFocusedWindow();
if(window.isMinimized()) {
return window.restore();
}
return window.minimize();
});
process.on("uncaughtException", console.error);
process.on("unhandledRejection", console.error);