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;