'use client'; import { useEffect } from 'react'; import { motion, type Variants } from 'framer-motion'; import { useReducedMotion } from '@/hooks/use-reduced-motion'; const pageVariants: Variants = { initial: { opacity: 0, y: 8, }, enter: { opacity: 1, y: 0, transition: { duration: 0.28, // DEC-N3(2026-10-08):原 [0.16, 1, 0.3, 1] 是令牌层之外的写死曲线, // 归口到 CONTEXT.md:77 的统一缓动 ease-ink = [0.22, 1, 0.36, 1](globals.css --ease-ink)。 ease: [0.22, 1, 0.36, 1] as [number, number, number, number], }, }, exit: { opacity: 0, y: -4, transition: { duration: 0.2, // 同上:退场同样走 ease-ink(与 page-transition.tsx exit 的曲线一致)。 ease: [0.22, 1, 0.36, 1] as [number, number, number, number], }, }, }; export default function MarketingTemplate({ children, }: { children: React.ReactNode; }) { const shouldReduceMotion = useReducedMotion(); // 2026-10-20:水合后把首屏可见性的兜底交还给 framer(见 globals.css 的 data-content-ready 规则)。 // 800ms > 最长入场 280ms,保证交接时入场动画已结束、不会闪一下。 useEffect(() => { const id = window.setTimeout(() => { document.documentElement.setAttribute('data-content-ready', '1'); }, 800); return () => window.clearTimeout(id); }, []); // 2026-10-20:**不再早返回 `<>{children}`** —— 那会让树结构与 SSR 不同 // (服务端永远渲染 motion.div,客户端 reduce 用户渲染裸 Fragment)⇒ React #418。 // 2026-10-20(导航白屏修复的连带回归):reduce 变体不能写成 `{}`。motion.div 挂载时 // hook 仍是 false(首帧与 SSR 一致),它按 pageVariants 开始 0→1 的入场;effect 切到 // reduce 后 `animate="enter"` 若映射到空变体,framer 会停在当前帧(实测 opacity 0.2) // 而不是「一步到位」。改为显式给可见终值 + 0 时长。 const variants = shouldReduceMotion ? { initial: { opacity: 1, y: 0 }, enter: { opacity: 1, y: 0, transition: { duration: 0 } }, } : pageVariants; return ( {children} ); }