From 7f0f74a6e9948b6b27c9665e5c8d0d2c627e5c5e Mon Sep 17 00:00:00 2001 From: Hermes CI Fix Date: Fri, 17 Jul 2026 09:44:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8F=9C=E5=8D=95=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E9=80=BB=E8=BE=91=20=E2=80=94=20=E7=9B=B8?= =?UTF-8?q?=E5=90=8Cgroup=E5=90=88=E5=B9=B6=E4=B8=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=88=86=E7=BB=84=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/layouts/MainLayout.vue | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/frontend/src/layouts/MainLayout.vue b/frontend/src/layouts/MainLayout.vue index f4e6a094..67cf9590 100644 --- a/frontend/src/layouts/MainLayout.vue +++ b/frontend/src/layouts/MainLayout.vue @@ -91,23 +91,26 @@ const filteredMenus = computed(() => { // 按分组组织菜单 const menuGroups = computed(() => { const groups: { label: string; items: typeof MENU_ITEMS }[] = [] - let currentLabel = '' - let currentItems: typeof MENU_ITEMS = [] + const groupMap = new Map() for (const item of filteredMenus.value) { - if (item.group) { - if (currentItems.length > 0) { - groups.push({ label: currentLabel, items: currentItems }) - } - currentLabel = item.group as string - currentItems = [item] - } else { - currentItems.push(item) + const label = item.group || '' + if (!label) continue + if (!groupMap.has(label)) { + groupMap.set(label, []) } + groupMap.get(label)!.push(item) } - if (currentItems.length > 0) { - groups.push({ label: currentLabel, items: currentItems }) + + // 按出现顺序输出 + const seen = new Set() + for (const item of filteredMenus.value) { + const label = item.group || '' + if (!label || seen.has(label)) continue + seen.add(label) + groups.push({ label, items: groupMap.get(label)! }) } + return groups })