Platform-dependent "About" menu placement

This commit is contained in:
Nick Denry 2020-05-28 00:05:11 +03:00
parent 3e5de6ea64
commit d06000103f
1 changed files with 20 additions and 11 deletions

View File

@ -9,10 +9,9 @@ let menuService = {}
menuService.createMenu = () => { menuService.createMenu = () => {
const application = { const isMac = process.platform === 'darwin'
label: 'Chimeverse',
submenu: [ const about = {
{
label: 'About Chimeverse', label: 'About Chimeverse',
click: () => { click: () => {
// @see https://github.com/electron/electron/issues/16558#issuecomment-484460276 // @see https://github.com/electron/electron/issues/16558#issuecomment-484460276
@ -21,7 +20,12 @@ menuService.createMenu = () => {
activeWindow.show() activeWindow.show()
activeWindow.webContents.send('about-page-event') activeWindow.webContents.send('about-page-event')
} }
}, }
const application = {
label: 'Chimeverse',
submenu: [
... isMac ? [about] : [],
{ {
label: 'Reconnect', label: 'Reconnect',
accelerator: 'CmdOrCtrl+R', accelerator: 'CmdOrCtrl+R',
@ -103,7 +107,12 @@ menuService.createMenu = () => {
], ],
} }
const template = [application, edit] const help = {
label: 'Help',
submenu: [about]
}
const template = [application, edit, ... !isMac ? help : []]
Menu.setApplicationMenu(Menu.buildFromTemplate(template)) Menu.setApplicationMenu(Menu.buildFromTemplate(template))
} }