From a9b05d66a6bc756c4335edd3c6160b02d2b24a41 Mon Sep 17 00:00:00 2001 From: memorydream <34763046+memorydream@users.noreply.github.com> Date: Fri, 29 Apr 2022 19:52:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(components/Titlebar):=20`=E8=BF=98=E5=8E=9F?= =?UTF-8?q?/=E6=9C=80=E5=A4=A7=E5=8C=96`=E6=8C=89=E9=92=AE=E5=9C=A8?= =?UTF-8?q?=E5=8F=8C=E5=87=BB=E6=A0=87=E9=A2=98=E6=A0=8F=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98=20(#1575?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(components/Titlebar): `还原/最大化`按钮在双击标题栏时不会更新的问题 * update --- src/background.js | 8 ++++++++ src/components/LinuxTitlebar.vue | 10 ++++------ src/components/Win32Titlebar.vue | 10 ++++------ src/electron/ipcMain.js | 4 +--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/background.js b/src/background.js index aa33918..1d4fdba 100644 --- a/src/background.js +++ b/src/background.js @@ -332,6 +332,14 @@ class Background { this.store.set('window', this.window.getBounds()); }); + this.window.on('maximize', () => { + this.window.webContents.send('isMaximized', true); + }); + + this.window.on('unmaximize', () => { + this.window.webContents.send('isMaximized', false); + }); + this.window.webContents.on('new-window', function (e, url) { e.preventDefault(); log('open url'); diff --git a/src/components/LinuxTitlebar.vue b/src/components/LinuxTitlebar.vue index 8575c6c..8d73bd6 100644 --- a/src/components/LinuxTitlebar.vue +++ b/src/components/LinuxTitlebar.vue @@ -12,8 +12,8 @@
@@ -40,7 +40,7 @@ export default { name: 'LinuxTitlebar', data() { return { - isShowMaximized: true, + isMaximized: false, }; }, computed: { @@ -49,9 +49,7 @@ export default { created() { if (process.env.IS_ELECTRON === true) { ipcRenderer.on('isMaximized', (_, value) => { - // 当窗口最大化时,value为false - // 当窗口还原时,value为true - this.isShowMaximized = value; + this.isMaximized = value; }); } }, diff --git a/src/components/Win32Titlebar.vue b/src/components/Win32Titlebar.vue index 1a6cae3..67386b3 100644 --- a/src/components/Win32Titlebar.vue +++ b/src/components/Win32Titlebar.vue @@ -9,8 +9,8 @@
@@ -37,7 +37,7 @@ export default { name: 'Win32Titlebar', data() { return { - isShowMaximized: true, + isMaximized: false, }; }, computed: { @@ -46,9 +46,7 @@ export default { created() { if (process.env.IS_ELECTRON === true) { ipcRenderer.on('isMaximized', (_, value) => { - // 当窗口最大化时,value为false - // 当窗口还原时,value为true - this.isShowMaximized = value; + this.isMaximized = value; }); } }, diff --git a/src/electron/ipcMain.js b/src/electron/ipcMain.js index 0075301..1831576 100644 --- a/src/electron/ipcMain.js +++ b/src/electron/ipcMain.js @@ -222,9 +222,7 @@ export function initIpcMain(win, store, trayEventEmitter) { }); ipcMain.on('maximizeOrUnmaximize', () => { - const isMaximized = win.isMaximized(); - isMaximized ? win.unmaximize() : win.maximize(); - win.webContents.send('isMaximized', isMaximized); + win.isMaximized() ? win.unmaximize() : win.maximize(); }); ipcMain.on('settings', (event, options) => {