-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
80 lines (66 loc) · 2.05 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const path = require('path');
const { app,
BrowserWindow,
globalShortcut } = require('electron');
const { embedTouchBar } = require('./touchbar.js');
if (process.platform === 'linux') {
const { createMprisPlayer } = require('./player.js');
}
const config = require('./config/config.js');
const { showNotifications } = require('./notifications/notificatoins.js');
const { createTray } = require('./tray/tray.js')
let mainWindow = null;
const singleInstanceLock = app.requestSingleInstanceLock();
if (!singleInstanceLock) {
app.quit();
}
app.on('second-instance', () => {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.focus()
}
});
app.on('ready', function () {
const hideMenuBar = config.get("hideMenuBar", false);
mainWindow = new BrowserWindow({
width: 1024,
height: 768,
center: true,
show: false,
backgroundColor: '#2e2c29',
title: 'Yandex.Music',
autoHideMenuBar: hideMenuBar,
icon: path.join(app.getAppPath(), 'static/icon.png'),
webPreferences: {
nodeIntegration: false,
preload: path.join(__dirname, 'preload.js'),
},
});
require("./menu/mainmenu.js");
mainWindow.on('closed', function() {
app.quit();
});
mainWindow.once('ready-to-show', () => {
mainWindow.show();
if (process.platform === 'darwin') {
embedTouchBar(mainWindow);
}
if (process.platform === 'linux') {
createTray(mainWindow);
createMprisPlayer(mainWindow);
}
});
mainWindow.loadURL('https://music.yandex.ru');
showNotifications();
globalShortcut.register('mediaplaypause', function() {
mainWindow.webContents.send('playpause');
});
globalShortcut.register('medianexttrack', function() {
mainWindow.webContents.send('next');
});
globalShortcut.register('mediaprevioustrack', function() {
mainWindow.webContents.send('prev');
});
});