From 5245a144428170842972103b534d07535fb18fbd Mon Sep 17 00:00:00 2001
From: ray <1490493387@qq.com>
Date: Thu, 10 Oct 2024 00:05:14 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E4=BF=AE=E5=A4=8D=E6=B7=B7?=
=?UTF-8?q?=E5=90=88=E5=B8=83=E5=B1=80=E9=87=8D=E5=AE=9A=E5=90=91=E9=A6=96?=
=?UTF-8?q?=E9=A1=B5=E6=9C=AA=E6=BF=80=E6=B4=BB=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Sidebar/components/SidebarMixTopMenu.vue | 13 +++++++++----
src/layout/components/Sidebar/index.vue | 6 +++---
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue b/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue
index 6982b815..c573fe7d 100644
--- a/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue
+++ b/src/layout/components/Sidebar/components/SidebarMixTopMenu.vue
@@ -1,4 +1,4 @@
-
+
-
+
首页
@@ -47,8 +47,13 @@ const appStore = useAppStore();
const permissionStore = usePermissionStore();
const router = useRouter();
-// 避免 activeTopMenuPath 缓存被清理,从当前路由路径获取顶部菜单路径,eg. /system/user → /system
-const activeTopMenuPath = useRoute().path.match(/^\/[^\/]+/)?.[0] || "/";
+// 避免 activeTopMenuPath 缓存被清理,从当前路由路径获取顶部菜单路径,
+// eg. / system / user → /system; / dashboard → /
+const activeTopMenuPath =
+ useRoute().path.split("/").filter(Boolean).length > 1
+ ? useRoute().path.match(/^\/[^\/]+/)?.[0] || "/"
+ : "/";
+
appStore.activeTopMenu(activeTopMenuPath);
// 激活的顶部菜单路径
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index 59c6b6be..67a3df09 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -1,12 +1,12 @@