-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
56 lines (47 loc) · 1.65 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
const config = require('./config.json')
const {app, BrowserWindow} = require('electron')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
let loading;
function sleep(millis) {
return new Promise(resolve => setTimeout(resolve, millis));
}
function createWindow(loading) {
win = new BrowserWindow({frame: false, show:false})
win.loadURL(config['remote_url'])
// When ready, show the window
win.once('ready-to-show', () => {
setTimeout(function() {
win.show()
win.focus()
if(config['maximize_on_startup']) {
win.maximize()
}
if(config['fullscreen_on_startup']) {
win.setFullScreen(true)
}
setTimeout(function() {
loading.hide()
}, 1000); //Wait a bit, because the window won't pop in instantly
}, 1000); //Wait a bit, because the screen will initially be white, and we don't want the user to see an ugly white flash
})
}
app.on('ready', () => {
loading = new BrowserWindow({show: false, frame: false, width:350, height:500})
loading.loadFile(__dirname + '/loading.html')
loading.once('ready-to-show', () => {
loading.show()
})
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
app.on('login', function(event, webContents, request, authInfo, callback) { // When we need to log in, send the un/pw
event.preventDefault()
callback('token', config['auth_token'])
})
createWindow(loading)
})