From 2785a58a36240c531a41f2feb634102f411b01a0 Mon Sep 17 00:00:00 2001 From: hongjli <3117313295@qq.com> Date: 星期二, 08 四月 2025 12:25:37 +0800 Subject: [PATCH] 主页优化 --- src/app/layout.tsx | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 8ad4198..fe500bc 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,7 @@ import { Inter } from "next/font/google"; import "./globals.css"; import ClientLayoutContent from '@/components/layout/ClientLayoutContent'; +import Script from 'next/script'; const inter = Inter({ subsets: ["latin"] }); @@ -14,6 +15,20 @@ }, }; +const ScrollToTop = () => { + return ( + <Script id="scroll-to-top"> + {` + if (typeof window !== 'undefined') { + window.onload = function() { + window.scrollTo(0, 0); + } + } + `} + </Script> + ); +}; + export default function RootLayout({ children, }: { @@ -21,6 +36,7 @@ }) { return ( <html lang="zh-CN" className="smooth-scroll"> + <ScrollToTop /> <body className={`${inter.className} overflow-x-hidden`}> <ClientLayoutContent>{children}</ClientLayoutContent> </body> -- Gitblit v1.9.3