fix: hydration mismatch (loading spinner restart) + cache strategy

Root cause of loading spinner restarting / name appearing twice:
React hydration mismatch → whole tree regenerated. Fixed all sources:
- AppProvider: remove typeof window in useState init (SSR/client diff);
  read cached forum name in useEffect instead
- ToastProvider: remove createPortal(document.body) (SSR absent →
  mismatch)
- LoadingScreen: name container uses dangerouslySetInnerHTML('') so
  React never manages/clobbers the inline-script-filled text
- layout.js: inline script moved to body first child (React official
  anti-FOUC pattern)

Cache: dynamic pages/API no-cache + ETag (304 on revalidate); static
/_next/static assets immutable 1y. Verified: 304 + immutable headers.
This commit is contained in:
lezi-fun committed 2026-08-11 10:52:21 +08:00
1 parent b5fafdbc09
commit 82bc2eb885
6 files changed
+58 -72

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ function HomeInner() {
// 初始化未完成:显示全屏加载页,避免未加载完的界面闪烁
if (!ready) {
return <LoadingScreen forumName={forumName} forumNameLoaded={forumNameLoaded} />;
return <LoadingScreen />;
}
return (