2019-02-12 14:22:33 +00:00
|
|
|
import { shell, Menu } from 'electron'
|
2019-01-10 19:54:34 +00:00
|
|
|
|
2019-03-18 19:37:06 +00:00
|
|
|
const v8Util = process.electronBinding('v8_util')
|
2018-09-21 05:24:42 +00:00
|
|
|
|
2019-01-10 13:32:03 +00:00
|
|
|
const isMac = process.platform === 'darwin'
|
|
|
|
|
2019-02-12 14:22:33 +00:00
|
|
|
export const setDefaultApplicationMenu = () => {
|
|
|
|
if (v8Util.getHiddenValue<boolean>(global, 'applicationMenuSet')) return
|
2018-09-21 05:24:42 +00:00
|
|
|
|
2019-02-12 14:22:33 +00:00
|
|
|
const helpMenu: Electron.MenuItemConstructorOptions = {
|
2019-01-10 13:32:03 +00:00
|
|
|
role: 'help',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Learn More',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
|
|
|
await shell.openExternal('https://electronjs.org')
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Documentation',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
|
|
|
const version = process.versions.electron
|
|
|
|
await shell.openExternal(`https://github.com/electron/electron/tree/v${version}/docs#readme`)
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Community Discussions',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
|
|
|
await 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',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
|
|
|
await 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-02-12 14:22:33 +00:00
|
|
|
const macAppMenu: Electron.MenuItemConstructorOptions = { role: 'appMenu' }
|
|
|
|
const template: Electron.MenuItemConstructorOptions[] = [
|
|
|
|
...(isMac ? [macAppMenu] : []),
|
2019-01-10 13:32:03 +00:00
|
|
|
{ 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)
|
|
|
|
}
|