A full-featured download manager.
feat: store window state
Dr_rOot9b61dad2c366
diff --git a/src/main/Application.js b/src/main/Application.jsindex 8f9d6bc2..7bea4e5c 100644--- a/src/main/Application.js+++ b/src/main/Application.js@@ -38,9 +38,7 @@ export default class Application extends EventEmitter {this.initTouchBarManager()- this.windowManager = new WindowManager({- userConfig: this.configManager.getUserConfig()- })+ this.initWindowManager()this.engine = new Engine({systemConfig: this.configManager.getSystemConfig(),@@ -82,6 +80,37 @@ export default class Application extends EventEmitter {}}+ initWindowManager () {+ this.windowManager = new WindowManager({+ userConfig: this.configManager.getUserConfig()+ })++ this.windowManager.on('window-resized', (data) => {+ this.storeWindowState(data)+ })+ this.windowManager.on('window-moved', (data) => {+ this.storeWindowState(data)+ })+ this.windowManager.on('window-closed', (data) => {+ this.storeWindowState(data)+ })+ }++ storeWindowState (data = {}) {+ const enabled = this.configManager.getUserConfig('keep-window-state')+ if (!enabled) {+ return+ }++ const state = this.configManager.getUserConfig('window-state', {})+ const { page, bounds } = data+ const newState = {+ ...state,+ [page]: bounds+ }+ this.configManager.setUserConfig('window-state', newState)+ }+start (page, options = {}) {this.showPage(page, options)}diff --git a/src/main/core/ConfigManager.js b/src/main/core/ConfigManager.jsindex 62bebe41..fd6e7fc4 100644--- a/src/main/core/ConfigManager.js+++ b/src/main/core/ConfigManager.js@@ -117,11 +117,13 @@ export default class ConfigManager {'new-task-show-downloading': true,'open-at-login': false,'resume-all-when-app-launched': false,+ 'keep-window-state': false,'session-path': getSessionPath(),'task-notification': true,'theme': 'auto','update-channel': 'latest',- 'use-proxy': false+ 'use-proxy': false,+ 'window-state': {}}})this.fixUserConfig()