-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelectron.js
43 lines (33 loc) · 897 Bytes
/
electron.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
const { app, BrowserWindow } = require('electron')
const path = require('path')
const Store = require('electron-store-data')
let win
function createWindow () {
const storeWindow = new Store({
filename: 'window',
defaults: {
bounds: { x: '', y: '', width: 900, height: 500 }
}
})
const { x, y, width, height } = storeWindow.get('bounds')
win = new BrowserWindow({ x: x, y: y, width: width, height: height, titleBarStyle: 'hidden', show: false })
win.loadURL('file://' + path.join(__dirname, 'production', 'index.html'))
win.once('ready-to-show', () => {
win.show()
})
win.on('close', () => {
storeWindow.set('bounds', win.getBounds())
})
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
app.on('window-all-closed', () => {
app.quit()
})