From 73f4febdc1b16c26facbbe6bb255218296fdb355 Mon Sep 17 00:00:00 2001 From: ZM25XC <78628186+ZM25XC@users.noreply.github.com> Date: Sat, 8 Jun 2024 17:08:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A1=B5=E9=9D=A2tag?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E7=8A=B6=E6=80=81=E9=80=BB=E8=BE=91=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当`showLink`为`false`,传递参数默认为空,当前页面路径为`/path1/index`,其余路径(`showLink:false`)为:`/path2/index`,`/path3/index`等都会显示激活状态 --- src/layout/hooks/useTag.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/layout/hooks/useTag.ts b/src/layout/hooks/useTag.ts index e82e36ff67..4054752e1d 100644 --- a/src/layout/hooks/useTag.ts +++ b/src/layout/hooks/useTag.ts @@ -114,15 +114,12 @@ export function useTags() { ]); function conditionHandle(item, previous, next) { - if (isBoolean(route?.meta?.showLink) && route?.meta?.showLink === false) { - if (Object.keys(route.query).length > 0) { - return isEqual(route.query, item.query) ? previous : next; - } else { - return isEqual(route.params, item.params) ? previous : next; - } - } else { - return route.path === item.path ? previous : next; - } + const isSamePath = route.path === item.path; + const hasQuery = Object.keys(route.query).length > 0; + const isSameData = hasQuery + ? isEqual(route.query, item.query) + : isEqual(route.params, item.params); + return isSamePath ? (isSameData ? previous : next) : next; } const iconIsActive = computed(() => {