Merge branch 'develop'

# Conflicts:
#	src/App.vue
#	src/api/menuApi.ts
#	src/components/core/layouts/art-header-bar/index.vue
#	src/router/routes/asyncRoutes.ts
#	src/router/routesAlias.ts
#	src/typings/api.d.ts
#	src/views/system/user-center/index.vue
This commit is contained in:
浅念
2025-07-21 11:44:09 +08:00
parent 2a82a7ba95
commit 7c1766ec79
19 changed files with 3722 additions and 500 deletions
+25 -2
View File
@@ -5,7 +5,28 @@ import { useUserStore } from '@/store/modules/user'
interface MenuResponse {
menuList: AppRouteRecord[]
}
// 合并方法
function mergeRoutes(dynamicRoutes: AppRouteRecord[] = [], staticRoutes: AppRouteRecord[] = []): AppRouteRecord[] {
// 深度合并逻辑
const merged = [...staticRoutes]
dynamicRoutes.forEach(dynamicRoute => {
const existingIndex = merged.findIndex(r => r.path === dynamicRoute.path)
if (existingIndex >= 0) {
// 合并children(如果存在)
if (dynamicRoute.children) {
merged[existingIndex].children = [
...(merged[existingIndex].children || []),
...dynamicRoute.children
]
}
} else {
merged.push(dynamicRoute)
}
})
return merged
}
// 菜单接口
export const menuService = {
async getMenuList(delay = 300): Promise<MenuResponse> {
@@ -17,6 +38,8 @@ export const menuService = {
}
// 模拟接口返回的菜单数据
const menuData = userStore.info.menu
// 2. 合并静态菜单
const finalRoutes = mergeRoutes(menuData, asyncRoutes)
// 验证菜单数据
if (!menuData || !Array.isArray(menuData) || menuData.length === 0) {
ElMessage.error('暂无系统菜单权限')
@@ -24,7 +47,7 @@ export const menuService = {
}
// 处理菜单数据
const menuList = menuData.map((route: any) => menuDataToRouter(route))
const menuList = finalRoutes.map((route: any) => menuDataToRouter(route))
// 验证处理后的菜单列表
if (!menuList || menuList.length === 0) {