feat: add workspace theme toggle
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user