This commit is contained in:
hailin 2025-03-12 15:59:39 +08:00
parent 2cbff4f599
commit 1bb56b127d
1 changed files with 9 additions and 1 deletions

View File

@ -20,6 +20,8 @@ import { ReactNode } from 'react';
import TranslationsProvider from '@/components/TranslationsProvider'; import TranslationsProvider from '@/components/TranslationsProvider';
import initTranslations from '../i18n'; import initTranslations from '../i18n';
import { usePathname } from 'next/navigation'; // Next.js 13+ 内置钩子
export const runtime = 'edge' // 'nodejs' (default) | 'edge' export const runtime = 'edge' // 'nodejs' (default) | 'edge'
@ -70,6 +72,12 @@ export default async function RootLayout({
}) { }) {
const { t, resources } = await initTranslations(locale, i18nNamespaces); const { t, resources } = await initTranslations(locale, i18nNamespaces);
const pathname = usePathname(); // 获取当前页面路径
// 如果路径是某些特定页面(例如 /auth则不渲染 Header
const showHeader = !pathname.startsWith('/auth');
return ( return (
<html lang={locale} dir={dir(locale)} suppressHydrationWarning> <html lang={locale} dir={dir(locale)} suppressHydrationWarning>
<head /> <head />
@ -89,7 +97,7 @@ export default async function RootLayout({
<Providers attribute="class" defaultTheme="system" enableSystem> <Providers attribute="class" defaultTheme="system" enableSystem>
<div className="flex min-h-screen flex-col"> <div className="flex min-h-screen flex-col">
<main className="flex flex-1 flex-col bg-muted/0.3"> <main className="flex flex-1 flex-col bg-muted/0.3">
<Header /> {showHeader && <Header />} {/* 条件渲染 Header */}
{children} {children}
{/* <Footer /> */} {/* <Footer /> */}
</main> </main>