fix(F006-W5.x.x+3.1): 菜单跨父菜单去重
老 vue sys_menu 表里 message/sms, message/sms-log, message/mail-template, message/mail-log 4 个 url 在多个父菜单下都有 (系统设置 + 消息管理 + pid=1067246875800111156) admin_new filterByFrontendTruth 之前只检查 url 是否在 MENU_LABELS, 没去重 导致侧边栏出现 2 份短信配置/邮件模板/邮件日志/短信日志 修法: filterByFrontendTruth 加 seenUrls Set, 跨父菜单去重 (只保留第一个出现的) 保留顺序取决于后端 sort 字段 (系统设置 sort=9 < 消息管理 sort=11) 所以 message/sms 保留在系统设置父菜单下, 其他 3 个 url 保留在消息管理下
This commit is contained in:
parent
f9e53be1ed
commit
1fe924e069
@ -101,7 +101,7 @@ export const MENU_LABELS: MenuLabel[] = [
|
|||||||
// ===== API 模块 =====
|
// ===== API 模块 =====
|
||||||
{ url: 'api/lunbo', label: '轮播管理', icon: 'Picture', path: '/api/lunbo', sort: 600 },
|
{ url: 'api/lunbo', label: '轮播管理', icon: 'Picture', path: '/api/lunbo', sort: 600 },
|
||||||
{ url: 'api/feedback', label: '意见反馈(→内容列表)', icon: 'ChatLineRound', path: '/other/operateguide', sort: 601 },
|
{ url: 'api/feedback', label: '意见反馈(→内容列表)', icon: 'ChatLineRound', path: '/other/operateguide', sort: 601 },
|
||||||
{ url: 'api/help', label: '帮助中心', icon: 'Notebook', path: '/api/help', sort: 602 },
|
{ url: 'api/help', label: '帮助中心(API)', icon: 'Notebook', path: '/api/help', sort: 602 },
|
||||||
|
|
||||||
// ===== 其它模块(老版本"其它"分组) =====
|
// ===== 其它模块(老版本"其它"分组) =====
|
||||||
{ url: 'other/textconfig', label: '常量配置', icon: 'Document', path: '/other/textconfig', sort: 700 },
|
{ url: 'other/textconfig', label: '常量配置', icon: 'Document', path: '/other/textconfig', sort: 700 },
|
||||||
@ -123,7 +123,7 @@ export const MENU_LABELS: MenuLabel[] = [
|
|||||||
|
|
||||||
// ===== 开发工具(devtools) =====
|
// ===== 开发工具(devtools) =====
|
||||||
{ url: 'devtools/datasource', label: '数据源配置', icon: 'Coin', path: '/devtools/datasource', sort: 901 },
|
{ url: 'devtools/datasource', label: '数据源配置', icon: 'Coin', path: '/devtools/datasource', sort: 901 },
|
||||||
{ url: 'devtools/param', label: '参数配置', icon: 'SetUp', path: '/devtools/param', sort: 902 },
|
{ url: 'devtools/param', label: '参数配置(开发)', icon: 'SetUp', path: '/devtools/param', sort: 902 },
|
||||||
{ url: 'devtools/baseclass', label: '基类配置', icon: 'Files', path: '/devtools/baseclass', sort: 903 },
|
{ url: 'devtools/baseclass', label: '基类配置', icon: 'Files', path: '/devtools/baseclass', sort: 903 },
|
||||||
{ url: 'devtools/template', label: '模板配置', icon: 'Tickets', path: '/devtools/template', sort: 904 },
|
{ url: 'devtools/template', label: '模板配置', icon: 'Tickets', path: '/devtools/template', sort: 904 },
|
||||||
{ url: 'devtools/fieldtype', label: '字段配置', icon: 'CollectionTag', path: '/devtools/fieldtype', sort: 905 },
|
{ url: 'devtools/fieldtype', label: '字段配置', icon: 'CollectionTag', path: '/devtools/fieldtype', sort: 905 },
|
||||||
|
|||||||
@ -59,6 +59,7 @@ export const useMenuStore = defineStore('menu', () => {
|
|||||||
*/
|
*/
|
||||||
function filterByFrontendTruth(items: ResolvedMenu[]): ResolvedMenu[] {
|
function filterByFrontendTruth(items: ResolvedMenu[]): ResolvedMenu[] {
|
||||||
const allowedUrls = new Set(MENU_LABELS.map(m => m.url))
|
const allowedUrls = new Set(MENU_LABELS.map(m => m.url))
|
||||||
|
const seenUrls = new Set<string>() // W5.x.x+3.1: 跨父菜单去重 (老 vue 一个 url 可能在多个父菜单下重复)
|
||||||
return items
|
return items
|
||||||
.map(item => {
|
.map(item => {
|
||||||
// 父菜单: 无 url, 递归处理 children
|
// 父菜单: 无 url, 递归处理 children
|
||||||
@ -68,8 +69,11 @@ export const useMenuStore = defineStore('menu', () => {
|
|||||||
if (!filtered.length) return null
|
if (!filtered.length) return null
|
||||||
return { ...item, children: filtered }
|
return { ...item, children: filtered }
|
||||||
}
|
}
|
||||||
// 子菜单: url 必须在 MENU_LABELS 里
|
// 子菜单: url 必须在 MENU_LABELS 里, 且首次出现
|
||||||
return allowedUrls.has(item.url) ? item : null
|
if (!allowedUrls.has(item.url)) return null
|
||||||
|
if (seenUrls.has(item.url)) return null
|
||||||
|
seenUrls.add(item.url)
|
||||||
|
return item
|
||||||
})
|
})
|
||||||
.filter((item): item is ResolvedMenu => item !== null)
|
.filter((item): item is ResolvedMenu => item !== null)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user