mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	fix: 路由顶级非目录菜单直接显示
This commit is contained in:
		| @ -65,6 +65,24 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord | |||||||
|       redirect: route.redirect, |       redirect: route.redirect, | ||||||
|       meta: meta |       meta: meta | ||||||
|     } |     } | ||||||
|  |     //处理顶级非目录路由 | ||||||
|  |     if (!route.children && route.parentId == 0 && route.component) { | ||||||
|  |       data.component = Layout | ||||||
|  |       data.meta = {} | ||||||
|  |       data.name = toCamelCase(route.path, true) + 'Parent' | ||||||
|  |       data.redirect = '' | ||||||
|  |       const childrenData: AppRouteRecordRaw = { | ||||||
|  |         path: '', | ||||||
|  |         name: toCamelCase(route.path, true), | ||||||
|  |         redirect: route.redirect, | ||||||
|  |         meta: meta | ||||||
|  |       } | ||||||
|  |       const index = route?.component | ||||||
|  |         ? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component)) | ||||||
|  |         : modulesRoutesKeys.findIndex((ev) => ev.includes(route.path)) | ||||||
|  |       childrenData.component = modules[modulesRoutesKeys[index]] | ||||||
|  |       data.children = [childrenData] | ||||||
|  |     } else { | ||||||
|       // 目录 |       // 目录 | ||||||
|       if (route.children) { |       if (route.children) { | ||||||
|         data.component = Layout |         data.component = Layout | ||||||
| @ -90,6 +108,7 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord | |||||||
|       if (route.children) { |       if (route.children) { | ||||||
|         data.children = generateRoute(route.children) |         data.children = generateRoute(route.children) | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|     res.push(data) |     res.push(data) | ||||||
|   } |   } | ||||||
|   return res |   return res | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								yudao-ui-admin-vue3/types/router.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								yudao-ui-admin-vue3/types/router.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -74,5 +74,6 @@ declare global { | |||||||
|     children?: AppCustomRouteRecordRaw[] |     children?: AppCustomRouteRecordRaw[] | ||||||
|     keepAlive?: boolean |     keepAlive?: boolean | ||||||
|     visible?: boolean |     visible?: boolean | ||||||
|  |     parentId?: number | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 weikun
					weikun