-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
executable file
·86 lines (69 loc) · 1.72 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
86
'use strict'
const {
electron,
ipcMain,
app,
dialog,
Tray,
Menu,
BrowserWindow,
nativeImage,
clipboard,
shell
} = require('electron');
const path = require('path');
let mainWindow;
let createWindow = () => {
mainWindow = new BrowserWindow({
minWidth: 400,
minHeight: 750,
width: 400,
height: 750,
transparent: true,
frame: false,
icon: path.join(path.resolve(app.getAppPath(), './assets/lo-icon@2x.png'))
})
mainWindow.loadURL(path.join('file://', __dirname, '/index.html'));
mainWindow.on('closed', () => {
mainWindow = null
});
// System tray.
//Tray with native image also this one fix the "index 0" error but still not shown image
let image = nativeImage.createFromPath('./app/assets/lo-icon@2x.png')
let tray = new Tray(image)
var contextMenu = Menu.buildFromTemplate([
{ label: 'open', click: () => {mainWindow.restore(); mainWindow.show();} },
{ label: 'minimize', click: () => {mainWindow.minimize();} },
{ label: 'close', click:
function handleClicked () {
app.quit();
}
}
]);
tray.on('click', function handleClicked () {
mainWindow.restore();
mainWindow.show();
});
tray.setToolTip('Material Account App');
tray.setContextMenu(contextMenu);
}
ipcMain.on('close-main-window', function () {
app.quit();
});
ipcMain.on('minimize', function () {
mainWindow.minimize();
});
ipcMain.on('go-to-github', function () {
shell.openExternal('https://github.com/ue/electra');
});
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
})