fix(usercenter): 首屏直接渲染登录页(修"空白")+ html suppressHydrationWarning

静态导出下 !ready 原来渲染空白背景 div,慢网络首屏看着是空的。改为 !ready||!authed
一律渲染 Login(静态无会话默认态),SSG 首屏即登录表单。html 加 suppressHydrationWarning
消除主题 data-theme 的 hydration 警告(#418)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
This commit is contained in:
wangjia
2026-07-06 23:40:24 +08:00
parent 97caae95b8
commit e4de308ba4
2 changed files with 4 additions and 5 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ export const viewport: Viewport = {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="zh" data-theme="light">
<html lang="zh" data-theme="light" suppressHydrationWarning>
<head>
{/* 设计令牌单一真相源,原样链入(SRI 由构建期注入) */}
{/* eslint-disable-next-line @next/next/no-css-tags */}
+3 -4
View File
@@ -100,10 +100,9 @@ export default function UserCenter() {
setView('overview');
}
if (!ready) {
return <div style={{ minHeight: '100vh', background: 'var(--bg)' }} />;
}
if (!authed) {
// 静态导出无服务端会话:首屏(!ready)与未登录一律直接渲染登录页,避免出现空白
// 背景(慢网络下用户会看到"空的")。已登录用户(有 refresh)会话续期完成后再切面板。
if (!ready || !authed) {
return <Login onDone={() => { setAuthed(true); setView('overview'); }} />;
}