From 05fcb4af49aee9c73b468b8980b76c696229fdab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=98=8A=E5=A4=A9?= <442384644@qq.com> Date: Thu, 8 Oct 2026 15:10:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=90=8E=E5=8F=B0):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=90=A5=E9=94=80=E5=88=9B=E5=BB=BA=E9=A1=B5=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E8=A2=AB=E7=A9=BA=E8=B7=AF=E5=BE=84=E8=8F=9C=E5=8D=95=E6=B1=A1?= =?UTF-8?q?=E6=9F=93=E4=B8=BA=E3=80=8C=E6=B7=BB=E5=8A=A0MCP=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit editRouterFun 对四个营销 Create 路由按菜单树拼标题时,目录菜单 (如 MCP服务)menu_path 为空串使 indexOf 恒成立且后写覆盖, 标题被污染成「添加+任意目录名」。改为:创建态保留路由定义的 meta.title;编辑态用 activeMenu 匹配最长菜单名 + ID。 --- frontend/admin/src/router/index.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/admin/src/router/index.js b/frontend/admin/src/router/index.js index aa6e8e7c8..7cadee93d 100644 --- a/frontend/admin/src/router/index.js +++ b/frontend/admin/src/router/index.js @@ -111,12 +111,19 @@ export function editRouterFun(to, from) { 'marketing_storeCouponCreate', ].includes(to.name) ) { - let route = to.matched[1].path.split(':')[0]; - menusStore.oneLvRoutes.map((e) => { - if (route.indexOf(e.path) != -1) { - to.meta.title = `${to.params.id ? e.title + 'ID: ' + to.params.id : '添加' + e.title}`; - } - }); + // 创建态(无 id)保留路由定义的 meta.title;编辑态用最具体菜单名 + ID 便于多标签区分。 + // 空匹配保护:目录菜单 path 为空时 indexOf 恒成立,曾把标题污染成任意"添加+目录名" + if (to.params.id) { + // 用 activeMenu(列表页路径)匹配菜单树,比 create 路径能命中更具体的菜单名 + const route = (to.meta.activeMenu || to.matched[1].path.split(':')[0]).replace(/\/$/, ''); + let best = null; + menusStore.oneLvRoutes.map((e) => { + const p = (e.path || '').replace(/\/$/, ''); + if (!p || route.indexOf(p) === -1) return; + if (!best || p.length > best.p.length) best = { p, title: e.title }; + }); + if (best) to.meta.title = `${best.title}ID: ${to.params.id}`; + } } // 产品类型扩展路由:从系统菜单树查找菜单名称作为标签页标题 if (to.name === 'product_extPage') {