-
Notifications
You must be signed in to change notification settings - Fork 48
/
main.js
52 lines (45 loc) · 1.28 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
const electron = require('electron');
const tray = require('./tray');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const mainPage = 'file://' + __dirname + '/public/index.html';
var isQuitting = false;
var mainWindow = null;
app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit();
}
});
app.on('ready', function() {
mainWindow = new BrowserWindow({
autoHideMenuBar: false,
webPreferences: {
nodeIntegration: false
},
width: 1200,
height: 750,
icon: __dirname + '/resources/app/public/images/batcave_small.png'
});
mainWindow.loadURL(mainPage);
tray.create(mainWindow);
// mainWindow.openDevTools();
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.on('close', e => {
if (!isQuitting) {
e.preventDefault();
if (process.platform === 'darwin') {
app.hide();
} else {
mainWindow.hide();
}
}
});
app.on('before-quit', function() {
isQuitting = true;
});
});