-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
67 lines (59 loc) · 1.53 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
const {app, BrowserWindow, TouchBar} = require('electron')
const {TouchBarLabel, TouchBarSpacer} = TouchBar
const windowStateKeeper = require('electron-window-state')
let mainWindow
const artist = new TouchBarLabel({textColor: '#5c43e8'})
const track = new TouchBarLabel({textColor: '#555555'})
const time = new TouchBarLabel({textColor: '#5c43e8'})
const touchBar = new TouchBar([
artist,
new TouchBarSpacer({size: 'small'}),
track,
new TouchBarSpacer({size: 'small'}),
time
])
const createWindow = () => {
let mainWindowState = windowStateKeeper({
defaultWidth: 1200,
defaultHeight: 800
})
mainWindow = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
titleBarStyle: 'hidden',
darkTheme: true,
show: false,
webPreferences: {
backgroundThrottling: false
}
})
mainWindowState.manage(mainWindow)
mainWindow.loadURL(`file://${__dirname}/components/app/index.html`)
mainWindow.setTouchBar(touchBar)
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
mainWindow.on('closed', () => {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
})
app.updateTouchBar = metadata => {
artist.label = metadata.artist
track.label = metadata.track
}
app.updateTouchBarTime = duration => {
time.label = duration
}