cdd1c03edb
- Header 右上角 lg:hidden 汉堡按钮(双横线 ↔ X,1200ms ease-66 变形) - 全屏菜单:首页/作品/服务/联系,text-[10svw],点开由 menuOpen 驱动 RouteTransitionOverlay 暗色幕布(z-30)垫底,菜单层 z-40 - 菜单打开时底部追加 主题/音效 切换(原版 tt 类) - 箭头全屏过阈值时打开菜单 → 菜单项取白色点线基调(原版 k.current 快照) - 菜单自动收起:首页加载门 / 切回桌面宽度(原版 B&&O(!1) / H||O(!1)) - 顺带修正品牌/桌面导航点线基调随箭头全屏变白(原版 $ 与 dottedTone)
577 lines
22 KiB
TypeScript
577 lines
22 KiB
TypeScript
"use client";
|
||
|
||
import { useCallback, useEffect, useRef, useState } from "react";
|
||
import ScrambleReveal from "@/components/dom/ScrambleReveal";
|
||
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,
|
||
useFullscreenTransitionController,
|
||
} from "@/lib/routeTransition";
|
||
import { loadingBus } from "@/lib/loadingBus";
|
||
import { useIsMobile } from "@/lib/useIsMobile";
|
||
import {
|
||
useArrowFullscreenPastThreshold,
|
||
ARROW_FULLSCREEN_DOM_COLOR_TRANSITION,
|
||
} from "@/lib/arrowFullscreen";
|
||
|
||
/**
|
||
* Header — ported from the original (chunk 2689132c4e070b68.js):
|
||
*
|
||
* - THEME[L]/THEME[D]/THEME[A]: click cycles light→dark→system; global
|
||
* keyboard [L]/[D]/[A] (original ASCIIThemeToggle; theme rendering is
|
||
* light-only in this port, the setting is stored).
|
||
* - SOUND[|/-\] / SOUND[·]: background music (/bgm.mp3, loop, 0.35);
|
||
* spinner chars cycle at 130ms while playing; keyboard [S]
|
||
* (original ASCIISoundToggle); choice persisted.
|
||
* - Hovering THEME/SOUND increments a counter that reveals the fixed
|
||
* 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.
|
||
* - Keyboard [T] scroll to top, [B] scroll to bottom.
|
||
*/
|
||
|
||
const SPINNER = ["|", "/", "-", "\\"];
|
||
|
||
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(() => {
|
||
const ua = navigator.userAgent;
|
||
let result = "未知";
|
||
if (/Edg\//.test(ua)) result = "Edge";
|
||
else if (/OPR\//.test(ua)) result = "Opera";
|
||
else if (/Firefox\//.test(ua)) result = "Firefox";
|
||
else if (/Chrome\//.test(ua)) result = "Chrome";
|
||
else if (/Safari\//.test(ua)) result = "Safari";
|
||
setName(result);
|
||
}, []);
|
||
return name;
|
||
}
|
||
|
||
export default function Header({
|
||
brandName = "北极新一",
|
||
copyrightName = "北极新一",
|
||
}: {
|
||
brandName?: string;
|
||
copyrightName?: string;
|
||
}) {
|
||
const { theme, setTheme, soundEnabled, setSoundEnabled } = useShellMedia();
|
||
useBgm(soundEnabled);
|
||
const { startNavigation } = useRouteTransitionController();
|
||
const { menuOpen, setMenuOpen } = useFullscreenTransitionController();
|
||
const pathname = usePathname();
|
||
const isMobile = useIsMobile();
|
||
|
||
// 首页内锚点直达;其它页面(/services、/work/...)则写入跨页锚点后
|
||
// 走路由过渡回首页,由 SmoothScroller 消费并平滑滚动到位。
|
||
const goToSection = useCallback(
|
||
(anchor: string) => {
|
||
if (pathname === "/") {
|
||
scrollEnv.scrollToSection(anchor);
|
||
} else {
|
||
sessionStorage.setItem(PENDING_SCROLL_ANCHOR_SESSION_KEY, anchor);
|
||
startNavigation("/");
|
||
}
|
||
},
|
||
[pathname, startNavigation]
|
||
);
|
||
// Arrow-fullscreen state: past the 0.5 reveal threshold the whole 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" });
|
||
const [hintCount, setHintCount] = useState(0);
|
||
const [spinnerIndex, setSpinnerIndex] = useState(0);
|
||
const [toggleEpoch, setToggleEpoch] = useState(0);
|
||
const interactedRef = useRef(false);
|
||
const browserName = useBrowserName();
|
||
const [viewport, setViewport] = useState({ w: 0, h: 0 });
|
||
const year = new Date().getFullYear();
|
||
|
||
// Clock tick (original: minute interval).
|
||
useEffect(() => {
|
||
const tick = () => {
|
||
const d = new Date();
|
||
setTime(
|
||
`${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`
|
||
);
|
||
};
|
||
tick();
|
||
const interval = window.setInterval(tick, 60_000);
|
||
return () => window.clearInterval(interval);
|
||
}, []);
|
||
|
||
// Pointer coordinates (original usePointerPosition × viewport, y-up).
|
||
useEffect(() => {
|
||
const onMove = (e: PointerEvent) => {
|
||
const x = Math.round(e.clientX);
|
||
const y = Math.round(window.innerHeight - e.clientY);
|
||
setCoords({
|
||
x: String(Math.max(0, Math.min(9999, x))).padStart(4, "0"),
|
||
y: String(Math.max(0, Math.min(9999, y))).padStart(4, "0"),
|
||
});
|
||
};
|
||
window.addEventListener("pointermove", onMove, { passive: true });
|
||
return () => window.removeEventListener("pointermove", onMove);
|
||
}, []);
|
||
|
||
// Viewport size for the hint panel (original useWindowSize).
|
||
useEffect(() => {
|
||
const update = () =>
|
||
setViewport({ w: window.innerWidth, h: window.innerHeight });
|
||
update();
|
||
window.addEventListener("resize", update, { passive: true });
|
||
return () => window.removeEventListener("resize", update);
|
||
}, []);
|
||
|
||
// Spinner while sound is playing (original 130ms interval).
|
||
useEffect(() => {
|
||
if (!soundEnabled) {
|
||
setSpinnerIndex(0);
|
||
return;
|
||
}
|
||
const interval = window.setInterval(
|
||
() => setSpinnerIndex((i) => (i + 1) % SPINNER.length),
|
||
130
|
||
);
|
||
return () => window.clearInterval(interval);
|
||
}, [soundEnabled]);
|
||
|
||
const bumpHint = useCallback(() => setHintCount((c) => c + 1), []);
|
||
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(() => {
|
||
const prev = prevRef.current;
|
||
if (prev.theme !== theme || prev.soundEnabled !== soundEnabled) {
|
||
prevRef.current = { theme, soundEnabled };
|
||
setHintCount((c) => (c > 0 ? 0 : c));
|
||
}
|
||
}, [theme, soundEnabled]);
|
||
|
||
const cycleTheme = useCallback(() => {
|
||
interactedRef.current = true;
|
||
setToggleEpoch((e) => e + 1);
|
||
const order: ThemeSetting[] = ["light", "dark", "system"];
|
||
const next = order[(order.indexOf(theme) + 1) % order.length];
|
||
setTheme(next);
|
||
}, [theme, setTheme]);
|
||
|
||
const toggleSound = useCallback(() => {
|
||
interactedRef.current = true;
|
||
setToggleEpoch((e) => e + 1);
|
||
setSoundEnabled(!soundEnabled);
|
||
}, [soundEnabled, setSoundEnabled]);
|
||
|
||
// Global keyboard shortcuts: [L]/[D]/[A] theme, [S] sound, [T]/[B] edges.
|
||
useEffect(() => {
|
||
const onKey = (e: KeyboardEvent) => {
|
||
if (
|
||
e.defaultPrevented ||
|
||
e.metaKey ||
|
||
e.ctrlKey ||
|
||
e.altKey ||
|
||
(e.target instanceof HTMLElement &&
|
||
["INPUT", "TEXTAREA", "SELECT"].includes(e.target.tagName))
|
||
) {
|
||
return;
|
||
}
|
||
const key = e.key.length === 1 ? e.key.toLowerCase() : "";
|
||
if (!key) return;
|
||
if (["l", "d", "a", "s"].includes(key)) resetHint();
|
||
if (key === "l") {
|
||
setTheme("light");
|
||
} else if (key === "d") {
|
||
setTheme("dark");
|
||
} else if (key === "a") {
|
||
setTheme("system");
|
||
} else if (key === "s") {
|
||
toggleSound();
|
||
} else if (key === "t") {
|
||
scrollEnv.scrollToTop("smooth");
|
||
} else if (key === "b") {
|
||
scrollEnv.scrollToBottom("smooth");
|
||
}
|
||
};
|
||
window.addEventListener("keydown", onKey);
|
||
return () => window.removeEventListener("keydown", onKey);
|
||
}, [resetHint, setTheme, toggleSound]);
|
||
|
||
const themeLabel =
|
||
theme === "light" ? "主题[L]" : theme === "dark" ? "主题[D]" : "主题[A]";
|
||
const soundLabel = soundEnabled
|
||
? `音效[${SPINNER[spinnerIndex]}]`
|
||
: "音效[·]";
|
||
|
||
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 (
|
||
<>
|
||
<header
|
||
className={`z-50 fixed inset-0 flex flex-col justify-between font-mono-2 pointer-events-none ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
||
menuOpen ? "text-l1" : arrowWhite ? "text-white" : "text-l1"
|
||
}`}
|
||
>
|
||
<div className="flex justify-between items-center px-4 lg:px-14 py-4 lg:py-7 text-base">
|
||
<a
|
||
className={`${brandDottedTone} p-2 font-sans font-bold uppercase pointer-events-auto transition-colors duration-300 ease-out`}
|
||
style={{ fontVariationSettings: '"wght" 700, "wdth" 120' }}
|
||
href="/"
|
||
>
|
||
<ScrambleReveal text={brandName} startDelayMs={300} scrambleColors={false} />
|
||
</a>
|
||
<div className="hidden lg:flex flex-wrap justify-between items-center gap-x-3 gap-y-2 pointer-events-auto basis-1/2 xl:basis-1/3">
|
||
<button
|
||
type="button"
|
||
className={`${dottedTone} p-2 uppercase cursor-pointer`}
|
||
onClick={() => goToSection("#selected-work")}
|
||
>
|
||
<ScrambleReveal text="作品" startDelayMs={300} scrambleColors={false} />
|
||
</button>
|
||
<button
|
||
type="button"
|
||
className={`${dottedTone} p-2 uppercase cursor-pointer`}
|
||
onClick={() => pathname !== "/services" && startNavigation("/services")}
|
||
>
|
||
<ScrambleReveal text="服务" startDelayMs={300} scrambleColors={false} />
|
||
</button>
|
||
<button
|
||
type="button"
|
||
className={`${dottedTone} p-2 uppercase cursor-pointer`}
|
||
onClick={() => goToSection("#contact")}
|
||
>
|
||
<ScrambleReveal text="联系" startDelayMs={300} scrambleColors={false} />
|
||
</button>
|
||
<span
|
||
role="button"
|
||
tabIndex={0}
|
||
aria-label={`主题:${theme === "light" ? "浅色" : theme === "dark" ? "深色" : "跟随系统"}`}
|
||
className={`${dottedTone} ${toggleCommon} p-2 uppercase cursor-pointer pointer-events-auto`}
|
||
onClick={(e) => {
|
||
e.preventDefault();
|
||
cycleTheme();
|
||
}}
|
||
onKeyDown={(e) => {
|
||
if (e.key === "Enter" || e.key === " ") {
|
||
e.preventDefault();
|
||
cycleTheme();
|
||
}
|
||
}}
|
||
onPointerEnter={bumpHint}
|
||
onPointerLeave={sinkHint}
|
||
onPointerDown={resetHint}
|
||
>
|
||
<ScrambleReveal
|
||
key={`theme-${theme}-${toggleEpoch}`}
|
||
text={themeLabel}
|
||
startDelayMs={interactedRef.current ? 100 : 300}
|
||
scrambleColors={false}
|
||
/>
|
||
</span>
|
||
<span
|
||
role="button"
|
||
tabIndex={0}
|
||
aria-label={
|
||
soundEnabled ? "音效播放中,点击暂停" : "音效已暂停,点击播放"
|
||
}
|
||
aria-pressed={soundEnabled}
|
||
className={`${dottedTone} ${toggleCommon} p-2 uppercase cursor-pointer pointer-events-auto`}
|
||
onClick={(e) => {
|
||
e.preventDefault();
|
||
toggleSound();
|
||
}}
|
||
onKeyDown={(e) => {
|
||
if (e.key === "Enter" || e.key === " ") {
|
||
e.preventDefault();
|
||
toggleSound();
|
||
}
|
||
}}
|
||
onPointerEnter={bumpHint}
|
||
onPointerLeave={sinkHint}
|
||
onPointerDown={resetHint}
|
||
>
|
||
<ScrambleReveal
|
||
key={`sound-${soundEnabled}-${toggleEpoch}`}
|
||
text={soundLabel}
|
||
startDelayMs={soundEnabled ? 100 : 300}
|
||
letterDelayMs={80}
|
||
scrambleColors={false}
|
||
/>
|
||
</span>
|
||
</div>
|
||
{/* 移动端右上角菜单按钮(原版 !B && hamburger;本移植首页加载门
|
||
极短,直接常驻)。两条横线 ↔ X,1200ms ease-66 变形。 */}
|
||
<div
|
||
className="lg:hidden flex flex-row justify-end items-center gap-4 col-span-6 p-2 cursor-pointer pointer-events-auto"
|
||
onClick={toggleMenu}
|
||
>
|
||
<div className="relative w-6 h-6">
|
||
<div
|
||
className={`${
|
||
menuOpen ? "w-0 delay-150 opacity-0" : "w-6"
|
||
} top-1.5 ${hamburgerBarBase}`}
|
||
/>
|
||
<div
|
||
className={`${
|
||
menuOpen ? "w-0 opacity-0" : "w-6 delay-150"
|
||
} bottom-1.5 ${hamburgerBarBase}`}
|
||
/>
|
||
<div
|
||
className={`${
|
||
menuOpen ? "w-6 delay-150" : "w-0 opacity-0"
|
||
} right-0 rotate-45 top-2.75 ${hamburgerBarBase}`}
|
||
/>
|
||
<div
|
||
className={`${
|
||
menuOpen ? "w-6" : "w-0 opacity-0 delay-150"
|
||
} right-0 -rotate-45 bottom-2.75 ${hamburgerBarBase}`}
|
||
/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* Nav hint panel — revealed by hovering THEME/SOUND (original P>0,
|
||
fade .4s cubic-bezier(.25,1,.5,1) via AnimatePresence). */}
|
||
{hintCount > 0 && (
|
||
<div
|
||
className="hidden top-24 right-0 left-0 z-50 fixed lg:flex flex-row-reverse px-4 lg:px-14 w-full pointer-events-none"
|
||
style={{
|
||
animation: "vh-fade-in 0.4s cubic-bezier(0.25, 1, 0.5, 1) both",
|
||
}}
|
||
>
|
||
<div
|
||
className={`flex flex-col bg-be p-2 font-mono-2 xl:basis-1/3 basis-1/2 ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
||
arrowWhite ? "text-white" : "text-l1"
|
||
}`}
|
||
>
|
||
{/* Original hint-panel texts omit scrambleColors → the scramble
|
||
component's default (true) applies: chars flash the lime
|
||
phase colors #c0fe04 → #607F02 while revealing, and the
|
||
per-char 10ms stagger over the wrapped lines produces the
|
||
top-to-bottom green sweep. */}
|
||
<ScrambleReveal
|
||
text="按 [L] 切换浅色模式,[D] 切换深色模式,[A] 跟随系统,也可以点击「主题」。按 [S] 暂停或恢复背景音乐,也可以点击「音效」,你的选择会保存在当前浏览器。[T] 回到顶部,[B] 滚动到底部。"
|
||
startDelayMs={0}
|
||
letterDelayMs={10}
|
||
/>
|
||
<br />
|
||
<span className="flex flex-row justify-between">
|
||
<ScrambleReveal
|
||
text={browserName}
|
||
startDelayMs={200}
|
||
letterDelayMs={10}
|
||
/>
|
||
<ScrambleReveal
|
||
text={`${viewport.w} \u00D7 ${viewport.h}`}
|
||
startDelayMs={200}
|
||
letterDelayMs={10}
|
||
/>
|
||
</span>
|
||
</div>
|
||
</div>
|
||
)}
|
||
|
||
<div className="flex justify-between px-4 lg:px-14 py-4 lg:py-7">
|
||
<span className="lg:hidden p-2 uppercase">
|
||
<ScrambleReveal text={time} startDelayMs={300} letterDelayMs={40} scrambleColors={false} />
|
||
</span>
|
||
<span className="hidden lg:inline p-2 uppercase">
|
||
<ScrambleReveal
|
||
text={`GMT+8 CN ${time}`}
|
||
startDelayMs={300}
|
||
letterDelayMs={40}
|
||
scrambleColors={false}
|
||
/>
|
||
</span>
|
||
<span
|
||
className={`${dottedTone} hidden lg:inline lg:bottom-7 lg:left-1/2 lg:fixed p-2 lg:-translate-x-1/2 cursor-pointer pointer-events-auto`}
|
||
onClick={() => scrollEnv.scrollToTop("smooth")}
|
||
>
|
||
<ScrambleReveal
|
||
text={`${coords.x} X ${coords.y} Y`}
|
||
startDelayMs={300}
|
||
letterDelayMs={40}
|
||
scrambleColors={false}
|
||
/>
|
||
</span>
|
||
{/* 版权行 — 替代原站的 RotatingGlobe。 */}
|
||
<span className="hidden lg:inline p-2">
|
||
<ScrambleReveal
|
||
text={`${copyrightName} (c) ${year}`}
|
||
startDelayMs={300}
|
||
letterDelayMs={40}
|
||
scrambleColors={false}
|
||
/>
|
||
</span>
|
||
{/* 菜单打开时底部追加的主题/音效切换(原版 tt 类,移动端可见) */}
|
||
{menuOpen && (
|
||
<>
|
||
<button
|
||
type="button"
|
||
aria-label={`主题:${theme === "light" ? "浅色" : theme === "dark" ? "深色" : "跟随系统"}`}
|
||
className={`${menuToggleClass} ${toggleCommon}`}
|
||
onClick={() => cycleTheme()}
|
||
>
|
||
<ScrambleReveal
|
||
key={`menu-theme-${theme}-${toggleEpoch}`}
|
||
text={themeLabel}
|
||
startDelayMs={300}
|
||
scrambleColors={false}
|
||
/>
|
||
</button>
|
||
<button
|
||
type="button"
|
||
aria-label={soundEnabled ? "音效播放中,点击暂停" : "音效已暂停,点击播放"}
|
||
aria-pressed={soundEnabled}
|
||
className={`${menuToggleClass} ${toggleCommon}`}
|
||
onClick={() => toggleSound()}
|
||
>
|
||
<ScrambleReveal
|
||
key={`menu-sound-${soundEnabled}-${toggleEpoch}`}
|
||
text={soundLabel}
|
||
startDelayMs={300}
|
||
scrambleColors={false}
|
||
/>
|
||
</button>
|
||
</>
|
||
)}
|
||
</div>
|
||
</header>
|
||
|
||
{/* 移动端全屏菜单(原版 R && overlay):z-40 位于 WebGL 幕布(z-30)
|
||
之上、Header(z-50)之下;首页/作品/服务/联系,text-[10svw] 大字。 */}
|
||
{menuOpen && (
|
||
<div className="lg:hidden z-40 fixed inset-0 flex flex-col justify-center items-start px-6 lg:px-16 py-6 lg:py-8 font-mono-2 text-[10svw] text-l1">
|
||
<a
|
||
href="/"
|
||
className={`${menuItemDotted} uppercase`}
|
||
onClick={() => setMenuOpen(false)}
|
||
>
|
||
<ScrambleReveal text="首页" startDelayMs={300} />
|
||
</a>
|
||
<button
|
||
type="button"
|
||
className={`${menuItemDotted} uppercase text-left cursor-pointer`}
|
||
onClick={() => {
|
||
setMenuOpen(false);
|
||
goToSection("#selected-work");
|
||
}}
|
||
>
|
||
<ScrambleReveal text="作品" startDelayMs={400} />
|
||
</button>
|
||
<button
|
||
type="button"
|
||
className={`${menuItemDotted} uppercase text-left cursor-pointer`}
|
||
onClick={() => {
|
||
setMenuOpen(false);
|
||
if (pathname !== "/services") startNavigation("/services");
|
||
}}
|
||
>
|
||
<ScrambleReveal text="服务" startDelayMs={450} />
|
||
</button>
|
||
<button
|
||
type="button"
|
||
className={`${menuItemDotted} uppercase text-left cursor-pointer`}
|
||
onClick={() => {
|
||
setMenuOpen(false);
|
||
goToSection("#contact");
|
||
}}
|
||
>
|
||
<ScrambleReveal text="联系" startDelayMs={500} />
|
||
</button>
|
||
</div>
|
||
)}
|
||
</>
|
||
);
|
||
}
|