A full-featured download manager.
refactor: app quit
Dr_rOot11c507008bad
diff --git a/src/main/Application.js b/src/main/Application.jsindex b295a8d0..a3d7f090 100644--- a/src/main/Application.js+++ b/src/main/Application.js@@ -79,6 +79,8 @@ export default class Application extends EventEmitter {}startEngine () {+ const self = this+try {this.engine.start()} catch (err) {@@ -89,7 +91,7 @@ export default class Application extends EventEmitter {message: this.i18n.t('app.system-error-message', { message })}).then(_ => {setTimeout(() => {- app.quit()+ self.quit()}, 100)})}@@ -200,9 +202,19 @@ export default class Application extends EventEmitter {}stop () {- this.engine.stop()- this.energyManager.stopPowerSaveBlocker()- this.trayManager.destroy()+ try {+ this.engineClient.shutdown()+ this.trayManager.destroy()+ this.engine.stop()+ this.energyManager.stopPowerSaveBlocker()+ } catch (err) {+ logger.warn(`[Motrix] stop error: `, err.message)+ }+ }++ quit () {+ this.stop()+ app.quit()}sendCommand (command, ...args) {@@ -333,17 +345,10 @@ export default class Application extends EventEmitter {})}- relaunch (page = 'index') {+ relaunch () {this.stop()app.relaunch()app.exit()- // this.closePage(page)- // if (page === 'index') {- // this.engine.restart()- // }- // setTimeout(() => {- // this.showPage(page)- // }, 500)}savePreference (config = {}) {@@ -368,9 +373,8 @@ export default class Application extends EventEmitter {this.relaunch()})- this.on('application:exit', () => {- this.stop()- app.exit()+ this.on('application:quit', () => {+ this.quit()})this.on('application:open-at-login', (openAtLogin) => {diff --git a/src/main/menus/darwin.json b/src/main/menus/darwin.jsonindex 8d938fd4..df9def12 100644--- a/src/main/menus/darwin.json+++ b/src/main/menus/darwin.json@@ -11,7 +11,7 @@{ "id": "app.hide-others", "role": "hideothers" },{ "id": "app.unhide", "role": "unhide" },{ "type": "separator" },- { "id": "app.quit", "role": "quit" }+ { "id": "app.quit", "command": "application:quit" }]},{diff --git a/src/main/menus/linux.json b/src/main/menus/linux.jsonindex 8285cac9..fbc34f82 100644--- a/src/main/menus/linux.json+++ b/src/main/menus/linux.json@@ -9,7 +9,7 @@{ "id": "app.check-for-updates", "command": "application:check-for-updates" },{ "id": "app.show", "command": "application:show", "command-arg": "index" },{ "type": "separator" },- { "id": "app.quit", "role": "quit" }+ { "id": "app.quit", "command": "application:quit" }]},{diff --git a/src/main/menus/tray.json b/src/main/menus/tray.jsonindex e612f9d4..7b2d97a3 100644--- a/src/main/menus/tray.json+++ b/src/main/menus/tray.json@@ -8,5 +8,5 @@{ "id": "app.check-for-updates", "command": "application:check-for-updates" },{ "type": "separator" },{ "id": "app.preferences", "command": "application:preferences", "command-before": "application:show,index" },- { "id": "app.quit", "role": "quit" }+ { "id": "app.quit", "command": "application:quit" }]diff --git a/src/main/menus/win32.json b/src/main/menus/win32.jsonindex 81c18b8d..0e756dd1 100644--- a/src/main/menus/win32.json+++ b/src/main/menus/win32.json@@ -9,7 +9,7 @@{ "id": "app.check-for-updates", "command": "application:check-for-updates" },{ "id": "app.show", "command": "application:show", "command-arg": "index" },{ "type": "separator" },- { "id": "app.quit", "role": "quit" }+ { "id": "app.quit", "command": "application:quit" }]},{diff --git a/src/shared/keymap.json b/src/shared/keymap.jsonindex f04980b4..1a52f97a 100644--- a/src/shared/keymap.json+++ b/src/shared/keymap.json@@ -1,4 +1,5 @@{+ "cmd-q": "application:quit","cmd-n": "application:new-task","cmd-shift-n": "application:new-bt-task","cmd-o": "application:open-file",