fix: hiding window menu should work on startup (#21436)

* fix: menu visibility should not be overwritten on startup

* fix: removing menu for window without global menubar

* test: setMenu tests are not for mac
This commit is contained in:
Cheng Zhao 2019-12-10 04:17:36 +09:00 committed by Samuel Attard
parent 7f6b308bf1
commit 3cb0ed306b
7 changed files with 88 additions and 15 deletions

View file

@ -195,13 +195,14 @@ app.on('window-all-closed', () => {
}
})
Promise.all([
import('@electron/internal/browser/default-menu'),
app.whenReady()
]).then(([{ setDefaultApplicationMenu }]) => {
// Create default menu
setDefaultApplicationMenu()
})
const { setDefaultApplicationMenu } = require('@electron/internal/browser/default-menu')
// Create default menu.
//
// Note that the task must be added before loading any app, so we can make sure
// the call is maded before any user window is created, otherwise the default
// menu may show even when user explicitly hides the menu.
app.once('ready', setDefaultApplicationMenu)
if (packagePath) {
// Finally load app's main.js and transfer control to C++.