From 29c051350b7cf027c0f86bccb8dc95a450a0b816 Mon Sep 17 00:00:00 2001 From: chenxing Date: Thu, 24 Sep 2026 15:38:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(layout):=20=E8=8F=9C=E5=8D=95=E7=82=B9?= =?UTF-8?q?=E5=87=BB/=E9=AB=98=E4=BA=AE=E7=BB=9F=E4=B8=80=E8=B5=B0=20resol?= =?UTF-8?q?veMenuPage=EF=BC=8C=E4=BF=AE=20/approval=20=E5=B0=BE=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC=E5=AF=BC=E8=87=B4=E8=A6=81=E7=82=B9=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?+=E4=B8=8D=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 之前模板与 linkMenu 用 raw item.page,后端 GetUserMod 待审核 page="/approval "(带尾空格) 与 routeChange 解析后的 "/approval" 不一致 → router.push 带空格需多次才命中、active 比对不等不高亮。 - linkMenu 与 active-class 改用 resolveMenuPage 解析后的 path(顺带修复外链 item.external 之前从 raw 取不到)。 - 不改数据;根治建议:平台模块管理把该 page 的尾空格去掉。 --- src/components/layout.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/layout.vue b/src/components/layout.vue index c2bdd4d..a202132 100644 --- a/src/components/layout.vue +++ b/src/components/layout.vue @@ -95,15 +95,21 @@ const routeChange = (to: any) => { navPath.value = []; }; +/** 统一解析菜单项目标:容忍平台配置的尾空格/旧 /notice 前缀/外链,返回内部路由 path 或外链 URL。 + * 模板高亮与点击都走这里,避免「raw page(带尾空格)vs 解析后 path」不一致导致点不动/不高亮。 */ +const resolveItemPage = (item: any) => + resolveMenuPage(item?.page, item?.modId ?? item?.id, item?.name); +const pageOf = (item: any): string => resolveItemPage(item).path; + const linkMenu = (item: any) => { - const page: string = item?.page || ""; + const { path: page, external } = resolveItemPage(item); if (!page) { // 解析不出有效页面:显式提示,而不是静默不动或被重定向吞到默认页 Message.warning(`菜单「${item?.name || "未命名"}」未配置有效页面路径,请检查基础平台模块设置`); return; } // 平台配置的外部链接模块:整页跳转 - if (item?.external) { + if (external) { window.location.href = page; return; } @@ -183,7 +189,7 @@ function linkHomePage() {
  • @@ -194,7 +200,7 @@ function linkHomePage() {
  • -
  • +
  • {{ item.name }}