fix: Header 跨页锚点导航 + 后台移除固定 URL 编辑项
- Header 作品/联系:首页内直接平滑滚动;在 /services、/work/* 等 非首页时写入 hq:pendingScrollAnchor 后经路由过渡回首页, SmoothScroller 消费并滚动到位(修复其它页面点击无反应) - 服务按钮在 /services 页自身不再重复导航 - PENDING_SCROLL_ANCHOR_SESSION_KEY 收敛到 lib/scrollEnv 单一来源, work 页与 SmoothScroller 共用,消除三处魔法字符串 - 后台「关于」组移除 about_p2_link_href(站内结构性锚点 #selected-work 不可配,只保留链接文字可编辑);seed/settings/类型同步清理
This commit is contained in:
@@ -4,7 +4,8 @@ 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 } from "@/lib/scrollEnv";
|
||||
import { scrollEnv, PENDING_SCROLL_ANCHOR_SESSION_KEY } from "@/lib/scrollEnv";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useRouteTransitionController } from "@/lib/routeTransition";
|
||||
import {
|
||||
useArrowFullscreenPastThreshold,
|
||||
@@ -60,6 +61,21 @@ export default function Header({
|
||||
const { theme, setTheme, soundEnabled, setSoundEnabled } = useShellMedia();
|
||||
useBgm(soundEnabled);
|
||||
const { startNavigation } = useRouteTransitionController();
|
||||
const pathname = usePathname();
|
||||
|
||||
// 首页内锚点直达;其它页面(/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()).
|
||||
@@ -213,21 +229,21 @@ export default function Header({
|
||||
<button
|
||||
type="button"
|
||||
className={`${dotted} p-2 uppercase cursor-pointer`}
|
||||
onClick={() => scrollEnv.scrollToSection("#selected-work")}
|
||||
onClick={() => goToSection("#selected-work")}
|
||||
>
|
||||
<ScrambleReveal text="作品" startDelayMs={300} scrambleColors={false} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={`${dotted} p-2 uppercase cursor-pointer`}
|
||||
onClick={() => startNavigation("/services")}
|
||||
onClick={() => pathname !== "/services" && startNavigation("/services")}
|
||||
>
|
||||
<ScrambleReveal text="服务" startDelayMs={300} scrambleColors={false} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={`${dotted} p-2 uppercase cursor-pointer`}
|
||||
onClick={() => scrollEnv.scrollToSection("#contact")}
|
||||
onClick={() => goToSection("#contact")}
|
||||
>
|
||||
<ScrambleReveal text="联系" startDelayMs={300} scrambleColors={false} />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user