This repository was archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
75 lines (63 loc) · 2.07 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
'use strict';
const path = require('path');
const { app, BrowserWindow, ipcMain } = require('electron');
const { Player } = require('./src/player');
const { YamTouchBar } = require('./src/yamTouchBar');
const { ShortcutManager } = require('./src/shortcutManager');
const { YamTray } = require('./src/yamTray');
const { YamMenu } = require('./src/yamMenu');
const { YamDock } = require('./src/yamDock');
const { Notificator } = require('./src/notificator');
const store = require('./src/store');
let win = null;
app.on('ready', () => {
win = new BrowserWindow({
backgroundColor: '#121212',
width: 1200, height: 800,
webPreferences: {
preload: path.join(__dirname, 'src/inject.js'),
nodeIntegration: true,
experimentalFeatures: true,
show: false,
icon: path.join(__dirname, 'build/icon.png')
},
minimizable: false,
});
const player = new Player(win, ipcMain);
const touchBar = new YamTouchBar(player);
const yamMenu = new YamMenu(player);
const yamTray = new YamTray(win, player);
const yamDock = new YamDock(player);
const notificator = new Notificator(player);
const shortcuts = new ShortcutManager(win, player);
player.on('EVENT_READY', () => {
if (process.env.NODE_ENV !== 'test') {
win.setTouchBar(touchBar.build());
yamMenu.build();
yamTray.build();
notificator.build();
yamDock.build();
shortcuts.bindKeys(win);
}
});
win.loadURL('https://music.yandex.ru');
win.on('closed', () => {
win = null;
});
win.on('close', function (event) {
if(!app.isQuiting){
event.preventDefault();
win.hide();
if(store.get('settings.tray')) {
app.dock.hide();
}
}
return false;
});
app.on('activate', () => win.show());
win.on('ready-to-show', () => {
app.dock.show();
win.show();
win.focus();
});
});