♻️ refactor: 优化布局组件,调整动画效果并修复ScrollToTop组件的依赖

This commit is contained in:
2025-07-28 14:32:02 +08:00
parent faa793a68d
commit dc698da285
4 changed files with 17 additions and 11 deletions

View File

@ -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 (
<div className="">
<ScrollToTop />
<div className="h-full">
{/* <ScrollToTop /> */}
<PostHeader post={post} />
<PostContent post={post} />
<PostContent post={post} />
</div>
);
}

View File

@ -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;
}