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

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

* update
master
memorydream 3 years ago committed by GitHub
parent c85af59b21
commit a9b05d66a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -332,6 +332,14 @@ class Background {
this.store.set('window', this.window.getBounds()); 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) { this.window.webContents.on('new-window', function (e, url) {
e.preventDefault(); e.preventDefault();
log('open url'); log('open url');

@ -12,8 +12,8 @@
<div <div
class="button max-restore codicon" class="button max-restore codicon"
:class="{ :class="{
'codicon-chrome-restore': !isShowMaximized, 'codicon-chrome-restore': isMaximized,
'codicon-chrome-maximize': isShowMaximized, 'codicon-chrome-maximize': !isMaximized,
}" }"
@click="windowMaxRestore" @click="windowMaxRestore"
></div> ></div>
@ -40,7 +40,7 @@ export default {
name: 'LinuxTitlebar', name: 'LinuxTitlebar',
data() { data() {
return { return {
isShowMaximized: true, isMaximized: false,
}; };
}, },
computed: { computed: {
@ -49,9 +49,7 @@ export default {
created() { created() {
if (process.env.IS_ELECTRON === true) { if (process.env.IS_ELECTRON === true) {
ipcRenderer.on('isMaximized', (_, value) => { ipcRenderer.on('isMaximized', (_, value) => {
// valuefalse this.isMaximized = value;
// valuetrue
this.isShowMaximized = value;
}); });
} }
}, },

@ -9,8 +9,8 @@
<div <div
class="button max-restore codicon" class="button max-restore codicon"
:class="{ :class="{
'codicon-chrome-restore': !isShowMaximized, 'codicon-chrome-restore': isMaximized,
'codicon-chrome-maximize': isShowMaximized, 'codicon-chrome-maximize': !isMaximized,
}" }"
@click="windowMaxRestore" @click="windowMaxRestore"
></div> ></div>
@ -37,7 +37,7 @@ export default {
name: 'Win32Titlebar', name: 'Win32Titlebar',
data() { data() {
return { return {
isShowMaximized: true, isMaximized: false,
}; };
}, },
computed: { computed: {
@ -46,9 +46,7 @@ export default {
created() { created() {
if (process.env.IS_ELECTRON === true) { if (process.env.IS_ELECTRON === true) {
ipcRenderer.on('isMaximized', (_, value) => { ipcRenderer.on('isMaximized', (_, value) => {
// valuefalse this.isMaximized = value;
// valuetrue
this.isShowMaximized = value;
}); });
} }
}, },

@ -222,9 +222,7 @@ export function initIpcMain(win, store, trayEventEmitter) {
}); });
ipcMain.on('maximizeOrUnmaximize', () => { ipcMain.on('maximizeOrUnmaximize', () => {
const isMaximized = win.isMaximized(); win.isMaximized() ? win.unmaximize() : win.maximize();
isMaximized ? win.unmaximize() : win.maximize();
win.webContents.send('isMaximized', isMaximized);
}); });
ipcMain.on('settings', (event, options) => { ipcMain.on('settings', (event, options) => {

Loading…
Cancel
Save