diff --git a/app/game/page.tsx b/app/game/page.tsx index 85c00cb..3216b17 100644 --- a/app/game/page.tsx +++ b/app/game/page.tsx @@ -261,7 +261,11 @@ function PuaPanel({ gameReady, hc, waveStarted }: { gameReady: boolean; hc: numb const [insufficient, setInsufficient] = useState(false) const [dupWarning, setDupWarning] = useState(null) const textareaRef = useRef(null) - const placeholder = useRef(PUA_PLACEHOLDERS[Math.floor(Math.random() * PUA_PLACEHOLDERS.length)]).current + const [placeholder, setPlaceholder] = useState(PUA_PLACEHOLDERS[0]) + useEffect(() => { + // 只在客户端随机选取,避免 SSR/客户端 hydration 不匹配 + setPlaceholder(PUA_PLACEHOLDERS[Math.floor(Math.random() * PUA_PLACEHOLDERS.length)]) + }, []) const cost = calcPuaCost(hc) const canAfford = hc >= cost