mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-18 08:21:34 +08:00
fix(window-provider): maximize avoiding loop detection
This commit is contained in:
parent
ffc2419afd
commit
0e89afb01f
@ -25,13 +25,21 @@ export const WindowProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let isUnmounted = false;
|
let isUnmounted = false;
|
||||||
|
let lastWidth = -1;
|
||||||
|
let lastHeight = -1;
|
||||||
|
|
||||||
const checkMaximized = debounce(async () => {
|
const checkMaximized = debounce(
|
||||||
if (!isUnmounted) {
|
async (event: { payload: { width: number; height: number } }) => {
|
||||||
|
if (isUnmounted) return;
|
||||||
|
const { width, height } = event.payload;
|
||||||
|
if (width === lastWidth && height === lastHeight) return;
|
||||||
|
lastWidth = width;
|
||||||
|
lastHeight = height;
|
||||||
const value = await currentWindow.isMaximized();
|
const value = await currentWindow.isMaximized();
|
||||||
setMaximized(value);
|
setMaximized(value);
|
||||||
}
|
},
|
||||||
}, 300);
|
300,
|
||||||
|
);
|
||||||
|
|
||||||
const unlistenPromise = currentWindow.onResized(checkMaximized);
|
const unlistenPromise = currentWindow.onResized(checkMaximized);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user