-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (39 loc) · 876 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
/**
* This is the code for the "main" Thread of electron
* Cooyright (c) 2019 by G. Weirich
* License and terms: See LICENSE
*/
const { app, BrowserWindow, Menu } = require('electron')
const cfg = new (require('electron-store'))()
let win;
createWindow = () => {
const bounds = cfg.get("bounds") || { width: 640, height: 480 }
win = new BrowserWindow({
width: bounds.width,
height: bounds.height,
x: bounds.x,
y: bounds.y,
icon: __dirname+"/assets/icon.png",
webPreferences: {
nodeIntegration: true
}
})
win.loadFile("index.html")
win.on('closed', () => {
win = null
})
win.on("resize", () => {
resize(win.getBounds())
})
win.on("move", () => {
resize(win.getBounds())
})
}
resize = bounds => {
cfg.set("bounds", bounds)
}
Menu.setApplicationMenu(null)
app.on("ready", createWindow)
app.on("window-all-closed", () => {
app.quit()
})