From e4ee38175edfb89e0f120f1f193db913a3f85ccf Mon Sep 17 00:00:00 2001 From: chenchun Date: Tue, 1 Sep 2026 20:57:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=A6=E6=83=85=E9=A1=B5=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E4=B8=8E=E5=A4=9A=E4=BD=99=E8=83=8C=E6=99=AF=20?= =?UTF-8?q?=E2=80=94=20=E5=AF=B9=E9=BD=90=E5=8E=9F=E7=AB=99=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E7=BA=A7=20canvas=20=E7=94=9F=E5=91=BD=E5=91=A8?= =?UTF-8?q?=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HeroScene/LoadingOverlay 仅在 "/" 渲染(原 canvas/set:详情页 reveal 后 卸载 canvas;entry 幕布是主页专属流程)——详情页不再有贴纸/背景 FX/玻璃 模型等"多余背景",也没有 loading 幕布 - 详情页滚动容器改为常规文档流:我们的 Lenis 是 window 级,原版的嵌套 overflow-y-auto 容器会吞掉滚轮导致页面不能滚动;窗口原生滚动接管 - SmoothScroller 按路由启停 Lenis(原 95212:主页 ReactLenis、详情页原生 滚动),路由切换时滚动复位到顶部(转场遮罩盖住跳变) - CDP 实测:详情页 wheel/End 滚动 ✅、canvas=0、幕布=0;返回主页后 canvas/Lenis/滚动条恢复、wheel 平滑滚动 ✅ --- app/work/[slug]/page.tsx | 30 ++++++++++++++--------------- components/canvas/HeroScene.tsx | 10 ++++++++++ components/dom/LoadingOverlay.tsx | 12 ++++++------ components/dom/SmoothScroller.tsx | 32 ++++++++++++++++++++++++++++--- 4 files changed, 60 insertions(+), 24 deletions(-) diff --git a/app/work/[slug]/page.tsx b/app/work/[slug]/page.tsx index e6d49d7..e71e8c9 100644 --- a/app/work/[slug]/page.tsx +++ b/app/work/[slug]/page.tsx @@ -124,9 +124,8 @@ function Article({ slug }: { slug: string }) { const article = WORK_ARTICLES[slug]; if (!article) { return ( -
-
-
+ <> +

404 @@ -141,18 +140,20 @@ function Article({ slug }: { slug: string }) {

-
-
-
+ + ); } return ( -
-
-
+ <> + {/* The window (Lenis) is the scroller — the original nests its own + overflow container per route because its Lenis wraps
; our + Lenis is window-level, so a nested overflow div would swallow the + wheel and kill scrolling. */} +

{article.title} @@ -222,9 +223,8 @@ function Article({ slug }: { slug: string }) {

)} - -
- + + ); } diff --git a/components/canvas/HeroScene.tsx b/components/canvas/HeroScene.tsx index b9faf90..02befac 100644 --- a/components/canvas/HeroScene.tsx +++ b/components/canvas/HeroScene.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect, useRef } from "react"; +import { usePathname } from "next/navigation"; import { Canvas, useThree } from "@react-three/fiber"; import { PerspectiveCamera } from "@react-three/drei"; @@ -76,6 +77,13 @@ export function HeroScene() { const isMobile = useIsMobile(); const ready = useAppReady(); const hostRef = useRef(null); + // Original canvas lifecycle (module 34841 `canvas/set`): the canvas is + // mounted for the home page and the fullscreen transitions; on detail + // routes it is unmounted once the route reveal completes. Our DOM-based + // transition overlay covers navigation, so the canvas simply renders + // home-only — no background FX / stickers / models leak onto detail pages. + const pathname = usePathname(); + const home = pathname === "/"; // Watchdog (outside the Canvas so it runs even before R3F configures): // R3F's react-use-measure can capture a stale intrinsic-size measurement @@ -111,6 +119,8 @@ export function HeroScene() { }; }, []); + if (!home) return null; + return ( // 1:1 original stacking: z-auto fixed host BEFORE the grid/main in DOM. // The z-20 BackgroundGrid (rendered after this element) paints above the diff --git a/components/dom/LoadingOverlay.tsx b/components/dom/LoadingOverlay.tsx index 3780ee0..e9fbfa4 100644 --- a/components/dom/LoadingOverlay.tsx +++ b/components/dom/LoadingOverlay.tsx @@ -1,10 +1,7 @@ "use client"; -import { - useEffect, - useState, - useSyncExternalStore, -} from "react"; +import { useEffect, useState, useSyncExternalStore } from "react"; +import { usePathname } from "next/navigation"; import { loadingBus } from "@/lib/loadingBus"; import LoadingCurtain from "@/components/canvas/LoadingCurtain"; @@ -71,6 +68,9 @@ export function useAppReady(): boolean { export function LoadingOverlay() { const heavy = useHeavyLoad(); const fontsReady = useFontsReady(); + // Original useHomeLoadingGate: the entry curtain is a "/"-only flow — + // detail routes render with no loading curtain at all. + const pathname = usePathname(); // wait → fading → reveal → (unmount when reveal completes) const [phase, setPhase] = useState<"wait" | "fading" | "reveal">("wait"); @@ -92,7 +92,7 @@ export function LoadingOverlay() { return () => window.clearTimeout(t2); }, [phase]); - if (!mounted) return null; + if (!mounted || pathname !== "/") return null; return ( <> diff --git a/components/dom/SmoothScroller.tsx b/components/dom/SmoothScroller.tsx index 6cef6c5..bf4ae40 100644 --- a/components/dom/SmoothScroller.tsx +++ b/components/dom/SmoothScroller.tsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect } from 'react'; +import { usePathname } from 'next/navigation'; import Lenis from 'lenis'; import { scrollBus, notifyScroll } from '@/lib/scrollBus'; import { scrollEnv } from '@/lib/scrollEnv'; @@ -21,7 +22,29 @@ const clamp01 = (v: number) => Math.min(1, Math.max(0, v)); * camera pull-back). */ export default function SmoothScroller() { + // Original route wiring (chunk 3c6cc5b2 module 95212): the home route is + // wrapped in ReactLenis; every other route scrolls its container + // natively. Our Lenis is window-level, so on detail routes we destroy it + // entirely (native window scroll) and reset the scroll to the top — the + // transition overlay covers the jump. + const pathname = usePathname(); + const isHome = pathname === '/'; + + // Scroll reset per route (original scrolls its per-route container to + // top on mount; the transition cover hides the jump). useEffect(() => { + if (window.location.hash) return; + window.scrollTo(0, 0); + requestAnimationFrame(() => window.scrollTo(0, 0)); + }, [isHome]); + + useEffect(() => { + if (!isHome) { + scrollEnv.setLenis(null); + return; + } + let disposed = false; + let rafId = 0; // Refresh must always start at the top (original behavior: no anchor // → scroll to 0; also re-asserted on bfcache pageshow). if ('scrollRestoration' in window.history) { @@ -73,19 +96,22 @@ export default function SmoothScroller() { updateCameraProgress(); function raf(time: number) { + if (disposed) return; lenis.raf(time); - requestAnimationFrame(raf); + rafId = requestAnimationFrame(raf); } - requestAnimationFrame(raf); + rafId = requestAnimationFrame(raf); return () => { + disposed = true; + cancelAnimationFrame(rafId); window.removeEventListener('resize', updateCameraProgress); window.removeEventListener('pageshow', onPageShow); scrollEnv.setLenis(null); lenis.destroy(); }; - }, []); + }, [isHome]); return null; }