feat: use default-app behavior in packaged apps (#16310)
Unify the behavior between default app and packaged apps: - create default application menu unless the app has one - default window-all-closed handling unless the app handles the event
This commit is contained in:
parent
8e2ab8b20b
commit
23d44e322d
11 changed files with 133 additions and 37 deletions
|
@ -7,8 +7,6 @@ const Module = require('module')
|
|||
const path = require('path')
|
||||
const url = require('url')
|
||||
|
||||
const { setDefaultApplicationMenu } = require('./menu')
|
||||
|
||||
// Parse command line options.
|
||||
const argv = process.argv.slice(1)
|
||||
|
||||
|
@ -59,18 +57,6 @@ if (nextArgIsRequire) {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
// Quit when all windows are closed and no other one is listening to this.
|
||||
app.on('window-all-closed', () => {
|
||||
if (app.listeners('window-all-closed').length === 1 && !option.interactive) {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
// Create default menu.
|
||||
app.once('ready', () => {
|
||||
setDefaultApplicationMenu()
|
||||
})
|
||||
|
||||
// Set up preload modules
|
||||
if (option.modules.length > 0) {
|
||||
Module._preloadModules(option.modules)
|
||||
|
@ -142,6 +128,9 @@ function startRepl () {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
// prevent quitting
|
||||
app.on('window-all-closed', () => {})
|
||||
|
||||
const repl = require('repl')
|
||||
repl.start('> ').on('exit', () => {
|
||||
process.exit(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue