-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
46 lines (40 loc) · 1.09 KB
/
main.js
File metadata and controls
46 lines (40 loc) · 1.09 KB
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
const electron = require('electron');
const url = require('url');
const path = require('path');
const {app, BrowserWindow, Menu, dialog} = electron;
let mainWindow;
// listen for app to be ready
app.on('ready', () => {
// create new window
mainWindow = new BrowserWindow({});
// open dev tools
mainWindow.webContents.openDevTools();
// load html into window
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'mainWindow.html'),
protocol: 'file',
slashes: true
}));
// build menu from template
const mainMenu = Menu.buildFromTemplate(template);
// insert menu
Menu.setApplicationMenu(mainMenu);
})
// create menu template
const template = [];
if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
})
}