diff --git a/components/dom/Header.tsx b/components/dom/Header.tsx index 03357c0..a459bb9 100644 --- a/components/dom/Header.tsx +++ b/components/dom/Header.tsx @@ -6,7 +6,12 @@ import { useShellMedia, type ThemeSetting } from "@/lib/shellMedia"; import { useBgm } from "@/lib/useBgm"; import { scrollEnv, PENDING_SCROLL_ANCHOR_SESSION_KEY } from "@/lib/scrollEnv"; import { usePathname } from "next/navigation"; -import { useRouteTransitionController } from "@/lib/routeTransition"; +import { + useRouteTransitionController, + useFullscreenTransitionController, +} from "@/lib/routeTransition"; +import { loadingBus } from "@/lib/loadingBus"; +import { useIsMobile } from "@/lib/useIsMobile"; import { useArrowFullscreenPastThreshold, ARROW_FULLSCREEN_DOM_COLOR_TRANSITION, @@ -25,6 +30,14 @@ import { * nav-hint panel (top-24): keyboard help + browser name + viewport * size. Pointer-down or any shortcut key resets it; changing * theme/sound also hides it (original P counter logic). + * - Mobile (<1024px): hamburger button top-right (two bars ↔ X, + * 1200ms ease-66 morph) toggles the fullscreen menu overlay — + * Home / Work / Contact at text-[10svw] on the dark WebGL curtain + * (menuOpen drives RouteTransitionOverlay's open prop); the bottom + * row gains THEME/SOUND toggles while open. Menu items get the + * white dotted tone when it was opened past the arrow-fullscreen + * threshold (original k.current snapshot); the menu auto-closes on + * the home loading gate and when resizing back to desktop. * - Bottom row: live clock, pointer coordinate readout (click → scroll * to top), and — replacing the original RotatingGlobe — the * VIRTHEART copyright line. @@ -33,9 +46,12 @@ import { const SPINNER = ["|", "/", "-", "\\"]; -const dotted = +const DOTTED_BASE = "relative before:content-[''] before:absolute before:inset-0 before:border-2 before:border-dotted before:border-transparent before:pointer-events-none before:transition-colors before:duration-200 lg:hover:before:border-l1"; +const DOTTED_BASE_WHITE = + "relative before:content-[''] before:absolute before:inset-0 before:border-2 before:border-dotted before:border-white before:pointer-events-none before:transition-colors before:duration-200 lg:hover:before:border-white"; + function useBrowserName(): string { const [name, setName] = useState("未知"); useEffect(() => { @@ -61,7 +77,9 @@ export default function Header({ const { theme, setTheme, soundEnabled, setSoundEnabled } = useShellMedia(); useBgm(soundEnabled); const { startNavigation } = useRouteTransitionController(); + const { menuOpen, setMenuOpen } = useFullscreenTransitionController(); const pathname = usePathname(); + const isMobile = useIsMobile(); // 首页内锚点直达;其它页面(/services、/work/...)则写入跨页锚点后 // 走路由过渡回首页,由 SmoothScroller 消费并平滑滚动到位。 @@ -80,6 +98,10 @@ export default function Header({ // (and the hyper-space section) turn white over the black stripe base // (original X = useArrowFullscreenPastThreshold()). const arrowWhite = useArrowFullscreenPastThreshold(); + // Whether the menu was opened while past the arrow-fullscreen threshold — + // snapshot at open time (original k.current), drives the white dotted tone + // of the fullscreen menu items. + const arrowWhiteAtOpenRef = useRef(false); const [time, setTime] = useState("--:--"); const [coords, setCoords] = useState({ x: "0001", y: "0001" }); @@ -144,6 +166,40 @@ export default function Header({ const sinkHint = useCallback(() => setHintCount((c) => Math.max(0, c - 1)), []); const resetHint = useCallback(() => setHintCount(0), []); + // ---- 移动端全屏菜单(原版 R/O 状态)---- + // 打开快照复位(原版 R||(k.current=!1))。 + useEffect(() => { + if (!menuOpen) arrowWhiteAtOpenRef.current = false; + }, [menuOpen]); + + // 首页加载门未就绪时关闭菜单(原版 B&&O(!1);本移植的 heavy-ready + // 等价信号是 loadingBus 首屏加载幕布,与 BackgroundGrid 相同)。 + const [heavyReady, setHeavyReady] = useState(true); + useEffect(() => { + setHeavyReady(loadingBus.getSnapshot().ready); + return loadingBus.subscribe(() => + setHeavyReady(loadingBus.getSnapshot().ready) + ); + }, []); + const homeLoadingGate = pathname === "/" && !heavyReady; + useEffect(() => { + if (homeLoadingGate) setMenuOpen(false); + }, [homeLoadingGate, setMenuOpen]); + + // 切回桌面宽度时收起菜单(原版 H||O(!1))。 + useEffect(() => { + if (!isMobile) setMenuOpen(false); + }, [isMobile, setMenuOpen]); + + const toggleMenu = useCallback(() => { + const next = !menuOpen; + if (next) { + // 打开瞬间快照箭头全屏状态(原版 k.current = readArro...Threshold()) + arrowWhiteAtOpenRef.current = arrowWhite; + } + setMenuOpen(next); + }, [menuOpen, arrowWhite, setMenuOpen]); + // Changing theme/sound hides the hint panel (original effect). const prevRef = useRef({ theme, soundEnabled }); useEffect(() => { @@ -211,15 +267,44 @@ export default function Header({ const toggleCommon = "inline-flex shrink-0 items-baseline gap-0 normal-case"; + // 品牌链接点线底色(原版 dottedTone: R ? "default" : X ? "white" : "default") + const brandDottedTone = menuOpen + ? DOTTED_BASE + : arrowWhite + ? DOTTED_BASE_WHITE + : DOTTED_BASE; + + // 桌面导航项/底部坐标点线底色(原版 $ = X ? white : default) + const dottedTone = arrowWhite ? DOTTED_BASE_WHITE : DOTTED_BASE; + + // 移动端汉堡按钮(lg:hidden,原版两条横线 ↔ X,1200ms ease-66 变形); + // 条色(原版 Y = R ? "bg-l1" : X ? "bg-white" : "bg-l1"):打开时亮色条盖在深色幕布上 + const hamburgerBarBase = `h-0.5 absolute transition-all duration-[1200ms] ease-66 ${ + menuOpen + ? "bg-l1" + : arrowWhite + ? "bg-white" + : "bg-l1" + }`; + + // 全屏菜单项的点线底色(原版 Q:按打开瞬间快照取色) + const menuItemDotted = arrowWhiteAtOpenRef.current + ? DOTTED_BASE_WHITE + : DOTTED_BASE; + + // 菜单打开时底部追加的主题/音效切换(原版 tt 类) + const menuToggleClass = `${DOTTED_BASE} p-2 text-l1 uppercase cursor-pointer pointer-events-auto ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION}`; + return ( + <>
@@ -228,21 +313,21 @@ export default function Header({
+ {/* 移动端右上角菜单按钮(原版 !B && hamburger;本移植首页加载门 + 极短,直接常驻)。两条横线 ↔ X,1200ms ease-66 变形。 */} +
+
+
+
+
+
+
+
{/* Nav hint panel — revealed by hovering THEME/SOUND (original P>0, @@ -360,7 +474,7 @@ export default function Header({ /> + {/* 菜单打开时底部追加的主题/音效切换(原版 tt 类,移动端可见) */} + {menuOpen && ( + <> + + + + )}
+ + {/* 移动端全屏菜单(原版 R && overlay):z-40 位于 WebGL 幕布(z-30) + 之上、Header(z-50)之下;首页/作品/服务/联系,text-[10svw] 大字。 */} + {menuOpen && ( +
+ setMenuOpen(false)} + > + + + + + +
+ )} + ); }