mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	fix: 修复路由showlink为false的异步路由,刷新后不显示
				
					
				
			This commit is contained in:
		
							parent
							
								
									b2dd962161
								
							
						
					
					
						commit
						4c6acc91ab
					
				@ -8,6 +8,7 @@ import {
 | 
				
			|||||||
} from "vue-router";
 | 
					} from "vue-router";
 | 
				
			||||||
import { router } from "./index";
 | 
					import { router } from "./index";
 | 
				
			||||||
import { loadEnv } from "../../build";
 | 
					import { loadEnv } from "../../build";
 | 
				
			||||||
 | 
					import { cloneDeep } from "lodash-unified";
 | 
				
			||||||
import { useTimeoutFn } from "@vueuse/core";
 | 
					import { useTimeoutFn } from "@vueuse/core";
 | 
				
			||||||
import { RouteConfigs } from "/@/layout/types";
 | 
					import { RouteConfigs } from "/@/layout/types";
 | 
				
			||||||
import { buildHierarchyTree } from "@pureadmin/utils";
 | 
					import { buildHierarchyTree } from "@pureadmin/utils";
 | 
				
			||||||
@ -39,7 +40,7 @@ function ascending(arr: any[]) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// 过滤meta中showLink为false的路由
 | 
					// 过滤meta中showLink为false的路由
 | 
				
			||||||
function filterTree(data: RouteComponent[]) {
 | 
					function filterTree(data: RouteComponent[]) {
 | 
				
			||||||
  const newTree = data.filter(
 | 
					  const newTree = cloneDeep(data).filter(
 | 
				
			||||||
    (v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false
 | 
					    (v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  newTree.forEach(
 | 
					  newTree.forEach(
 | 
				
			||||||
@ -135,7 +136,7 @@ function initRouter(name: string) {
 | 
				
			|||||||
              // 最终路由进行升序
 | 
					              // 最终路由进行升序
 | 
				
			||||||
              ascending(router.options.routes[0].children);
 | 
					              ascending(router.options.routes[0].children);
 | 
				
			||||||
              if (!router.hasRoute(v?.name)) router.addRoute(v);
 | 
					              if (!router.hasRoute(v?.name)) router.addRoute(v);
 | 
				
			||||||
              const flattenRouters = router
 | 
					              const flattenRouters: any = router
 | 
				
			||||||
                .getRoutes()
 | 
					                .getRoutes()
 | 
				
			||||||
                .find(n => n.path === "/");
 | 
					                .find(n => n.path === "/");
 | 
				
			||||||
              router.addRoute(flattenRouters);
 | 
					              router.addRoute(flattenRouters);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user