-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
60 lines (46 loc) · 1.31 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
/// <reference path="typings/node/node.d.ts"/>
/*jslint node: true */
/*jshint esversion: 6 */
const { app, BrowserWindow, globalShortcut } = require('electron');
require('./main-process/application-menus');
require('./main-process/context-menus');
let mainWindow;
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
return true;
});
if (shouldQuit) {
app.quit();
}
app.on('ready', function () {
mainWindow = new BrowserWindow({
width: 1000,
height: 800,
icon: __dirname + '/icon.png'
});
mainWindow.show();
if(/\-\-debugging/i.test(process.argv[2])){
mainWindow.openDevTools();
}
mainWindow.loadURL('file://' + __dirname + '/app/index.html');
mainWindow.webContents.on('did-finish-load', function() {
if(process.platform.toLowerCase() === 'darwin'){
mainWindow.webContents.send('isMac', true);
}
});
globalShortcut.register('CmdOrCtrl+F12', function () {
mainWindow.show();
});
mainWindow.on('closed', function () {
mainWindow = null;
});
});
app.on('window-all-closed', () => {
if (process.platform.toLowerCase() !== 'darwin') {
app.quit();
}
});