refactor: 移除暗色主题切换脚本,纯静态网站不需要主题切换
This commit is contained in:
+5
-27
@@ -2,18 +2,12 @@ import type { Metadata, Viewport } from "next";
|
||||
import { Geist, Geist_Mono, Noto_Sans_SC, Ma_Shan_Zheng, Long_Cang } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import { ThemeProvider } from "@/contexts/theme-context";
|
||||
import { WebVitals } from "@/components/analytics/web-vitals";
|
||||
import { GoogleAnalytics } from "@/components/analytics/GoogleAnalytics";
|
||||
import { Analytics } from "@vercel/analytics/react";
|
||||
import { OrganizationSchema, WebsiteSchema } from "@/components/seo/structured-data";
|
||||
import { MobileTabBar } from "@/components/layout/mobile-tab-bar";
|
||||
import { ErrorBoundary } from "@/components/ui/error-boundary";
|
||||
import { ScrollProgress } from "@/components/ui/scroll-progress";
|
||||
import { BackToTop } from "@/components/ui/back-to-top";
|
||||
import { SessionProvider } from "@/providers/session-provider";
|
||||
import { initSentry } from "@/lib/sentry";
|
||||
|
||||
initSentry();
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
@@ -134,18 +128,6 @@ export default function RootLayout({
|
||||
/>
|
||||
<OrganizationSchema />
|
||||
<WebsiteSchema />
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
try {
|
||||
const theme = localStorage.getItem('ruixin-theme') || 'system';
|
||||
if (theme === 'dark' || (theme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
} catch {}
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
</head>
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} ${notoSansSC.variable} ${maShanZheng.variable} ${longCang.variable} font-sans antialiased`}
|
||||
@@ -153,17 +135,13 @@ export default function RootLayout({
|
||||
>
|
||||
<ScrollProgress />
|
||||
<GoogleAnalytics />
|
||||
<WebVitals />
|
||||
<SessionProvider>
|
||||
<ThemeProvider>
|
||||
<ErrorBoundary>
|
||||
{children}
|
||||
</ErrorBoundary>
|
||||
</ThemeProvider>
|
||||
</SessionProvider>
|
||||
<ThemeProvider>
|
||||
<ErrorBoundary>
|
||||
{children}
|
||||
</ErrorBoundary>
|
||||
</ThemeProvider>
|
||||
<MobileTabBar />
|
||||
<BackToTop />
|
||||
<Analytics />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user