mirror of
https://github.com/KivotosRailway/website.git
synced 2026-11-03 11:06:32 +09:00
404 页面路由问题修复
This commit is contained in:
@@ -1 +1,5 @@
|
||||
export { default, metadata, viewport } from "@/components/layout/site-document";
|
||||
import { SiteShell } from "@/components/layout/site-shell";
|
||||
|
||||
export default function LegacyLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
return <SiteShell locale="zh-Hans">{children}</SiteShell>;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import SiteDocument from "@/components/layout/site-document";
|
||||
import { SiteShell } from "@/components/layout/site-shell";
|
||||
import { getLocaleMessages, locales, matchLocale } from "@/lib/i18n";
|
||||
|
||||
export { viewport } from "@/components/layout/site-document";
|
||||
export const dynamicParams = false;
|
||||
|
||||
export function generateStaticParams() {
|
||||
@@ -39,5 +38,5 @@ export default async function LocaleLayout({ children, params }: {
|
||||
const { locale } = await params;
|
||||
const canonicalLocale = matchLocale(locale);
|
||||
if (!canonicalLocale) notFound();
|
||||
return <SiteDocument locale={canonicalLocale}>{children}</SiteDocument>;
|
||||
return <SiteShell locale={canonicalLocale}>{children}</SiteShell>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import SiteDocument from "@/components/layout/site-document";
|
||||
|
||||
export { metadata, viewport } from "@/components/layout/site-document";
|
||||
|
||||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
return <SiteDocument>{children}</SiteDocument>;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { SiteShell } from "@/components/layout/site-shell";
|
||||
import { HttpStatusPage } from "@/components/status/http-status-page";
|
||||
|
||||
export default function NotFound() {
|
||||
return <SiteShell locale="zh-Hans"><HttpStatusPage code={404} /></SiteShell>;
|
||||
}
|
||||
@@ -1,11 +1,5 @@
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import { Suspense } from "react";
|
||||
import "@/app/globals.css";
|
||||
import type { Locale } from "@/lib/i18n";
|
||||
import { LocaleProvider } from "@/components/layout/locale-context";
|
||||
import { SiteFooter } from "@/components/layout/site-footer";
|
||||
import { SiteHeader } from "@/components/layout/site-header";
|
||||
import { LocaleUrlSync } from "@/components/layout/locale-url-sync";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: {
|
||||
@@ -25,10 +19,9 @@ export const viewport: Viewport = {
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
locale = "zh-Hans",
|
||||
}: Readonly<{ children: React.ReactNode; locale?: Locale }>) {
|
||||
}: Readonly<{ children: React.ReactNode }>) {
|
||||
return (
|
||||
<html lang={locale} suppressHydrationWarning>
|
||||
<html lang="zh-Hans" suppressHydrationWarning>
|
||||
<head>
|
||||
{/* Run during HTML parsing, before the body can paint. */}
|
||||
<script
|
||||
@@ -82,12 +75,7 @@ export default function RootLayout({
|
||||
})();` }}
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<LocaleProvider locale={locale}>
|
||||
<Suspense fallback={null}><LocaleUrlSync /></Suspense>
|
||||
<SiteHeader />{children}<SiteFooter />
|
||||
</LocaleProvider>
|
||||
</body>
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Suspense } from "react";
|
||||
import type { Locale } from "@/lib/i18n";
|
||||
import { LocaleProvider } from "@/components/layout/locale-context";
|
||||
import { LocaleUrlSync } from "@/components/layout/locale-url-sync";
|
||||
import { SiteFooter } from "@/components/layout/site-footer";
|
||||
import { SiteHeader } from "@/components/layout/site-header";
|
||||
|
||||
export function SiteShell({ children, locale }: { children: React.ReactNode; locale: Locale }) {
|
||||
return (
|
||||
<LocaleProvider locale={locale}>
|
||||
<Suspense fallback={null}><LocaleUrlSync /></Suspense>
|
||||
<SiteHeader />{children}<SiteFooter />
|
||||
</LocaleProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user