-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
84 lines (76 loc) · 1.96 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
81
82
83
const { app, BrowserWindow,nativeImage, Menu, Tray } = require('electron');
const { updateElectronApp, UpdateSourceType } = require('update-electron-app');
const { join } = require('path');
updateElectronApp(); // additional configuration options available
app.on('before-quit', function () {
isQuiting = true;
});
let win = null
const gotTheLock = app.requestSingleInstanceLock()
const createWindow = () => {
icon = nativeImage.createFromPath(join(__dirname, "src", "icons", "32x32.png"))
win = new BrowserWindow({
width: 1200,
height: 800,
title: 'ZvukApp',
icon: icon,
});
win.on('page-title-updated', (evt) => {
evt.preventDefault();
win.setTitle("ZvukApp");
});
win.loadURL('https://zvuk.com/');
win.on('minimize',function(event){
event.preventDefault();
win.hide();
});
}
if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to start a second instance, focus our window.
if (win) {
if (win.isMinimized()) win.show()
}
})
// Create myWindow, load the rest of the application, etc.
app.whenReady().then(() => {
createWindow()
icon = nativeImage.createFromPath(join(__dirname, "src", "icons", "32x32.png"))
tray = new Tray(icon)
tray.setContextMenu(Menu.buildFromTemplate([
{
label: 'Show App', click: function () {
win.show();
}
},
{
label: 'Quit', click: function () {
isQuiting = true;
app.quit();
}
}
]));
tray.on('click', function(e){
if (!win.isVisible()){
win.show();
}
});
tray.on('double-click', function(e){
if (win.isVisible()){
win.hide();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
}
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})