Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cc36cb9f7 | |||
| 27ed0fbf79 | |||
| 15b138cdd7 | |||
| cdd1c03edb |
@@ -213,11 +213,14 @@ void main() {
|
|||||||
float tintK_hard = clamp(uTintEnabled, 0.0, 1.0) * clamp(uTintMix, 0.0, 1.0) * tintAlpha;
|
float tintK_hard = clamp(uTintEnabled, 0.0, 1.0) * clamp(uTintMix, 0.0, 1.0) * tintAlpha;
|
||||||
vec3 baseClamped = clamp(color, 0.0, 1.0);
|
vec3 baseClamped = clamp(color, 0.0, 1.0);
|
||||||
vec3 blendClamped = clamp(tintColorGradient.rgb, 0.0, 1.0);
|
vec3 blendClamped = clamp(tintColorGradient.rgb, 0.0, 1.0);
|
||||||
// Hard Light blend: 2*blend*base where base < 0.5, screen elsewhere
|
// Hard Light blend(原版逐通道):blend 通道 > 0.5 → screen,否则 multiply。
|
||||||
|
// 注意选择器是 blend(tint 色)而非 base —— 暗色主题的 #64c3ff/#8e9dc4
|
||||||
|
// 各通道跨 0.5,选错变量会导致 Dark 下模型颜色整体偏差。
|
||||||
|
vec3 h = step(vec3(0.5), blendClamped);
|
||||||
vec3 hard = mix(
|
vec3 hard = mix(
|
||||||
2.0 * blendClamped * baseClamped,
|
2.0 * baseClamped * blendClamped,
|
||||||
1.0 - 2.0 * (1.0 - blendClamped) * (1.0 - baseClamped),
|
1.0 - 2.0 * (1.0 - blendClamped) * (1.0 - baseClamped),
|
||||||
step(0.5, baseClamped)
|
h
|
||||||
);
|
);
|
||||||
vec3 hardColor = mix(color, hard, tintK_hard);
|
vec3 hardColor = mix(color, hard, tintK_hard);
|
||||||
|
|
||||||
|
|||||||
@@ -423,7 +423,11 @@ export function LoadingCurtain({
|
|||||||
// dedicated fullscreen fixed wrapper gives the container a real viewport
|
// dedicated fullscreen fixed wrapper gives the container a real viewport
|
||||||
// box; pointer-events:none inherits to the whole subtree.
|
// box; pointer-events:none inherits to the whole subtree.
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 z-[60] pointer-events-none">
|
// 原版这块幕布 Canvas 是 "z-30 fixed inset-0 pointer-events-none":
|
||||||
|
// 盖住页面内容(≤z-20),但必须低于移动端全屏菜单(z-40)、
|
||||||
|
// 进度条(z-40)与 Header(z-50)——曾写成 z-[60] 会把菜单整个
|
||||||
|
// 压在幕布下面,移动端打开菜单只剩一片背景色。
|
||||||
|
<div className="fixed inset-0 z-30 pointer-events-none">
|
||||||
<Canvas
|
<Canvas
|
||||||
dpr={[1, 2]}
|
dpr={[1, 2]}
|
||||||
frameloop="demand"
|
frameloop="demand"
|
||||||
|
|||||||
+201
-10
@@ -6,7 +6,12 @@ import { useShellMedia, type ThemeSetting } from "@/lib/shellMedia";
|
|||||||
import { useBgm } from "@/lib/useBgm";
|
import { useBgm } from "@/lib/useBgm";
|
||||||
import { scrollEnv, PENDING_SCROLL_ANCHOR_SESSION_KEY } from "@/lib/scrollEnv";
|
import { scrollEnv, PENDING_SCROLL_ANCHOR_SESSION_KEY } from "@/lib/scrollEnv";
|
||||||
import { usePathname } from "next/navigation";
|
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 {
|
import {
|
||||||
useArrowFullscreenPastThreshold,
|
useArrowFullscreenPastThreshold,
|
||||||
ARROW_FULLSCREEN_DOM_COLOR_TRANSITION,
|
ARROW_FULLSCREEN_DOM_COLOR_TRANSITION,
|
||||||
@@ -25,6 +30,14 @@ import {
|
|||||||
* nav-hint panel (top-24): keyboard help + browser name + viewport
|
* nav-hint panel (top-24): keyboard help + browser name + viewport
|
||||||
* size. Pointer-down or any shortcut key resets it; changing
|
* size. Pointer-down or any shortcut key resets it; changing
|
||||||
* theme/sound also hides it (original P counter logic).
|
* 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
|
* - Bottom row: live clock, pointer coordinate readout (click → scroll
|
||||||
* to top), and — replacing the original RotatingGlobe — the
|
* to top), and — replacing the original RotatingGlobe — the
|
||||||
* VIRTHEART copyright line.
|
* VIRTHEART copyright line.
|
||||||
@@ -33,9 +46,12 @@ import {
|
|||||||
|
|
||||||
const SPINNER = ["|", "/", "-", "\\"];
|
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";
|
"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 {
|
function useBrowserName(): string {
|
||||||
const [name, setName] = useState("未知");
|
const [name, setName] = useState("未知");
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -61,7 +77,9 @@ export default function Header({
|
|||||||
const { theme, setTheme, soundEnabled, setSoundEnabled } = useShellMedia();
|
const { theme, setTheme, soundEnabled, setSoundEnabled } = useShellMedia();
|
||||||
useBgm(soundEnabled);
|
useBgm(soundEnabled);
|
||||||
const { startNavigation } = useRouteTransitionController();
|
const { startNavigation } = useRouteTransitionController();
|
||||||
|
const { menuOpen, setMenuOpen } = useFullscreenTransitionController();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
// 首页内锚点直达;其它页面(/services、/work/...)则写入跨页锚点后
|
// 首页内锚点直达;其它页面(/services、/work/...)则写入跨页锚点后
|
||||||
// 走路由过渡回首页,由 SmoothScroller 消费并平滑滚动到位。
|
// 走路由过渡回首页,由 SmoothScroller 消费并平滑滚动到位。
|
||||||
@@ -80,6 +98,10 @@ export default function Header({
|
|||||||
// (and the hyper-space section) turn white over the black stripe base
|
// (and the hyper-space section) turn white over the black stripe base
|
||||||
// (original X = useArrowFullscreenPastThreshold()).
|
// (original X = useArrowFullscreenPastThreshold()).
|
||||||
const arrowWhite = 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 [time, setTime] = useState("--:--");
|
||||||
const [coords, setCoords] = useState({ x: "0001", y: "0001" });
|
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 sinkHint = useCallback(() => setHintCount((c) => Math.max(0, c - 1)), []);
|
||||||
const resetHint = useCallback(() => setHintCount(0), []);
|
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).
|
// Changing theme/sound hides the hint panel (original effect).
|
||||||
const prevRef = useRef({ theme, soundEnabled });
|
const prevRef = useRef({ theme, soundEnabled });
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -211,15 +267,44 @@ export default function Header({
|
|||||||
const toggleCommon =
|
const toggleCommon =
|
||||||
"inline-flex shrink-0 items-baseline gap-0 normal-case";
|
"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 (
|
return (
|
||||||
|
<>
|
||||||
<header
|
<header
|
||||||
className={`z-50 fixed inset-0 flex flex-col justify-between font-mono-2 pointer-events-none ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
className={`z-50 fixed inset-0 flex flex-col justify-between font-mono-2 pointer-events-none ${ARROW_FULLSCREEN_DOM_COLOR_TRANSITION} ${
|
||||||
arrowWhite ? "text-white" : "text-l1"
|
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">
|
<div className="flex justify-between items-center px-4 lg:px-14 py-4 lg:py-7 text-base">
|
||||||
<a
|
<a
|
||||||
className={`${dotted} p-2 font-sans font-bold uppercase pointer-events-auto transition-colors duration-300 ease-out`}
|
className={`${brandDottedTone} p-2 font-sans font-bold uppercase pointer-events-auto transition-colors duration-300 ease-out`}
|
||||||
style={{ fontVariationSettings: '"wght" 700, "wdth" 120' }}
|
style={{ fontVariationSettings: '"wght" 700, "wdth" 120' }}
|
||||||
href="/"
|
href="/"
|
||||||
>
|
>
|
||||||
@@ -228,21 +313,21 @@ export default function Header({
|
|||||||
<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">
|
<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
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`${dotted} p-2 uppercase cursor-pointer`}
|
className={`${dottedTone} p-2 uppercase cursor-pointer`}
|
||||||
onClick={() => goToSection("#selected-work")}
|
onClick={() => goToSection("#selected-work")}
|
||||||
>
|
>
|
||||||
<ScrambleReveal text="作品" startDelayMs={300} scrambleColors={false} />
|
<ScrambleReveal text="作品" startDelayMs={300} scrambleColors={false} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`${dotted} p-2 uppercase cursor-pointer`}
|
className={`${dottedTone} p-2 uppercase cursor-pointer`}
|
||||||
onClick={() => pathname !== "/services" && startNavigation("/services")}
|
onClick={() => pathname !== "/services" && startNavigation("/services")}
|
||||||
>
|
>
|
||||||
<ScrambleReveal text="服务" startDelayMs={300} scrambleColors={false} />
|
<ScrambleReveal text="服务" startDelayMs={300} scrambleColors={false} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`${dotted} p-2 uppercase cursor-pointer`}
|
className={`${dottedTone} p-2 uppercase cursor-pointer`}
|
||||||
onClick={() => goToSection("#contact")}
|
onClick={() => goToSection("#contact")}
|
||||||
>
|
>
|
||||||
<ScrambleReveal text="联系" startDelayMs={300} scrambleColors={false} />
|
<ScrambleReveal text="联系" startDelayMs={300} scrambleColors={false} />
|
||||||
@@ -251,7 +336,7 @@ export default function Header({
|
|||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
aria-label={`主题:${theme === "light" ? "浅色" : theme === "dark" ? "深色" : "跟随系统"}`}
|
aria-label={`主题:${theme === "light" ? "浅色" : theme === "dark" ? "深色" : "跟随系统"}`}
|
||||||
className={`${dotted} ${toggleCommon} p-2 uppercase cursor-pointer pointer-events-auto`}
|
className={`${dottedTone} ${toggleCommon} p-2 uppercase cursor-pointer pointer-events-auto`}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
cycleTheme();
|
cycleTheme();
|
||||||
@@ -280,7 +365,7 @@ export default function Header({
|
|||||||
soundEnabled ? "音效播放中,点击暂停" : "音效已暂停,点击播放"
|
soundEnabled ? "音效播放中,点击暂停" : "音效已暂停,点击播放"
|
||||||
}
|
}
|
||||||
aria-pressed={soundEnabled}
|
aria-pressed={soundEnabled}
|
||||||
className={`${dotted} ${toggleCommon} p-2 uppercase cursor-pointer pointer-events-auto`}
|
className={`${dottedTone} ${toggleCommon} p-2 uppercase cursor-pointer pointer-events-auto`}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
toggleSound();
|
toggleSound();
|
||||||
@@ -304,6 +389,35 @@ export default function Header({
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
{/* Nav hint panel — revealed by hovering THEME/SOUND (original P>0,
|
{/* Nav hint panel — revealed by hovering THEME/SOUND (original P>0,
|
||||||
@@ -360,7 +474,7 @@ export default function Header({
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
className={`${dotted} hidden lg:inline lg:bottom-7 lg:left-1/2 lg:fixed p-2 lg:-translate-x-1/2 cursor-pointer pointer-events-auto`}
|
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")}
|
onClick={() => scrollEnv.scrollToTop("smooth")}
|
||||||
>
|
>
|
||||||
<ScrambleReveal
|
<ScrambleReveal
|
||||||
@@ -379,7 +493,84 @@ export default function Header({
|
|||||||
scrambleColors={false}
|
scrambleColors={false}
|
||||||
/>
|
/>
|
||||||
</span>
|
</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>
|
</div>
|
||||||
</header>
|
</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>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-10
@@ -8,7 +8,8 @@ import { useEffect, useSyncExternalStore } from "react";
|
|||||||
* sound store (module 23525):
|
* sound store (module 23525):
|
||||||
*
|
*
|
||||||
* - theme ∈ {light, dark, system}, persisted to localStorage "theme"
|
* - theme ∈ {light, dark, system}, persisted to localStorage "theme"
|
||||||
* (original key, kept verbatim for parity); default "light".
|
* (original key, kept verbatim for parity); default "system" — follow the
|
||||||
|
* device (auto), per product decision (original defaulted to "light").
|
||||||
* - resolvedTheme = theme === "system"
|
* - resolvedTheme = theme === "system"
|
||||||
* ? (matchMedia("(prefers-color-scheme: dark)").matches ? dark : light)
|
* ? (matchMedia("(prefers-color-scheme: dark)").matches ? dark : light)
|
||||||
* : theme;
|
* : theme;
|
||||||
@@ -16,7 +17,8 @@ import { useEffect, useSyncExternalStore } from "react";
|
|||||||
* CSS tokens flip via the .dark block in globals.css.
|
* CSS tokens flip via the .dark block in globals.css.
|
||||||
* - "system" follows OS changes live (original matchMedia change listener).
|
* - "system" follows OS changes live (original matchMedia change listener).
|
||||||
* - soundEnabled persisted to localStorage "sound" ("on"/"off", original
|
* - soundEnabled persisted to localStorage "sound" ("on"/"off", original
|
||||||
* keys).
|
* keys); default ON — BGM starts (autoplay policies defer actual playback
|
||||||
|
* to the first user gesture, handled in useBgm's recovery effect).
|
||||||
*
|
*
|
||||||
* Implemented as a module-singleton external store (useSyncExternalStore)
|
* Implemented as a module-singleton external store (useSyncExternalStore)
|
||||||
* instead of the original context: the header and the canvas components
|
* instead of the original context: the header and the canvas components
|
||||||
@@ -38,9 +40,9 @@ type ShellMediaState = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let state: ShellMediaState = {
|
let state: ShellMediaState = {
|
||||||
theme: "light",
|
theme: "system",
|
||||||
resolvedTheme: "light",
|
resolvedTheme: "light",
|
||||||
soundEnabled: false,
|
soundEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const listeners = new Set<() => void>();
|
const listeners = new Set<() => void>();
|
||||||
@@ -90,16 +92,18 @@ function hydrate() {
|
|||||||
if (hydrated || typeof window === "undefined") return;
|
if (hydrated || typeof window === "undefined") return;
|
||||||
hydrated = true;
|
hydrated = true;
|
||||||
const stored = readStored(THEME_KEY);
|
const stored = readStored(THEME_KEY);
|
||||||
|
// 无有效存储 → 默认 system(自动跟随设备)
|
||||||
const theme: ThemeSetting = SETTINGS.includes(stored as ThemeSetting)
|
const theme: ThemeSetting = SETTINGS.includes(stored as ThemeSetting)
|
||||||
? (stored as ThemeSetting)
|
? (stored as ThemeSetting)
|
||||||
: "light";
|
: "system";
|
||||||
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
mediaQuery.addEventListener("change", onSystemChange);
|
mediaQuery.addEventListener("change", onSystemChange);
|
||||||
state = { ...state, theme, resolvedTheme: resolve(theme) };
|
state = { ...state, theme, resolvedTheme: resolve(theme) };
|
||||||
applyDocument(theme);
|
applyDocument(theme);
|
||||||
state = {
|
state = {
|
||||||
...state,
|
...state,
|
||||||
soundEnabled: readStored(SOUND_KEY) === "on",
|
// 无有效存储 → 默认开启 BGM;显式 "off" 才关闭
|
||||||
|
soundEnabled: readStored(SOUND_KEY) !== "off",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,12 +146,14 @@ function subscribe(listener: () => void) {
|
|||||||
const getSnapshot = () => state;
|
const getSnapshot = () => state;
|
||||||
|
|
||||||
// Hydration-safe SSR snapshot: must equal what the server rendered
|
// Hydration-safe SSR snapshot: must equal what the server rendered
|
||||||
// (light/paused defaults). React uses this for the hydration render, then
|
// (system/light defaults per product decision; sound defaults ON — the
|
||||||
// re-renders with the live snapshot once the client store hydrates.
|
// audio only starts after the first user gesture, see useBgm). React uses
|
||||||
|
// this for the hydration render, then re-renders with the live snapshot
|
||||||
|
// once the client store hydrates.
|
||||||
const SERVER_SNAPSHOT: ShellMediaState = {
|
const SERVER_SNAPSHOT: ShellMediaState = {
|
||||||
theme: "light",
|
theme: "system",
|
||||||
resolvedTheme: "light",
|
resolvedTheme: "light",
|
||||||
soundEnabled: false,
|
soundEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getServerSnapshot(): ShellMediaState {
|
function getServerSnapshot(): ShellMediaState {
|
||||||
|
|||||||
Reference in New Issue
Block a user