43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { Metadata, Viewport } from "next";
|
|
import { Suspense } from "react";
|
|
import "./globals.css";
|
|
import { ThemeProvider } from "./context/ThemeContext";
|
|
import NavigationLoadingProvider from "./components/NavigationLoadingProvider";
|
|
import { getSiteConfig } from "@/config";
|
|
|
|
export const viewport: Viewport = {
|
|
width: "device-width",
|
|
initialScale: 1,
|
|
viewportFit: "cover",
|
|
};
|
|
|
|
export const metadata: Metadata = {
|
|
title: getSiteConfig().meta.title,
|
|
description: getSiteConfig().meta.description,
|
|
};
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: Readonly<{
|
|
children: React.ReactNode;
|
|
}>) {
|
|
return (
|
|
<html lang="zh-CN" suppressHydrationWarning>
|
|
<head>
|
|
<script
|
|
dangerouslySetInnerHTML={{
|
|
__html: `(function(){try{var t=localStorage.getItem("theme");var d=t==="dark"||(t!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches);document.documentElement.classList.toggle("dark",d);}catch(e){}})();`,
|
|
}}
|
|
/>
|
|
</head>
|
|
<body className="antialiased">
|
|
<ThemeProvider>
|
|
<Suspense fallback={null}>
|
|
<NavigationLoadingProvider>{children}</NavigationLoadingProvider>
|
|
</Suspense>
|
|
</ThemeProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|