-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
59 lines (50 loc) · 1.1 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
/* eslint-disable-next-line import/no-extraneous-dependencies */
const { BrowserWindow, Menu, Tray, app } = require('electron');
const path = require('path');
// Set a variable when the app is quitting.
let isQuiting = false;
let win;
let tray;
app.on('ready', () => {
tray = new Tray(path.join(__dirname, 'icon.png'));
tray.setContextMenu(
Menu.buildFromTemplate([
{
label: 'Show App',
click() {
win.show();
},
},
{
label: 'Quit',
click() {
isQuiting = true;
app.quit();
},
},
])
);
win = new BrowserWindow();
// Load ibroadcast web player
win.loadURL('https://media.ibroadcast.com');
// Maximize window
win.maximize();
// On close, minimize and don't quit
win.on('close', (evt) => {
if (!isQuiting) {
evt.preventDefault();
win.hide();
}
});
win.on('minimize', (evt) => {
evt.preventDefault();
win.hide();
});
});
app.on('before-quit', () => {
isQuiting = true;
});
// Clicking on dock shows the application
app.on('activate', () => {
win.show();
});