1
1
import { cloneDeep } from 'lodash-es'
2
- import type { RouteMeta , RouteRecordRaw } from 'vue-router'
2
+ import type { RouteRecordRaw } from 'vue-router'
3
3
import useSettingsStore from './settings'
4
4
import { resolveRoutePath } from '@/utils'
5
5
import { systemRoutes } from '@/router/routes'
@@ -25,16 +25,15 @@ const useRouteStore = defineStore(
25
25
title : route . meta ?. title ,
26
26
icon : route . meta ?. icon ,
27
27
hide : ! route . meta ?. breadcrumb && route . meta ?. breadcrumb === false ,
28
- } ] , route . path , route . meta ?. auth )
28
+ } ] , route . path )
29
29
}
30
30
return route
31
31
}
32
- function flatAsyncRoutesRecursive ( routes : RouteRecordRaw [ ] , breadcrumb : Route . breadcrumb [ ] = [ ] , baseUrl = '' , baseAuth : RouteMeta [ 'auth' ] ) : RouteRecordRaw [ ] {
32
+ function flatAsyncRoutesRecursive ( routes : RouteRecordRaw [ ] , breadcrumb : Route . breadcrumb [ ] = [ ] , baseUrl = '' ) : RouteRecordRaw [ ] {
33
33
const res : RouteRecordRaw [ ] = [ ]
34
34
routes . forEach ( ( route ) => {
35
35
if ( route . children ) {
36
36
const childrenBaseUrl = resolveRoutePath ( baseUrl , route . path )
37
- const childrenBaseAuth = ! baseAuth || baseAuth === '' || baseAuth ?. length === 0 ? route . meta ?. auth : baseAuth
38
37
const tmpBreadcrumb = cloneDeep ( breadcrumb )
39
38
tmpBreadcrumb . push ( {
40
39
path : childrenBaseUrl ,
@@ -47,11 +46,10 @@ const useRouteStore = defineStore(
47
46
if ( ! tmpRoute . meta ) {
48
47
tmpRoute . meta = { }
49
48
}
50
- tmpRoute . meta . auth = childrenBaseAuth
51
49
tmpRoute . meta . breadcrumbNeste = tmpBreadcrumb
52
50
delete tmpRoute . children
53
51
res . push ( tmpRoute )
54
- const childrenRoutes = flatAsyncRoutesRecursive ( route . children , tmpBreadcrumb , childrenBaseUrl , childrenBaseAuth )
52
+ const childrenRoutes = flatAsyncRoutesRecursive ( route . children , tmpBreadcrumb , childrenBaseUrl )
55
53
childrenRoutes . forEach ( ( item ) => {
56
54
// 如果 path 一样则覆盖,因为子路由的 path 可能设置为空,导致和父路由一样,直接注册会提示路由重复
57
55
if ( res . some ( v => v . path === item . path ) ) {
@@ -80,7 +78,6 @@ const useRouteStore = defineStore(
80
78
if ( ! tmpRoute . meta ) {
81
79
tmpRoute . meta = { }
82
80
}
83
- tmpRoute . meta . auth = ! baseAuth || baseAuth === '' || baseAuth ?. length === 0 ? tmpRoute . meta ?. auth : baseAuth
84
81
tmpRoute . meta . breadcrumbNeste = tmpBreadcrumb
85
82
res . push ( tmpRoute )
86
83
}
0 commit comments