fix(play): resolve hydration mismatch and fragile pace index

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-07 14:23:44 +08:00
parent dc36b1fe9e
commit 69ae1380cb
2 changed files with 6 additions and 5 deletions
+2 -1
View File
@@ -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 顺序很重要:玩家输入若存在,必须放在最前面、单独成段、
// 用强指令包住,否则模型会把它当成夹在风格说明里的背景参考、扩写出
+4 -4
View File
@@ -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<boolean>(() => {
if (typeof window === "undefined") return true;
return readStoredVisionClick();
});
const [visionClickEnabled, setVisionClickEnabled] = useState(true);
const startedRef = useRef(false);
const poolRef = useRef<Map<string, PrefetchEntry>>(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