Skip to content

Commit 967b07b

Browse files
committed
fix(settings): 修复主题切换双 Provider 冲突 + 双向同步
问题: - fumadocs 的 RootProvider 内置 next-themes,与自己的 ThemeProvider 同时往 <html class> 写 light/dark,导致进入 /settings 时从黑闪白 - Header 右上角 ThemeToggle 切换主题后,/settings 表单选中态不更新 - Settings 保存时的语言设置写不到文档页能读到的位置 修复: - RootProvider 加 theme={{ enabled: false }},禁用 fumadocs 内置主题 - SettingsForm 用 useTheme() 读当前主题作为初始值 - 监听 currentTheme 变化,同步到表单选中态 - 切主题按钮立即 setTheme(所见即所得,不用等保存) - handleSave 保存成功后把 language 写 cookie,供 /docs Server Component 读
1 parent 001fd16 commit 967b07b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

app/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ export default async function RootLayout({
206206
<ThemeProvider defaultTheme="dark" storageKey="ih-theme">
207207
<AuthProvider>
208208
<RootProvider
209+
// 禁用 fumadocs 内置的 next-themes,避免与我们自己的 ThemeProvider(storageKey: ih-theme)
210+
// 同时往 <html class> 写 light/dark 导致闪烁和状态不同步
211+
theme={{ enabled: false }}
209212
search={{
210213
SearchDialog: CustomSearchDialog,
211214
// 使用静态索引,兼容 next export 与本地开发

0 commit comments

Comments
 (0)