-
-
Notifications
You must be signed in to change notification settings - Fork 111
/
index.js
85 lines (71 loc) · 2.16 KB
/
index.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*global require,process,__dirname*/
const {app, Menu, BrowserWindow, shell} = require('electron')
, path = require('path')
, url = require('url')
, packageJSON = require('./package.json')
, applicationTemplate = packageJSON.appTemplate;
//Set main window height bigger for Windows ONLY
if (process.platform === 'win32') {
applicationTemplate.minHeight += 30;
applicationTemplate.height += 30;
}
//Set main window height smaller for Linux ONLY
if (process.platform !== 'win32' &&
process.platform !== 'darwin') {
applicationTemplate.minHeight -= 20;
applicationTemplate.height -= 20;
}
app.on('window-all-closed', () => {
app.quit();
});
app.on('ready', () => {
const mainWindow = new BrowserWindow(applicationTemplate)
, updateWindow = new BrowserWindow({
'width': 400,
'height': 192,
'parent': mainWindow,
'show': false,
'resizable': false,
'maximizable': false,
'alwaysOnTop': true,
'fullscreenable': false,
'title': ''
})
, OSMenu = require('./menu.js')(mainWindow, updateWindow, shell, packageJSON, app);
Menu.setApplicationMenu(Menu.buildFromTemplate(OSMenu));
updateWindow.loadURL(url.format({
'pathname': path.resolve(__dirname, 'dist', 'update.html'),
'protocol': 'file:',
'slashes': true
}));
updateWindow.on('close', event => {
event.preventDefault();
mainWindow.webContents.send('loading:unfreeze-app');
updateWindow.hide();
});
mainWindow.on('ready-to-show', () => {
mainWindow.show();
});
mainWindow.on('page-title-updated', event => {
//lock app title otherwise gets the index.html filename
event.preventDefault();
});
mainWindow.on('restore', () => {
//hide autoupdates window
updateWindow.hide();
mainWindow.webContents.send('loading:unfreeze-app');
});
mainWindow.on('enter-full-screen', () => {
//hide autoupdates window
updateWindow.hide();
mainWindow.webContents.send('loading:unfreeze-app');
});
mainWindow.on('closed', () => {
app.quit();
});
mainWindow.loadURL(url.format({
'pathname': path.resolve(__dirname, 'dist', 'index.html'),
'protocol': 'file:',
'slashes': true
}));
});