forked from kleinrui/sub-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.tsx
54 lines (46 loc) · 1.39 KB
/
layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Inter } from "next/font/google";
import { headers } from "next/headers";
import { ThemeProvider } from "next-themes";
import { AppSidebar } from "@/components/app-sidebar";
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import { Toaster } from "@/components/ui/sonner";
import { cn } from "@/lib/utils";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
// Add metadata export
export const metadata = {
title: "Sub Box - 订阅管理系统",
description: "简单高效的订阅管理工具",
icons: {
icon: [
{
url: "/favicon.svg",
type: "image/svg+xml",
},
],
},
};
function getStoredTheme(): string {
try {
const headersList = headers();
const cookie = headersList.get("cookie") ?? "";
if (!cookie) return "system";
const themeMatch = cookie.match(/theme=([^;]+)/);
return themeMatch?.[1] ?? "system";
} catch {
return "system";
}
}
export default function RootLayout({ children }: { children: React.ReactNode }) {
const defaultTheme = getStoredTheme();
return (
<html lang="zh-CN" suppressHydrationWarning>
<body className={cn(inter.className, "min-h-screen")}>
<ThemeProvider attribute="class" defaultTheme={defaultTheme} enableSystem disableTransitionOnChange>
{children}
<Toaster />
</ThemeProvider>
</body>
</html>
);
}