Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): splash 补盖淡出遵守 reduced-motion 且不挡点击

Dashc5c665f95319
diff --git a/apps/desktop/src/renderer/components/splash/SplashScreen.tsx b/apps/desktop/src/renderer/components/splash/SplashScreen.tsx
index 006c0d3f12..2b30a3bfb7 100644
--- a/apps/desktop/src/renderer/components/splash/SplashScreen.tsx
+++ b/apps/desktop/src/renderer/components/splash/SplashScreen.tsx
@@ -11,6 +11,7 @@ import {
import { useAppShellCover } from '@/contexts/AppShellCoverContext';
import { useEnvCheck } from '@/contexts/EnvCheckContext';
import { useLoginHandoff } from '@/contexts/LoginHandoffContext';
+import { useReducedMotion } from '@/hooks/useReducedMotion';
import { WindowControls } from '@/components/title-bar/WindowControls';
import { desktopScale } from '@/components/login/loginScale';
import { useViewportSize } from '@/components/login/LoginStage';
@@ -93,6 +94,7 @@ export function SplashScreen() {
const splash = useSplash();
const { step, totalSteps } = useEnvCheck();
const { coverHeld } = useAppShellCover();
+ const reducedMotion = useReducedMotion();
const handoff = useLoginHandoff();
const [shellCoverFading, setShellCoverFading] = useState(false);
const prevCoverHeldRef = useRef(coverHeld);
@@ -140,6 +142,12 @@ export function SplashScreen() {
useEffect(() => {
if (prevCoverHeldRef.current && !coverHeld && (realPhase === 'splash_done' || realPhase === 'splash_skipped')) {
+ // reduced-motion 把 --splash-fade-duration 置 0ms。再留 500ms 透明全屏层
+ // 会吞掉主界面刚露出时的点击(层未 pointer-events:none)。
+ if (reducedMotion) {
+ prevCoverHeldRef.current = coverHeld;
+ return;
+ }
setShellCoverFading(true);
const timer = window.setTimeout(() => setShellCoverFading(false), 500);
prevCoverHeldRef.current = coverHeld;
@@ -147,7 +155,7 @@ export function SplashScreen() {
}
if (holdAfterDone) setShellCoverFading(false);
prevCoverHeldRef.current = coverHeld;
- }, [coverHeld, holdAfterDone, realPhase]);
+ }, [coverHeld, holdAfterDone, realPhase, reducedMotion]);
const shellCoverVisible = holdAfterDone || shellCoverFading;
@@ -221,7 +229,7 @@ export function SplashScreen() {
className={cn(
'fixed inset-0 z-[9999] overflow-hidden',
(realPhase === 'fading_out' || shellCoverFading) && !fixture
- ? 'opacity-0'
+ ? 'pointer-events-none opacity-0'
: 'opacity-100',
)}
style={
diff --git a/apps/desktop/src/renderer/components/splash/__tests__/SplashScreen.test.tsx b/apps/desktop/src/renderer/components/splash/__tests__/SplashScreen.test.tsx
index c745b3b94d..1f7f8405cc 100644
--- a/apps/desktop/src/renderer/components/splash/__tests__/SplashScreen.test.tsx
+++ b/apps/desktop/src/renderer/components/splash/__tests__/SplashScreen.test.tsx
@@ -381,4 +381,31 @@ describe('SplashScreen wave4 统一面板', () => {
expect(screen.getByText('splash.tips.waking')).toBeTruthy();
expect(document.documentElement.getAttribute('data-splash-active')).toBe('1');
});
+
+ it('cover 放行后淡出层不拦截点击', () => {
+ mocks.coverHeld = true;
+ const view = renderSplash('splash_done');
+ mocks.coverHeld = false;
+ view.rerender(<SplashScreen />);
+ expect(screen.getByTestId('splash-root').className).toContain('pointer-events-none');
+ expect(screen.getByTestId('splash-root').className).toContain('opacity-0');
+ });
+
+ it('reduced-motion 下 cover 放行立即卸载,不留 500ms 透明遮罩', () => {
+ window.matchMedia = vi.fn().mockImplementation((query: string) => ({
+ matches: String(query).includes('prefers-reduced-motion'),
+ media: query,
+ addEventListener: () => {},
+ removeEventListener: () => {},
+ addListener: () => {},
+ removeListener: () => {},
+ dispatchEvent: () => false,
+ })) as unknown as typeof window.matchMedia;
+ mocks.coverHeld = true;
+ const view = renderSplash('splash_done');
+ expect(screen.getByTestId('splash-panel')).toBeTruthy();
+ mocks.coverHeld = false;
+ view.rerender(<SplashScreen />);
+ expect(view.container.firstElementChild).toBeNull();
+ });
});