mirror of
				https://github.com/soybeanjs/soybean-admin.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	fix(projects): when the roles filter submenu is empty, the parent menu is not excluded. fixed #621. (#626)
This commit is contained in:
		@@ -19,7 +19,7 @@ export function filterAuthRoutesByRoles(routes: ElegantConstRoute[], roles: stri
 | 
			
		||||
 * @param route Auth route
 | 
			
		||||
 * @param roles Roles
 | 
			
		||||
 */
 | 
			
		||||
function filterAuthRouteByRoles(route: ElegantConstRoute, roles: string[]) {
 | 
			
		||||
function filterAuthRouteByRoles(route: ElegantConstRoute, roles: string[]): ElegantConstRoute[] {
 | 
			
		||||
  const routeRoles = (route.meta && route.meta.roles) || [];
 | 
			
		||||
 | 
			
		||||
  // if the route's "roles" is empty, then it is allowed to access
 | 
			
		||||
@@ -34,6 +34,11 @@ function filterAuthRouteByRoles(route: ElegantConstRoute, roles: string[]) {
 | 
			
		||||
    filterRoute.children = filterRoute.children.flatMap(item => filterAuthRouteByRoles(item, roles));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Exclude the route if it has no children after filtering
 | 
			
		||||
  if (filterRoute.children?.length === 0) {
 | 
			
		||||
    return [];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return hasPermission || isEmptyRoles ? [filterRoute] : [];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user