fix(macOS): fix traffic lights position and visibility on macOS, closes #3129 (#3130)

This commit is contained in:
Huang Xin
2026-02-01 12:38:40 +08:00
committed by GitHub
parent 570598520f
commit 1294ef90c1
2 changed files with 13 additions and 5 deletions
@@ -92,10 +92,12 @@ const HeaderBar: React.FC<HeaderBarProps> = ({
if (hoveredBookKey === bookKey && isTopLeft) {
setTrafficLightVisibility(true, { x: 10, y: 20 });
} else if (!hoveredBookKey) {
setTrafficLightVisibility(false);
setTimeout(() => {
setTrafficLightVisibility(false);
}, 200);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appService, isSideBarVisible, hoveredBookKey]);
}, [appService, isSideBarVisible, hoveredBookKey, isTrafficLightVisible]);
// Check if mouse is outside header area to avoid false positive event of MouseLeave when clicking inside header on Windows
const isMouseOutsideHeader = useCallback((clientX: number, clientY: number) => {
@@ -53,9 +53,15 @@ export const useTrafficLightStore = create<TrafficLightState>((set, get) => {
const { getCurrentWindow } = await import('@tauri-apps/api/window');
const currentWindow = getCurrentWindow();
const unlistenEnterFullScreen = await currentWindow.listen('will-enter-fullscreen', () => {
set({ isTrafficLightVisible: false, trafficLightInFullscreen: true });
});
const unlistenEnterFullScreen = await currentWindow.listen(
'will-enter-fullscreen',
async () => {
const fullscreen = await currentWindow.isFullscreen();
if (fullscreen) {
set({ isTrafficLightVisible: false, trafficLightInFullscreen: true });
}
},
);
const unlistenExitFullScreen = await currentWindow.listen('will-exit-fullscreen', () => {
const { shouldShowTrafficLight } = get();