-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
39 lines (32 loc) · 1017 Bytes
/
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
'use strict'
const { app, shell, Menu, Tray } = require('electron');
const path = require('path');
const { menubar } = require('menubar');
const iconPath = path.join(__dirname, 'app', 'IconTemplate.png');
app.on('ready', () => {
const tray = new Tray(iconPath);
const contextMenu = Menu.buildFromTemplate([
{ label: 'Quit', role: 'quit', click: () => app.exit() },
]);
tray.addListener('right-click', () => tray.popUpContextMenu(contextMenu))
const hotelClerk = menubar({
tray,
index: 'http://localhost:2000',
browserWindow: {
width: 350,
height: 350,
},
preloadWindow: true,
});
hotelClerk.on('after-create-window', function () {
const webContents = hotelClerk.window.webContents;
const handleRedirect = (e, url) => {
if (url != webContents.getURL()) {
e.preventDefault()
shell.openExternal(url)
}
};
webContents.on('will-navigate', handleRedirect);
webContents.on('new-window', handleRedirect);
});
});