-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
62 lines (55 loc) · 1.31 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
53
54
55
56
57
58
59
60
61
62
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const Tray = electron.Tray;
const path = require('path');
const Menu = electron.Menu;
const MenuItem = electron.MenuItem;
const trayIconPath = path.join(__dirname,'/assets/images/colors.png')
let win
let tray = null ;
function createWindow () {
win = new BrowserWindow({
show:false,
height:618,width:1124,
resizable: false,frame:false
})
win.webContents.openDevTools
win.loadURL('file://'+__dirname+'/src/index.html')
win.once('ready-to-show', () => {
win.show()
})
win.on('closed', () => {
win = null
})
}
function createTray(paams) {
tray = new Tray(trayIconPath)
tray.setToolTip('Material design colors')
tray.on('double-click', () => {
win.show();
})
let tray_menu = new Menu();
tray_menu.append( new MenuItem({
label:'Open',
click:() => {
win.show();
}
}));
tray_menu.append( new MenuItem({role:'quit'}));
tray.setContextMenu(tray_menu);
}
app.on('ready', () => {
createWindow()
createTray()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})