2018-09-21 05:24:42 +00:00
|
|
|
const { shell, Menu } = require('electron')
|
|
|
|
|
2019-01-10 13:32:03 +00:00
|
|
|
const isMac = process.platform === 'darwin'
|
|
|
|
|
2018-09-21 05:24:42 +00:00
|
|
|
const setDefaultApplicationMenu = () => {
|
|
|
|
if (Menu.getApplicationMenu()) return
|
|
|
|
|
2019-01-10 13:32:03 +00:00
|
|
|
const helpMenu = {
|
|
|
|
role: 'help',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Learn More',
|
|
|
|
click () {
|
|
|
|
shell.openExternal('https://electronjs.org')
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Documentation',
|
|
|
|
click () {
|
|
|
|
shell.openExternal(
|
|
|
|
`https://github.com/electron/electron/tree/v${process.versions.electron}/docs#readme`
|
|
|
|
)
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Community Discussions',
|
|
|
|
click () {
|
|
|
|
shell.openExternal('https://discuss.atom.io/c/electron')
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Search Issues',
|
|
|
|
click () {
|
|
|
|
shell.openExternal('https://github.com/electron/electron/issues')
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
}
|
|
|
|
]
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
|
|
|
|
2019-01-10 13:32:03 +00:00
|
|
|
const template = [
|
|
|
|
...(isMac ? [{ role: 'appMenu' }] : []),
|
|
|
|
{ role: 'fileMenu' },
|
|
|
|
{ role: 'editMenu' },
|
|
|
|
{ role: 'viewMenu' },
|
|
|
|
{ role: 'windowMenu' },
|
|
|
|
helpMenu
|
|
|
|
]
|
|
|
|
|
2018-09-21 05:24:42 +00:00
|
|
|
const menu = Menu.buildFromTemplate(template)
|
|
|
|
Menu.setApplicationMenu(menu)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
setDefaultApplicationMenu
|
|
|
|
}
|