fix: style fixes to windows app control buttons (#4150)

This commit is contained in:
Peng Xiao
2023-09-04 17:01:31 +08:00
committed by GitHub
parent f245b4f5ce
commit 1066a8ca74
7 changed files with 106 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ import { isMacOS, isWindows } from '../shared/utils';
import { getExposedMeta } from './exposed';
import { ensureHelperProcess } from './helper-process';
import { logger } from './logger';
import { uiSubjects } from './ui';
import { parseCookie } from './utils';
const IS_DEV: boolean =
@@ -111,6 +112,20 @@ async function createWindow() {
const size = browserWindow.getSize();
browserWindow.setSize(size[0] + 1, size[1] + 1);
browserWindow.setSize(size[0], size[1]);
uiSubjects.onMaximized.next(false);
});
browserWindow.on('maximize', () => {
uiSubjects.onMaximized.next(true);
});
// full-screen == maximized in UI on windows
browserWindow.on('enter-full-screen', () => {
uiSubjects.onMaximized.next(true);
});
browserWindow.on('unmaximize', () => {
uiSubjects.onMaximized.next(false);
});
/**

View File

@@ -19,4 +19,10 @@ export const uiEvents = {
sub.unsubscribe();
};
},
onMaximized: (fn: (maximized: boolean) => void) => {
const sub = uiSubjects.onMaximized.subscribe(fn);
return () => {
sub.unsubscribe();
};
},
} satisfies Record<string, MainEventRegister>;

View File

@@ -26,7 +26,11 @@ export const uiHandlers = {
handleMaximizeApp: async () => {
const windows = BrowserWindow.getAllWindows();
windows.forEach(w => {
if (w.isMaximized()) {
// allow unmaximize when in full screen mode
if (w.isFullScreen()) {
w.setFullScreen(false);
w.unmaximize();
} else if (w.isMaximized()) {
w.unmaximize();
} else {
w.maximize();

View File

@@ -3,4 +3,5 @@ import { Subject } from 'rxjs';
export const uiSubjects = {
onStartLogin: new Subject<{ email?: string }>(),
onFinishLogin: new Subject<{ success: boolean; email?: string }>(),
onMaximized: new Subject<boolean>(),
};