From ba9a918d99e97d9b1fe1da59be599c5503dec90a Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Wed, 29 Mar 2023 14:35:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E7=BA=A7?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E9=AB=98=E4=BA=AE=E9=97=AE=E9=A2=98=20(#459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/components/MenuContent.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/layouts/components/MenuContent.vue b/src/layouts/components/MenuContent.vue index 2f0ddb0..543353e 100644 --- a/src/layouts/components/MenuContent.vue +++ b/src/layouts/components/MenuContent.vue @@ -38,7 +38,6 @@ const props = defineProps({ default: () => [], }, }); - const active = computed(() => getActive()); const list = computed(() => { @@ -85,9 +84,16 @@ const getHref = (item: MenuRoute) => { }; const getPath = (item: ListItemType) => { + const activeLevel = active.value.split('/').length; + const pathLevel = item.path.split('/').length; + if (activeLevel > pathLevel && active.value.startsWith(item.path)) { + return active.value; + } + if (active.value === item.path) { return active.value; } + return item.meta?.single ? item.redirect : item.path; };