Platform-dependent "About" menu placement
This commit is contained in:
parent
3e5de6ea64
commit
d06000103f
|
@ -9,19 +9,23 @@ let menuService = {}
|
||||||
|
|
||||||
menuService.createMenu = () => {
|
menuService.createMenu = () => {
|
||||||
|
|
||||||
|
const isMac = process.platform === 'darwin'
|
||||||
|
|
||||||
|
const about = {
|
||||||
|
label: 'About Chimeverse',
|
||||||
|
click: () => {
|
||||||
|
// @see https://github.com/electron/electron/issues/16558#issuecomment-484460276
|
||||||
|
// let activeWindow = BrowserWindow.getFocusedWindow()
|
||||||
|
let activeWindow = BrowserWindow.getAllWindows()[0]
|
||||||
|
activeWindow.show()
|
||||||
|
activeWindow.webContents.send('about-page-event')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const application = {
|
const application = {
|
||||||
label: 'Chimeverse',
|
label: 'Chimeverse',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
... isMac ? [about] : [],
|
||||||
label: 'About Chimeverse',
|
|
||||||
click: () => {
|
|
||||||
// @see https://github.com/electron/electron/issues/16558#issuecomment-484460276
|
|
||||||
// let activeWindow = BrowserWindow.getFocusedWindow()
|
|
||||||
let activeWindow = BrowserWindow.getAllWindows()[0]
|
|
||||||
activeWindow.show()
|
|
||||||
activeWindow.webContents.send('about-page-event')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
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))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue