-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (37 loc) · 931 Bytes
/
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
'use strict';
const app = require('app');
const BrowserWindow = require('browser-window');
// report crashes to the Electron project
require('crash-reporter').start();
// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();
function createMainWindow () {
const win = new BrowserWindow({
width: 600,
height: 400,
resizable: false
});
win.loadUrl(`file://${__dirname}/index.html`);
win.on('closed', onClosed);
return win;
}
function onClosed() {
// deref the window
// for multiple windows store them in an array
mainWindow = null;
}
// prevent window being GC'd
let mainWindow;
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate-with-no-open-windows', function () {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});
app.on('ready', function () {
mainWindow = createMainWindow();
});