-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cjs
73 lines (62 loc) · 1.77 KB
/
main.cjs
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
const { app, BrowserWindow, Menu, MenuItem } = require('electron')
const config = require("./config.json");
const handleQuickNavigationClick = async (menuItem, focusedWindow, _) => {
await focusedWindow.loadURL(config.navigation[menuItem.id]);
};
const createWindow = () => {
const win = new BrowserWindow({
width: config.windowWidth,
height: config.windowHeight,
show: false,
icon: 'resources/material_apps.png',
});
// Same behaviour as win.webContents.loadURL(...)
win.loadURL(config.appUrl);
win.once('ready-to-show', () => {
win.setTitle(config.title);
// Add quick navigation menu item
const appMenu = Menu.getApplicationMenu();
const quickNavigationMenuItem = new MenuItem({
label: 'Quick Navigation',
id: 'quick-nav',
submenu: [
{
id: 'drive',
label: 'Drive',
click: handleQuickNavigationClick,
},
{
id: 'photos',
label: 'Photos',
click: handleQuickNavigationClick,
},
{
id: 'keep',
label: 'Keep',
click: handleQuickNavigationClick,
},
{
id: 'calendar',
label: 'Calendar and Tasks',
click: handleQuickNavigationClick,
}
]
});
appMenu.append(quickNavigationMenuItem);
Menu.setApplicationMenu(appMenu);
win.show();
})
// Load contents of new windows in main window instead.
// Avoids desktop clutter
win.webContents.setWindowOpenHandler((details) => {
win.loadURL(details.url);
return {action: 'deny'};
})
}
app.whenReady().then(() => {
createWindow();
});
app.on('window-all-closed', () => {
app.quit();
});
console.log("Session data (inc. logged in account) stored in: " + app.getPath("sessionData"));