feat: add workspace theme toggle

This commit is contained in:
2026-07-03 04:28:01 -07:00
parent c4d5222ddd
commit fb15d4db47
4 changed files with 147 additions and 6 deletions

View File

@@ -14,6 +14,21 @@ type RootLayoutProps = {
export default function RootLayout({ children }: RootLayoutProps): React.ReactElement {
return (
<html lang="zh-CN" suppressHydrationWarning>
<head>
<script
dangerouslySetInnerHTML={{
__html: `
try {
var theme = localStorage.getItem("teatea-theme") || "system";
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
var isDark = theme === "dark" || (theme === "system" && prefersDark);
document.documentElement.classList.toggle("dark", isDark);
document.documentElement.style.colorScheme = isDark ? "dark" : "light";
} catch (_) {}
`,
}}
/>
</head>
<body>{children}</body>
</html>
);