mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	fix: showLink is false,children menu 404
This commit is contained in:
		
							parent
							
								
									c8e90b4bd7
								
							
						
					
					
						commit
						45c2c4a301
					
				@ -49,6 +49,13 @@ export const constantRoutesArr: Array<RouteComponent> = ascending(
 | 
			
		||||
  constantRoutes
 | 
			
		||||
).concat(...remainingRouter);
 | 
			
		||||
 | 
			
		||||
// 过滤meta中showLink为false的路由
 | 
			
		||||
export const filterTree = data => {
 | 
			
		||||
  const newTree = data.filter(v => v.meta.showLink);
 | 
			
		||||
  newTree.forEach(v => v.children && (v.children = filterTree(v.children)));
 | 
			
		||||
  return newTree;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 过滤后端传来的动态路由 重新生成规范路由
 | 
			
		||||
export const addAsyncRoutes = (arrRoutes: Array<RouteComponent>) => {
 | 
			
		||||
  if (!arrRoutes || !arrRoutes.length) return;
 | 
			
		||||
@ -67,7 +74,7 @@ export const addAsyncRoutes = (arrRoutes: Array<RouteComponent>) => {
 | 
			
		||||
 | 
			
		||||
export const router: Router = createRouter({
 | 
			
		||||
  history: createWebHashHistory(),
 | 
			
		||||
  routes: ascending(constantRoutes).concat(...remainingRouter),
 | 
			
		||||
  routes: filterTree(ascending(constantRoutes)).concat(...remainingRouter),
 | 
			
		||||
  scrollBehavior(to, from, savedPosition) {
 | 
			
		||||
    return new Promise(resolve => {
 | 
			
		||||
      if (savedPosition) {
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,6 @@
 | 
			
		||||
import { defineStore } from "pinia";
 | 
			
		||||
import { store } from "/@/store";
 | 
			
		||||
 | 
			
		||||
import { constantRoutesArr, ascending } from "/@/router/index";
 | 
			
		||||
import { constantRoutesArr, ascending, filterTree } from "/@/router/index";
 | 
			
		||||
 | 
			
		||||
export const usePermissionStore = defineStore({
 | 
			
		||||
  id: "pure-permission",
 | 
			
		||||
@ -13,14 +12,6 @@ export const usePermissionStore = defineStore({
 | 
			
		||||
  }),
 | 
			
		||||
  actions: {
 | 
			
		||||
    asyncActionRoutes(routes) {
 | 
			
		||||
      const filterTree = data => {
 | 
			
		||||
        const newTree = data.filter(v => v.meta.showLink);
 | 
			
		||||
        newTree.forEach(
 | 
			
		||||
          v => v.children && (v.children = filterTree(v.children))
 | 
			
		||||
        );
 | 
			
		||||
        return newTree;
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      if (this.wholeRoutes.length > 0) return;
 | 
			
		||||
      this.wholeRoutes = filterTree(
 | 
			
		||||
        ascending(this.constantRoutes.concat(routes))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user