From a7a9e96a58bc4b87aa37c4ef1898a5cbdd5570fb Mon Sep 17 00:00:00 2001 From: Zhongyi Tong Date: Sun, 6 Aug 2017 00:25:56 +0800 Subject: [PATCH] Set application menu in AppMenu.setMenu instead of in main.js. --- app/main/index.js | 2 +- app/main/menu.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/main/index.js b/app/main/index.js index 36264e19..243624f6 100644 --- a/app/main/index.js +++ b/app/main/index.js @@ -153,7 +153,7 @@ app.on('activate', () => { }); app.on('ready', () => { - electron.Menu.setApplicationMenu(appMenu.getMenu()); + appMenu.setMenu(); mainWindow = createMainWindow(); const page = mainWindow.webContents; diff --git a/app/main/menu.js b/app/main/menu.js index 6e9060ba..ad84aac7 100644 --- a/app/main/menu.js +++ b/app/main/menu.js @@ -343,9 +343,10 @@ class AppMenu { }); } - getMenu() { + setMenu() { const tpl = process.platform === 'darwin' ? this.getDarwinTpl() : this.getOtherTpl(); - return Menu.buildFromTemplate(tpl); + const menu = Menu.buildFromTemplate(tpl); + Menu.setApplicationMenu(menu); } }