From 69ae1380cbe6173daac7fc983b309d6d62440216 Mon Sep 17 00:00:00 2001 From: yuanzonghao Date: Sun, 7 Jun 2026 14:23:44 +0800 Subject: [PATCH] fix(play): resolve hydration mismatch and fragile pace index Co-Authored-By: Claude Opus 4.6 --- app/page.tsx | 3 ++- app/play/page.tsx | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 99be34f..729fbdc 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1261,6 +1261,7 @@ export default function HomePage() { const styleRow = OPTS.findIndex((o) => o.modal); const voiceRow = OPTS.findIndex((o) => o.label === "语音配音"); + const paceRow = OPTS.findIndex((o) => o.label === "内容节奏"); const genderIndex = sel[0] ?? 0; const gender = (OPTS[0]!.items[genderIndex] as Gender) ?? "男性向"; const phrases = EXAMPLE_PHRASES[gender]; @@ -1335,7 +1336,7 @@ export default function HomePage() { const plotStyle = PLOT_STYLES[sel[2] ?? 1] ?? "多线转折"; const voice = OPTS[voiceRow]!.items[sel[voiceRow] ?? 1]!; const audioEnabled = voice === "开启"; - const pace = PACINGS[sel[4] ?? 1] ?? "紧凑爽快"; + const pace = PACINGS[sel[paceRow] ?? 1] ?? "紧凑爽快"; // worldSetting 顺序很重要:玩家输入若存在,必须放在最前面、单独成段、 // 用强指令包住,否则模型会把它当成夹在风格说明里的背景参考、扩写出 diff --git a/app/play/page.tsx b/app/play/page.tsx index 739a8b4..66a8a48 100644 --- a/app/play/page.tsx +++ b/app/play/page.tsx @@ -580,10 +580,7 @@ function PlayInner() { // Once the player dismisses the silence nudge, keep it gone for this session. const [nudgeDismissed, setNudgeDismissed] = useState(false); const [settingsOpen, setSettingsOpen] = useState(false); - const [visionClickEnabled, setVisionClickEnabled] = useState(() => { - if (typeof window === "undefined") return true; - return readStoredVisionClick(); - }); + const [visionClickEnabled, setVisionClickEnabled] = useState(true); const startedRef = useRef(false); const poolRef = useRef>(new Map()); @@ -653,6 +650,9 @@ function PlayInner() { useEffect(() => { mutedRef.current = muted; }, [muted]); + useEffect(() => { + setVisionClickEnabled(readStoredVisionClick()); + }, []); // Coarse liveness ping for active-time analytics. /play is a single SPA // route, so page views alone read as ~0 duration; a 30s heartbeat (only