-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
40 lines (40 loc) · 952 Bytes
/
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
const {app, Menu, Tray } = require('electron')
const starfish = require('starfish-server')
const open = require('open')
let tray = null
const init = () => {
const homedir = require('os').homedir();
starfish({ db: homedir + "/.starfish" })
createTray()
open("http://localhost:21000")
}
const createTray = () => {
tray = new Tray(process.resourcesPath + "/extraResources/icon.png")
const contextMenu = Menu.buildFromTemplate([{
label: 'Dashboard',
click: () => {
open("http://localhost:21000")
}
}, {
label: 'Exit',
click: () => {
app.quit()
}
}])
if (process.platform === 'win32') {
tray.on('click', () => {
tray.popUpContextMenu(contextMenu)
})
}
tray.setToolTip('Starfish')
tray.setContextMenu(contextMenu)
}
app.whenReady().then(() => {
init()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
if (app.dock) app.dock.hide()