Skip to content

A full-featured download manager.

feat: restore window state at init

Dr_rOot90f0a7c5f62d
diff --git a/src/main/ui/WindowManager.js b/src/main/ui/WindowManager.js
index b0d8a596..cf7da307 100644
--- a/src/main/ui/WindowManager.js
+++ b/src/main/ui/WindowManager.js
@@ -57,6 +57,17 @@ export default class WindowManager extends EventEmitter {
return result
}
+ getPageBounds (page) {
+ const enabled = this.userConfig['keep-window-state']
+ const windowStateMap = this.userConfig['window-state'] || {}
+ let result = null
+ if (enabled) {
+ result = windowStateMap[page]
+ }
+
+ return result
+ }
+
openWindow (page, options = {}) {
const pageOptions = this.getPageOptions(page)
const { hidden } = options
@@ -73,6 +84,12 @@ export default class WindowManager extends EventEmitter {
...pageOptions.attrs
})
+ const bounds = this.getPageBounds(page)
+ console.log('bounds ====>', bounds)
+ if (bounds) {
+ window.setBounds(bounds)
+ }
+
window.webContents.on('new-window', (e, url) => {
e.preventDefault()
shell.openExternal(url)