forked from angrykoala/gaucho
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
68 lines (55 loc) · 1.65 KB
/
main.js
File metadata and controls
68 lines (55 loc) · 1.65 KB
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
"use strict";
const path = require('path');
const MainWindow = require('./app/main/main_window');
const AppEvents = require('./app/main/app_events');
const UserConfig = require('./app/main/user_config');
//system tray icon
const {app, Menu, Tray} = require('electron')
let tray = null
function isDevEnv() {
return process.env.NODE_ENV === "dev";
}
//Global reference to window
let win = null;
function initApp() {
function createWindow() {
if (win === null) {
const iconPath = path.join(__dirname, 'resources', 'icon.png');
const htmlUrl = "file://" + __dirname + "/index.html";
UserConfig.loadConfig((config) => {
win = new MainWindow()
.setIcon(iconPath)
.setIndex(htmlUrl)
.setUserConfig(config)
.initWindow(isDevEnv());
win.on('minimize',function(event){
event.preventDefault()
win.hide();
});
win.on('close', function (event) {
if( !app.isQuiting){
event.preventDefault()
win.hide();
}
return false;
});
});
}
}
AppEvents(createWindow);
}
app.on('ready', () => {
tray = new Tray('resources/icon.png')
const contextMenu = Menu.buildFromTemplate([
{ label: 'Show App', click: function(){
win.show();
} },
{ label: 'Quit', click: function(){
app.isQuiting = true;
app.quit();
} }
]);
tray.setToolTip('LinkMe Task Runner')
tray.setContextMenu(contextMenu)
})
initApp();