From c1599b38a0c6a0c731a70487f91c5cf8eb540dea Mon Sep 17 00:00:00 2001 From: biss Date: Sat, 24 Oct 2026 21:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components.d.ts | 1 + web/src/layouts/AdminLayout.vue | 151 ++++++++++++++++++++++++-------- web/src/style.css | 25 ++++++ 3 files changed, 140 insertions(+), 37 deletions(-) diff --git a/web/src/components.d.ts b/web/src/components.d.ts index f306b32..94f2e80 100644 --- a/web/src/components.d.ts +++ b/web/src/components.d.ts @@ -39,6 +39,7 @@ declare module 'vue' { ElLink: typeof import('element-plus/es')['ElLink'] ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] + ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup'] ElOption: typeof import('element-plus/es')['ElOption'] ElPagination: typeof import('element-plus/es')['ElPagination'] ElPopover: typeof import('element-plus/es')['ElPopover'] diff --git a/web/src/layouts/AdminLayout.vue b/web/src/layouts/AdminLayout.vue index a3bb0ee..5b78383 100644 --- a/web/src/layouts/AdminLayout.vue +++ b/web/src/layouts/AdminLayout.vue @@ -30,6 +30,12 @@ interface NavigationGroup { items: NavigationItem[] } +interface NavigationCategory { + key: string + label: string + groups: NavigationGroup[] +} + const stableNavigationIds: Record = { '/dashboard': 'dashboard', '/academic-calendar': 'academic-calendar', @@ -457,16 +463,63 @@ const favoriteItems = computed(() => { .filter((item): item is NavigationItem => Boolean(item)) }) -const navigationGroups = computed(() => [ +const navigationCategoryBlueprints = [ + { key: 'workspace', label: '工作台', groupKeys: ['overview', 'statistics'] }, + { + key: 'teaching', + label: '教学管理', + groupKeys: ['teaching-construction', 'teaching-operation', 'experiments'], + }, + { + key: 'assessment', + label: '考试与成绩', + groupKeys: ['teaching-assessment', 'examinations'], + }, + { + key: 'students', + label: '学生事务', + groupKeys: [ + 'student-status', + 'student-development', + 'physical-health', + 'dormitory-management', + 'graduation', + ], + }, + { key: 'system', label: '系统管理', groupKeys: ['organization'] }, +] as const + +const systemNavigationCategories = computed(() => { + const groupsByKey = new Map( + availableNavigationGroups.value.map((group) => [group.key, group]), + ) + return navigationCategoryBlueprints + .map((category) => ({ + key: category.key, + label: category.label, + groups: category.groupKeys + .map((key) => groupsByKey.get(key)) + .filter((group): group is NavigationGroup => Boolean(group)), + })) + .filter((category) => category.groups.length > 0) +}) + +const navigationCategories = computed(() => [ ...(favoriteItems.value.length - ? [{ key: 'favorites', label: '常用', items: favoriteItems.value }] + ? [{ + key: 'favorites', + label: '常用', + groups: [{ key: 'favorites', label: '常用功能', items: favoriteItems.value }], + }] : []), - ...availableNavigationGroups.value, + ...systemNavigationCategories.value, ]) -const activeGroupKey = computed( - () => availableNavigationGroups.value.find((group) => - group.items.some((item) => item.path === route.path), +const activeCategoryKey = computed( + () => systemNavigationCategories.value.find((category) => + category.groups.some((group) => + group.items.some((item) => item.path === route.path), + ), )?.key ?? '', ) @@ -493,9 +546,7 @@ const workspaceLabel = computed(() => { const pageTitle = computed(() => { if (route.path === '/account') return '个人账户' - const matchedItem = navigationGroups.value - .flatMap((group) => group.items) - .find((item) => item.path === route.path) + const matchedItem = allNavigationItems.value.find((item) => item.path === route.path) return matchedItem?.label ?? '教务管理' }) @@ -671,24 +722,37 @@ onMounted(() => { class="horizontal-menu" @select="handleNavigationSelect" > -