mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	perf: router rank
This commit is contained in:
		
							parent
							
								
									99140bbd1e
								
							
						
					
					
						commit
						ae57e42612
					
				@ -22,6 +22,13 @@ import { getAsyncRoutes } from "/@/api/routes";
 | 
			
		||||
 | 
			
		||||
// 按照路由中meta下的rank等级升序来排序路由
 | 
			
		||||
function ascending(arr: any[]) {
 | 
			
		||||
  arr.forEach(v => {
 | 
			
		||||
    if (v?.meta?.rank === 0) {
 | 
			
		||||
      if (v.name !== "home" && v.path !== "/") {
 | 
			
		||||
        console.warn("rank only the home page can be 0");
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
  return arr.sort(
 | 
			
		||||
    (a: { meta: { rank: number } }, b: { meta: { rank: number } }) => {
 | 
			
		||||
      return a?.meta?.rank - b?.meta?.rank;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user