This repository was archived by the owner on Jan 19, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmenu.js
66 lines (63 loc) · 1.47 KB
/
menu.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
const { shell, dialog } = require('electron')
const isMac = process.platform === 'darwin'
function getMenuTemplate(mainWindow, funcs) {
return [
...(isMac ? [{
role: 'appMenu'
}] : []),
// { role: 'fileMenu' }
{
label: 'File',
submenu: [{
label: 'Open File',
accelerator: 'CmdOrCtrl+O',
// this is the main bit hijack the click event
click() {
// construct the select file dialog
dialog.showOpenDialog({
properties: ['openFile']
})
.then(function(fileObj) {
// the fileObj has two props
if (!fileObj.canceled) {
mainWindow.webContents.send('FILE_OPEN', fileObj.filePaths)
}
})
.catch(function(err) {
console.error(err)
})
}
},
isMac ? {
role: 'close'
} : {
role: 'quit'
}
]
},
{
role: 'editMenu'
},
{
role: 'viewMenu'
},
{
role: 'windowMenu'
},
{
role: 'help',
submenu: [{
label: 'Developer Website',
click: async () => {
await shell.openExternal('https://software.onpointcoding.net/whatsappexportviewer')
}
},{
label: 'About',
click: async () => {
funcs.openAbout()
}
}]
}
];
}
module.exports = { getMenuTemplate }