From b73ffcf64ad9bef1432aa68824b7443abcd72503 Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sat, 21 Mar 2020 18:57:02 +0800 Subject: [PATCH 1/8] Update package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 4e5b9ae3a..f23f8d57c 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "argv-split": "^2.0.1", "classnames": "^2.2.6", "dolm": "^0.7.3-beta", + "electron-store": "^5.1.1", "fix-path": "^3.0.0", "iconv-lite": "^0.5.1", "jschardet": "^2.1.1", From 5127b59137cbc9de82033149cb219c4f1af9e293 Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sat, 21 Mar 2020 18:57:43 +0800 Subject: [PATCH 2/8] Update main.js --- src/main.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 1745f614c..60bc69187 100644 --- a/src/main.js +++ b/src/main.js @@ -4,6 +4,14 @@ const i18n = require('./i18n') const setting = require('./setting') const updater = require('./updater') +const Store = require('electron-store') +const store = new Store() + +// get the previous size +let preWidth = store.get('preWidth') +let preHeight = store.get('preHeight') +let maxWindow = store.get('maxWindow') + let windows = [] let openfile = null @@ -13,8 +21,8 @@ function newWindow(path) { process.platform === 'linux' ? resolve(__dirname, '../logo.png') : null, title: app.name, useContentSize: true, - width: setting.get('window.width'), - height: setting.get('window.height'), + width: preWidth ? preWidth : setting.get('window.width'), + height: preHeight ? preHeight : setting.get('window.height'), minWidth: setting.get('window.minwidth'), minHeight: setting.get('window.minheight'), autoHideMenuBar: !setting.get('view.show_menubar'), @@ -33,6 +41,24 @@ function newWindow(path) { window.show() }) + if (maxWindow === 'true') { + window.maximize() + } + + // store the window size + window.on('maximize', () => { + store.set('maxWindow', 'true') + }) + window.on('unmaximize', () => { + store.set('maxWindow', 'false') + }) + window.on('resize', () => { + const [nowWidth, nowHeight] = window.getSize() + store.set('preWidth', nowWidth) + store.set('preHeight', nowHeight) + //console.log(`Width: ${preWidth}, Height: ${preHeight}`); + }) + window.on('closed', () => { window = null }) From 72105a17c0c34645298c75e3dcc4e26fca493c40 Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sun, 22 Mar 2020 13:51:49 +0800 Subject: [PATCH 3/8] Update main.js --- src/main.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main.js b/src/main.js index 60bc69187..6077bae98 100644 --- a/src/main.js +++ b/src/main.js @@ -4,14 +4,6 @@ const i18n = require('./i18n') const setting = require('./setting') const updater = require('./updater') -const Store = require('electron-store') -const store = new Store() - -// get the previous size -let preWidth = store.get('preWidth') -let preHeight = store.get('preHeight') -let maxWindow = store.get('maxWindow') - let windows = [] let openfile = null @@ -21,8 +13,14 @@ function newWindow(path) { process.platform === 'linux' ? resolve(__dirname, '../logo.png') : null, title: app.name, useContentSize: true, - width: preWidth ? preWidth : setting.get('window.width'), - height: preHeight ? preHeight : setting.get('window.height'), + width: setting.get('window.preWidth') + ? setting.get('window.preWidth') + : setting.get('window.width'), + height: setting.get('window.preHeight') + ? setting.get('window.preHeight') + : setting.get('window.height'), + width: setting.get('window.width'), + height: setting.get('window.height'), minWidth: setting.get('window.minwidth'), minHeight: setting.get('window.minheight'), autoHideMenuBar: !setting.get('view.show_menubar'), @@ -41,22 +39,22 @@ function newWindow(path) { window.show() }) - if (maxWindow === 'true') { + if (setting.get('window.max') === true) { window.maximize() } // store the window size window.on('maximize', () => { - store.set('maxWindow', 'true') + setting.set('window.max', true) }) + window.on('unmaximize', () => { - store.set('maxWindow', 'false') + setting.set('window.max', false) }) + window.on('resize', () => { - const [nowWidth, nowHeight] = window.getSize() - store.set('preWidth', nowWidth) - store.set('preHeight', nowHeight) - //console.log(`Width: ${preWidth}, Height: ${preHeight}`); + setting.set('window.preWidth', window.getSize()[0]) + setting.set('window.preHeight', window.getSize()[1]) }) window.on('closed', () => { From fb6ddb137fbdbf149dbfcb2d879611898da28708 Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sun, 22 Mar 2020 13:52:23 +0800 Subject: [PATCH 4/8] Update package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index f23f8d57c..4e5b9ae3a 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,6 @@ "argv-split": "^2.0.1", "classnames": "^2.2.6", "dolm": "^0.7.3-beta", - "electron-store": "^5.1.1", "fix-path": "^3.0.0", "iconv-lite": "^0.5.1", "jschardet": "^2.1.1", From dbf50fc26fcb634f94f84d4f8f13f22c3f2bc0aa Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sun, 22 Mar 2020 13:53:14 +0800 Subject: [PATCH 5/8] Update setting.js --- src/setting.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/setting.js b/src/setting.js index 6c71a2770..b2f102d9c 100644 --- a/src/setting.js +++ b/src/setting.js @@ -210,7 +210,10 @@ let defaults = { 'window.height': 604, 'window.minheight': 440, 'window.minwidth': 526, - 'window.width': 564 + 'window.width': 564, + 'window.max': false, + 'window.preWidth': undefined, + 'window.preHeight': undefined } let eventEmitters = {} From 6b45a9d32c8fe0d9fed1430aae64fc4085e361ae Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sun, 22 Mar 2020 18:46:31 +0800 Subject: [PATCH 6/8] Update setting.js --- src/setting.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/setting.js b/src/setting.js index b2f102d9c..7908d9071 100644 --- a/src/setting.js +++ b/src/setting.js @@ -211,9 +211,7 @@ let defaults = { 'window.minheight': 440, 'window.minwidth': 526, 'window.width': 564, - 'window.max': false, - 'window.preWidth': undefined, - 'window.preHeight': undefined + 'window.maximized': false } let eventEmitters = {} From ec0af5eb0aaed38e0dc1205a2176699e548d4f70 Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sun, 22 Mar 2020 18:47:33 +0800 Subject: [PATCH 7/8] Update main.js --- src/main.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main.js b/src/main.js index 6077bae98..11d1c118c 100644 --- a/src/main.js +++ b/src/main.js @@ -13,12 +13,6 @@ function newWindow(path) { process.platform === 'linux' ? resolve(__dirname, '../logo.png') : null, title: app.name, useContentSize: true, - width: setting.get('window.preWidth') - ? setting.get('window.preWidth') - : setting.get('window.width'), - height: setting.get('window.preHeight') - ? setting.get('window.preHeight') - : setting.get('window.height'), width: setting.get('window.width'), height: setting.get('window.height'), minWidth: setting.get('window.minwidth'), @@ -39,22 +33,22 @@ function newWindow(path) { window.show() }) - if (setting.get('window.max') === true) { + if (setting.get('window.maximized') === true) { window.maximize() } // store the window size window.on('maximize', () => { - setting.set('window.max', true) + setting.set('window.maximized', true) }) window.on('unmaximize', () => { - setting.set('window.max', false) + setting.set('window.maximized', false) }) window.on('resize', () => { - setting.set('window.preWidth', window.getSize()[0]) - setting.set('window.preHeight', window.getSize()[1]) + setting.set('window.width', window.getSize()[0]) + setting.set('window.height', window.getSize()[1]) }) window.on('closed', () => { From ec3835dc2e5ea6fec5997e46cdb973927977df61 Mon Sep 17 00:00:00 2001 From: ivysrono Date: Sun, 22 Mar 2020 18:54:26 +0800 Subject: [PATCH 8/8] Update main.js --- src/main.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main.js b/src/main.js index 11d1c118c..84e757b2d 100644 --- a/src/main.js +++ b/src/main.js @@ -46,11 +46,6 @@ function newWindow(path) { setting.set('window.maximized', false) }) - window.on('resize', () => { - setting.set('window.width', window.getSize()[0]) - setting.set('window.height', window.getSize()[1]) - }) - window.on('closed', () => { window = null })