diff --git a/apps/readest-app/src/app/reader/components/HeaderBar.tsx b/apps/readest-app/src/app/reader/components/HeaderBar.tsx index a37f8981..ebab603c 100644 --- a/apps/readest-app/src/app/reader/components/HeaderBar.tsx +++ b/apps/readest-app/src/app/reader/components/HeaderBar.tsx @@ -92,10 +92,12 @@ const HeaderBar: React.FC = ({ 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) => { diff --git a/apps/readest-app/src/store/trafficLightStore.ts b/apps/readest-app/src/store/trafficLightStore.ts index 8f10618a..7987df7a 100644 --- a/apps/readest-app/src/store/trafficLightStore.ts +++ b/apps/readest-app/src/store/trafficLightStore.ts @@ -53,9 +53,15 @@ export const useTrafficLightStore = create((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();