mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix: style fixes to windows app control buttons (#4150)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user