fix: set default menu in will-finish-launching event (#23214)
This commit is contained in:
parent
69ccf94d45
commit
cb6a1e2c5e
2 changed files with 7 additions and 5 deletions
|
@ -207,10 +207,9 @@ const { setDefaultApplicationMenu } = require('@electron/internal/browser/defaul
|
|||
|
||||
// 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.whenReady().then(setDefaultApplicationMenu);
|
||||
// The |will-finish-launching| event is emitted before |ready| event, so default
|
||||
// menu is set before any user window is created.
|
||||
app.once('will-finish-launching', setDefaultApplicationMenu);
|
||||
|
||||
if (packagePath) {
|
||||
// Finally load app's main.js and transfer control to C++.
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
|
||||
let win;
|
||||
app.whenReady().then(function () {
|
||||
// This test uses "app.once('ready')" while the |test-menu-null| test uses
|
||||
// "app.whenReady()", the 2 APIs have slight difference on timing to cover
|
||||
// more cases.
|
||||
app.once('ready', function () {
|
||||
win = new BrowserWindow({});
|
||||
win.setMenuBarVisibility(false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue