From f0c7aca3ff4ae665423bf4e9c718333dd4522a5d Mon Sep 17 00:00:00 2001 From: Slinetrac Date: Fri, 12 Dec 2025 17:27:05 +0800 Subject: [PATCH] fix(window): hover effect of the minimize and close button does not disappear `5bb4539e3f2d04288bf52164fdbf47bcaf949aea` was accidentally reverted in `8316c75c7836af254257d6be338d99c5c4c5923c`, so we reapply it here. --- Changelog.md | 1 + src/providers/window/WindowContext.ts | 4 ++-- src/providers/window/WindowProvider.tsx | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index b6f32fdfa..63697db7b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -26,6 +26,7 @@ - 修复 macOS 在安装和卸载服务时提示与操作不匹配 - 修复菜单排序模式拖拽异常 - 修复托盘菜单代理组前的异常勾选状态 +- 修复 Windows 下自定义标题栏按钮在最小化 / 关闭后 hover 状态残留
✨ 新增功能 diff --git a/src/providers/window/WindowContext.ts b/src/providers/window/WindowContext.ts index e5f7380e6..1cc0c3ba1 100644 --- a/src/providers/window/WindowContext.ts +++ b/src/providers/window/WindowContext.ts @@ -6,8 +6,8 @@ export interface WindowContextType { maximized: boolean | null; toggleDecorations: () => Promise; refreshDecorated: () => Promise; - minimize: () => void; - close: () => void; + minimize: () => Promise; + close: () => Promise; toggleMaximize: () => Promise; toggleFullscreen: () => Promise; currentWindow: ReturnType; diff --git a/src/providers/window/WindowProvider.tsx b/src/providers/window/WindowProvider.tsx index b43d22daf..7fb0893ff 100644 --- a/src/providers/window/WindowProvider.tsx +++ b/src/providers/window/WindowProvider.tsx @@ -12,8 +12,16 @@ export const WindowProvider: React.FC<{ children: React.ReactNode }> = ({ const [decorated, setDecorated] = useState(null); const [maximized, setMaximized] = useState(null); - const close = useCallback(() => currentWindow.close(), [currentWindow]); - const minimize = useCallback(() => currentWindow.minimize(), [currentWindow]); + const close = useCallback(async () => { + // Delay one frame so the UI can clear :hover before the window hides. + await new Promise((resolve) => setTimeout(resolve, 20)); + await currentWindow.close(); + }, [currentWindow]); + const minimize = useCallback(async () => { + // Delay one frame so the UI can clear :hover before the window hides. + await new Promise((resolve) => setTimeout(resolve, 10)); + await currentWindow.minimize(); + }, [currentWindow]); useEffect(() => { let isUnmounted = false;