From 2a712f09ef478ebff74a5e39d1b63e051c418f68 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Thu, 26 Feb 2026 23:06:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BE=A7=E8=BE=B9=E6=A0=8F?= =?UTF-8?q?=E7=A7=81=E4=BA=BA=E5=BD=B1=E5=BA=93=E9=80=89=E9=A1=B9=E4=B8=8D?= =?UTF-8?q?=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sidebar.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 3b8cf4e..4dea967 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -308,10 +308,16 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => { const decodedActive = decodeURIComponent(active); const decodedItemHref = decodeURIComponent(item.href); + // 提取路径名(不包含查询参数) + const activePathname = decodedActive.split('?')[0]; + const itemPathname = decodedItemHref.split('?')[0]; + const isActive = decodedActive === decodedItemHref || (decodedActive.startsWith('/douban') && - decodedActive.includes(`type=${typeMatch}`)); + decodedActive.includes(`type=${typeMatch}`)) || + // 对于没有type参数的路径,只比较路径名 + (!typeMatch && activePathname === itemPathname); const Icon = item.icon; return (