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 { Geist, Geist_Mono, Noto_Sans_SC, Ma_Shan_Zheng, Long_Cang } from "next/font/google";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
import { ThemeProvider } from "@/contexts/theme-context";
|
import { ThemeProvider } from "@/contexts/theme-context";
|
||||||
import { WebVitals } from "@/components/analytics/web-vitals";
|
|
||||||
import { GoogleAnalytics } from "@/components/analytics/GoogleAnalytics";
|
import { GoogleAnalytics } from "@/components/analytics/GoogleAnalytics";
|
||||||
import { Analytics } from "@vercel/analytics/react";
|
|
||||||
import { OrganizationSchema, WebsiteSchema } from "@/components/seo/structured-data";
|
import { OrganizationSchema, WebsiteSchema } from "@/components/seo/structured-data";
|
||||||
import { MobileTabBar } from "@/components/layout/mobile-tab-bar";
|
import { MobileTabBar } from "@/components/layout/mobile-tab-bar";
|
||||||
import { ErrorBoundary } from "@/components/ui/error-boundary";
|
import { ErrorBoundary } from "@/components/ui/error-boundary";
|
||||||
import { ScrollProgress } from "@/components/ui/scroll-progress";
|
import { ScrollProgress } from "@/components/ui/scroll-progress";
|
||||||
import { BackToTop } from "@/components/ui/back-to-top";
|
import { BackToTop } from "@/components/ui/back-to-top";
|
||||||
import { SessionProvider } from "@/providers/session-provider";
|
|
||||||
import { initSentry } from "@/lib/sentry";
|
|
||||||
|
|
||||||
initSentry();
|
|
||||||
|
|
||||||
const geistSans = Geist({
|
const geistSans = Geist({
|
||||||
variable: "--font-geist-sans",
|
variable: "--font-geist-sans",
|
||||||
@@ -134,18 +128,6 @@ export default function RootLayout({
|
|||||||
/>
|
/>
|
||||||
<OrganizationSchema />
|
<OrganizationSchema />
|
||||||
<WebsiteSchema />
|
<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>
|
</head>
|
||||||
<body
|
<body
|
||||||
className={`${geistSans.variable} ${geistMono.variable} ${notoSansSC.variable} ${maShanZheng.variable} ${longCang.variable} font-sans antialiased`}
|
className={`${geistSans.variable} ${geistMono.variable} ${notoSansSC.variable} ${maShanZheng.variable} ${longCang.variable} font-sans antialiased`}
|
||||||
@@ -153,17 +135,13 @@ export default function RootLayout({
|
|||||||
>
|
>
|
||||||
<ScrollProgress />
|
<ScrollProgress />
|
||||||
<GoogleAnalytics />
|
<GoogleAnalytics />
|
||||||
<WebVitals />
|
<ThemeProvider>
|
||||||
<SessionProvider>
|
<ErrorBoundary>
|
||||||
<ThemeProvider>
|
{children}
|
||||||
<ErrorBoundary>
|
</ErrorBoundary>
|
||||||
{children}
|
</ThemeProvider>
|
||||||
</ErrorBoundary>
|
|
||||||
</ThemeProvider>
|
|
||||||
</SessionProvider>
|
|
||||||
<MobileTabBar />
|
<MobileTabBar />
|
||||||
<BackToTop />
|
<BackToTop />
|
||||||
<Analytics />
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user