-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.js
46 lines (38 loc) · 1.08 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
const path = require('path')
const { app, BrowserWindow, Tray } = require('electron')
const Positioner = require('electron-positioner')
app.dock.hide()
app.on('ready', () => {
const tray = new Tray(path.resolve(__dirname, 'static', 'images', 'hue.png'))
const view = new BrowserWindow({
width: 300,
height: 400,
frame: false,
resizable: false,
movable: false,
minimizable: false,
maximizable: false,
show: false,
alwaysOnTop: true,
skipTaskbar: true
})
const pos = new Positioner(view)
tray.on('click', () => {
tray.setImage(path.resolve(__dirname, 'static', 'images', 'hue-white.png'))
const { x, y } = pos.calculate('trayCenter', tray.getBounds())
view.setPosition(x, y, false)
view.show()
view.focus()
})
view.on('show', () => {
tray.setHighlightMode('always')
})
view.on('blur', () => {
view.hide()
})
view.on('hide', () => {
tray.setImage(path.resolve(__dirname, 'static', 'images', 'hue.png'))
tray.setHighlightMode('never')
})
view.loadURL(`file://${__dirname}/static/index.html`)
})