From dc698da2855d113e5ae20473555cb77fed2ce0dd Mon Sep 17 00:00:00 2001 From: Snowykami Date: Mon, 28 Jul 2025 14:32:02 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=B8=83=E5=B1=80=E7=BB=84=E4=BB=B6=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=8A=A8=E7=94=BB=E6=95=88=E6=9E=9C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DScrollToTop=E7=BB=84=E4=BB=B6=E7=9A=84=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/app/(main)/layout.tsx | 11 ++++++----- web/src/app/(main)/p/[id]/page.tsx | 6 +++++- web/src/components/blog-post.tsx | 7 +++---- web/src/components/scroll-to-top.client.tsx | 4 +++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/web/src/app/(main)/layout.tsx b/web/src/app/(main)/layout.tsx index 91f16d8..193cf07 100644 --- a/web/src/app/(main)/layout.tsx +++ b/web/src/app/(main)/layout.tsx @@ -14,13 +14,13 @@ export default function RootLayout({ const pathname = usePathname() return ( <> -
- -
+
+ +
+
{children}
diff --git a/web/src/app/(main)/p/[id]/page.tsx b/web/src/app/(main)/p/[id]/page.tsx index 1ef98c6..576326d 100644 --- a/web/src/app/(main)/p/[id]/page.tsx +++ b/web/src/app/(main)/p/[id]/page.tsx @@ -12,5 +12,9 @@ export default async function PostPage({ params }: Props) { const post = await getPostById(id, cookieStore.get('token')?.value || ''); if (!post) return
文章不存在
- return + return ( +
+ +
+ ) } diff --git a/web/src/components/blog-post.tsx b/web/src/components/blog-post.tsx index f172abb..b9dd520 100644 --- a/web/src/components/blog-post.tsx +++ b/web/src/components/blog-post.tsx @@ -1,7 +1,6 @@ import { Suspense } from "react"; import type { Post } from "@/models/post"; import { Calendar, Clock, FileText, Flame, Heart, MessageCircle, PenLine, SquarePen } from "lucide-react"; -import { MDXRemote } from "next-mdx-remote-client/rsc"; import ScrollToTop from "@/components/scroll-to-top.client"; import { RenderMarkdown } from "@/components/markdown"; import { isMobileByUA } from "@/utils/server/device"; @@ -134,10 +133,10 @@ async function PostContent({ post }: { post: Post }) { async function BlogPost({ post }: { post: Post }) { return ( -
- +
+ {/* */} - +
); } diff --git a/web/src/components/scroll-to-top.client.tsx b/web/src/components/scroll-to-top.client.tsx index 44c1030..450199d 100644 --- a/web/src/components/scroll-to-top.client.tsx +++ b/web/src/components/scroll-to-top.client.tsx @@ -1,9 +1,11 @@ 'use client' +import { usePathname } from "next/navigation"; import { useEffect } from "react"; export default function ScrollToTop() { + const pathname = usePathname(); useEffect(() => { window.scrollTo(0, 0); - }, []); + }, [pathname]); return null; } \ No newline at end of file