From 9a5a5b99e6b50faecd7475d406d9c2655ecf9166 Mon Sep 17 00:00:00 2001 From: Snowykami Date: Mon, 28 Jul 2025 14:06:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AF=BC=E5=85=A5=E5=92=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96Navbar=E7=BB=84=E4=BB=B6=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/blog-home.tsx | 1 - web/src/components/blog-post.tsx | 6 +- web/src/components/navbar.tsx | 101 ++++++++++++++----------------- 3 files changed, 51 insertions(+), 57 deletions(-) diff --git a/web/src/components/blog-home.tsx b/web/src/components/blog-home.tsx index 5e4f94f..be27d4d 100644 --- a/web/src/components/blog-home.tsx +++ b/web/src/components/blog-home.tsx @@ -14,7 +14,6 @@ import { useStoredState } from '@/hooks/use-storage-state'; import { listLabels } from "@/api/label"; import { POST_SORT_TYPE } from "@/localstore"; - // 定义排序类型 type SortType = 'latest' | 'popular'; diff --git a/web/src/components/blog-post.tsx b/web/src/components/blog-post.tsx index 8e7fa14..f172abb 100644 --- a/web/src/components/blog-post.tsx +++ b/web/src/components/blog-post.tsx @@ -4,6 +4,7 @@ import { Calendar, Clock, FileText, Flame, Heart, MessageCircle, PenLine, Square 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"; function PostMeta({ post }: { post: Post }) { return ( @@ -59,9 +60,10 @@ function PostMeta({ post }: { post: Post }) { ); } -function PostHeader({ post }: { post: Post }) { +async function PostHeader({ post }: { post: Post }) { + const isMobile = await isMobileByUA(); return ( -
+
{/* 背景层 */}
+ {navbarMenuComponents.map((item) => ( @@ -123,62 +121,57 @@ function ListItem({ } function SidebarMenuClientOnly() { - const [mounted, setMounted] = useState(false); - useEffect(() => setMounted(true), []); - if (!mounted) return null; return ; } function SidebarMenu() { const [open, setOpen] = useState(false) - const { isMobile } = useDevice() - - if (!isMobile) return null - return ( - - - - - - {/* 可访问性要求的标题,视觉上隐藏 */} - 侧边栏菜单 - - - + ) : null + )} + + +
+ ) } \ No newline at end of file