This repository has been archived by the owner on Jun 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
73 lines (62 loc) · 2.06 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
const {app, BrowserWindow, globalShortcut, Menu, Tray, ipcMain } = require('electron')
let pyroTray = null;
var pyro;
function pyrostart() {
console.log('App loading')
app.whenReady().then(() => {
pyro = new BrowserWindow({
width: 1400,
height: 800,
minWidth: 1000,
minHeight: 600,
webPreferences: {
preload: "preload.js",
webviewTag: true,
nodeIntegration: true,
contextIsolation: false
},
show: false,
icon: "static/desktop_icon.ico",
titleBarStyle: 'hidden',
hasShadow: true,
autoHideMenuBar: true,
frame: false,
backgroundColor: "#101015"
})
pyro.loadFile('app.html').then()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
pyro.loadFile('app.html').then(null)
}
})
pyro.show()
console.log('App loaded')
// Keyboard shortcut to open Pyro
globalShortcut.register('Alt+P', () => {
pyro.show()
})
// init tray menu and set labels/functions
pyroTray = new Tray('img/favicon.png');
const pyroContextMenu = Menu.buildFromTemplate([
{ label: 'Open Pyro', type: 'normal', click: () => pyro.show() },
{ label: 'Separator', type: 'separator' },
{ label: 'Paste Clipboard', type: 'normal' },
{ label: 'Upload File', type: 'normal' },
{ label: 'Separator', type: 'separator' },
{ label: 'Credits', type: 'normal' },
{ label: 'Quit Pyro', type: 'normal', click: () => app.quit()}
])
// Set the tray menu
pyroTray.setToolTip("Pyro App");
pyroTray.setContextMenu(pyroContextMenu)
})
}
pyrostart()
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
ipcMain.on('minimize', () => {
pyro.minimize()
})