feat(dark-mode): 实现深色模式支持
- 定义87个CSS变量的深色值([data-theme=dark]选择器) - 升级ThemeProvider支持light/dark/system三种模式 - 新增ThemeToggle组件(桌面端Header+移动端菜单) - 添加防FOUC内联脚本(渲染前应用主题) - Logo根据主题自动切换(logo.svg/logo-white.svg) - 更新测试用例覆盖主题切换逻辑
This commit is contained in:
@@ -121,6 +121,11 @@ export default function RootLayout({
|
||||
return (
|
||||
<html lang="zh-CN" className="scroll-smooth" suppressHydrationWarning>
|
||||
<head>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `(function(){try{var t=localStorage.getItem('novalon-theme');if(t==='dark'||(t==='system'||!t)&&window.matchMedia('(prefers-color-scheme:dark)').matches){document.documentElement.setAttribute('data-theme','dark')}}catch(e){}})()`,
|
||||
}}
|
||||
/>
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
|
||||
|
||||
Reference in New Issue
Block a user