From 34c37b191d87cd5bf718c2c9f64631add06cfc3a Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sun, 22 Mar 2020 19:24:29 +0800 Subject: [PATCH] Preserve window maximized state (#670) * Update package.json * Update main.js * Update main.js * Update package.json * Update setting.js * Update setting.js * Update main.js * Update main.js --- src/main.js | 13 +++++++++++++ src/setting.js | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 1745f614c..84e757b2d 100644 --- a/src/main.js +++ b/src/main.js @@ -33,6 +33,19 @@ function newWindow(path) { window.show() }) + if (setting.get('window.maximized') === true) { + window.maximize() + } + + // store the window size + window.on('maximize', () => { + setting.set('window.maximized', true) + }) + + window.on('unmaximize', () => { + setting.set('window.maximized', false) + }) + window.on('closed', () => { window = null }) diff --git a/src/setting.js b/src/setting.js index 8048f93fa..3312747a8 100644 --- a/src/setting.js +++ b/src/setting.js @@ -211,7 +211,8 @@ let defaults = { 'window.height': 604, 'window.minheight': 440, 'window.minwidth': 526, - 'window.width': 564 + 'window.width': 564, + 'window.maximized': false } let eventEmitters = {}