fix(components/Titlebar): 还原/最大化按钮在双击标题栏时不会更新的问题 (#1575)

* fix(components/Titlebar): `还原/最大化`按钮在双击标题栏时不会更新的问题

* update
This commit is contained in:
memorydream
2022-04-29 19:52:22 +08:00
committed by GitHub
parent c85af59b21
commit a9b05d66a6
4 changed files with 17 additions and 15 deletions

View File

@@ -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');

View File

@@ -12,8 +12,8 @@
<div
class="button max-restore codicon"
:class="{
'codicon-chrome-restore': !isShowMaximized,
'codicon-chrome-maximize': isShowMaximized,
'codicon-chrome-restore': isMaximized,
'codicon-chrome-maximize': !isMaximized,
}"
@click="windowMaxRestore"
></div>
@@ -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;
});
}
},

View File

@@ -9,8 +9,8 @@
<div
class="button max-restore codicon"
:class="{
'codicon-chrome-restore': !isShowMaximized,
'codicon-chrome-maximize': isShowMaximized,
'codicon-chrome-restore': isMaximized,
'codicon-chrome-maximize': !isMaximized,
}"
@click="windowMaxRestore"
></div>
@@ -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;
});
}
},

View File

@@ -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) => {