fix(window): hover effect of the minimize and close button does not disappear

`5bb4539e3f2d04288bf52164fdbf47bcaf949aea` was accidentally reverted in `8316c75c7836af254257d6be338d99c5c4c5923c`, so we reapply it here.
This commit is contained in:
Slinetrac
2025-12-12 17:27:05 +08:00
parent 8316c75c78
commit f0c7aca3ff
3 changed files with 13 additions and 4 deletions

View File

@@ -26,6 +26,7 @@
- 修复 macOS 在安装和卸载服务时提示与操作不匹配
- 修复菜单排序模式拖拽异常
- 修复托盘菜单代理组前的异常勾选状态
- 修复 Windows 下自定义标题栏按钮在最小化 / 关闭后 hover 状态残留
<details>
<summary><strong> ✨ 新增功能 </strong></summary>

View File

@@ -6,8 +6,8 @@ export interface WindowContextType {
maximized: boolean | null;
toggleDecorations: () => Promise<void>;
refreshDecorated: () => Promise<boolean>;
minimize: () => void;
close: () => void;
minimize: () => Promise<void>;
close: () => Promise<void>;
toggleMaximize: () => Promise<void>;
toggleFullscreen: () => Promise<void>;
currentWindow: ReturnType<typeof getCurrentWindow>;

View File

@@ -12,8 +12,16 @@ export const WindowProvider: React.FC<{ children: React.ReactNode }> = ({
const [decorated, setDecorated] = useState<boolean | null>(null);
const [maximized, setMaximized] = useState<boolean | null>(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;