Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit afca2e1f
authored
Feb 08, 2023
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
路由问题修复及优化
1 parent
0c1804a8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
193 additions
and
290 deletions
linkwe-pc/src/layout/components/TopNav/index.vue
linkwe-pc/src/router/index.js
linkwe-pc/src/store/getters.js
linkwe-pc/src/store/modules/permission.js
linkwe-pc/src/layout/components/TopNav/index.vue
View file @
afca2e1
...
@@ -16,214 +16,152 @@
...
@@ -16,214 +16,152 @@
</template>
</template>
<
script
>
<
script
>
import
{
constantRoutes
}
from
'@/router'
import
{
constantRoutes
}
from
'@/router'
import
{
isExternal
}
from
'@/utils/validate'
import
{
isExternal
}
from
'@/utils/validate'
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
name
:
''
,
// name: '',
// 顶部栏初始数
// 顶部栏初始数
visibleNumber
:
5
,
visibleNumber
:
5
,
// 是否为首次加载
// 是否为首次加载
isFrist
:
false
,
isFrist
:
false
,
// 当前激活菜单的
// 当前激活菜单的
currentIndex
:
''
currentIndex
:
''
,
}
}
},
computed
:
{
theme
()
{
return
this
.
$store
.
state
.
settings
.
theme
},
},
computed
:
{
// 顶部显示菜单
theme
()
{
topMenus
()
{
return
this
.
$store
.
state
.
settings
.
theme
let
topMenus
=
[]
},
this
.
routers
.
map
((
menu
)
=>
{
// 顶部显示菜单
if
(
menu
.
hidden
!==
true
)
{
topMenus
()
{
// 兼容顶部栏一级菜单内部跳转 (you bug)
let
topMenus
=
[]
// if (menu.path === '/') {
this
.
routers
.
map
((
menu
)
=>
{
// topMenus.push(menu.children[0])
if
(
menu
.
hidden
!==
true
)
{
// } else {
// 兼容顶部栏一级菜单内部跳转 (you bug)
// }
// if (menu.path === '/') {
topMenus
.
push
(
menu
)
// topMenus.push(menu.children[0])
// } else {
// }
topMenus
.
push
(
menu
)
}
})
return
topMenus
},
// 所有的路由信息
routers
()
{
return
this
.
$store
.
state
.
permission
.
topbarRouters
},
// 设置子路由
childrenMenus
()
{
var
childrenMenus
=
[]
this
.
routers
.
map
((
router
)
=>
{
for
(
var
item
in
router
.
children
)
{
if
(
router
.
children
[
item
].
parentPath
===
undefined
)
{
if
(
router
.
path
===
'/'
)
{
router
.
children
[
item
].
path
=
router
.
children
[
item
].
path
}
else
{
if
(
!
this
.
ishttp
(
router
.
children
[
item
].
path
))
{
router
.
children
[
item
].
path
=
router
.
path
+
'/'
+
router
.
children
[
item
].
path
}
}
router
.
children
[
item
].
parentPath
=
router
.
path
}
childrenMenus
.
push
(
router
.
children
[
item
])
}
})
return
constantRoutes
.
concat
(
childrenMenus
)
},
// 默认激活的菜单
activeMenu
()
{
const
path
=
this
.
$route
.
path
let
activePath
=
this
.
defaultRouter
()
if
(
path
.
lastIndexOf
(
'/'
)
>
0
)
{
const
tmpPath
=
path
.
substring
(
1
,
path
.
length
)
activePath
=
'/'
+
tmpPath
.
substring
(
0
,
tmpPath
.
indexOf
(
'/'
))
}
// else if ('/index' == path || '' == path) {
// if (!this.isFrist) {
// this.isFrist = true
// activePath = '/index'
// } else {
// activePath = '/index'
// }
// }
var
routes
=
this
.
activeRoutes
(
activePath
)
if
(
routes
.
length
===
0
)
{
activePath
=
path
}
}
return
activePath
})
}
return
topMenus
},
},
beforeMount
()
{
routers
()
{
window
.
addEventListener
(
'resize'
,
this
.
setVisibleNumber
)
return
this
.
$store
.
state
.
permission
.
topbarRouters
},
},
beforeDestroy
()
{
// 默认激活的一级菜单路径 eg:/drainageCode
window
.
removeEventListener
(
'resize'
,
this
.
setVisibleNumber
)
activeMenu
()
{
const
path
=
this
.
$route
.
path
let
activePath
=
this
.
routers
.
filter
((
e
)
=>
!
e
.
hidden
).
path
if
(
path
.
lastIndexOf
(
'/'
)
>
0
)
{
activePath
=
path
.
substring
(
0
,
path
.
indexOf
(
'/'
,
1
))
}
var
routes
=
this
.
activeRoutes
(
activePath
)
if
(
routes
.
length
===
0
)
{
activePath
=
path
}
return
activePath
},
},
mounted
()
{
},
this
.
setVisibleNumber
()
beforeMount
()
{
this
.
setName
()
window
.
addEventListener
(
'resize'
,
this
.
setVisibleNumber
)
// this.handleSelect(this.topMenus[0].path)
},
beforeDestroy
()
{
window
.
removeEventListener
(
'resize'
,
this
.
setVisibleNumber
)
},
mounted
()
{
this
.
setVisibleNumber
()
// this.setName()
// this.handleSelect(this.topMenus[0].path)
},
methods
:
{
// setName() {
// this.topMenus.map((dd) => {
// if (this.activeMenu == dd.path) {
// this.name = dd.meta.title
// }
// })
// },
// 根据宽度计算设置显示栏数
setVisibleNumber
()
{
const
width
=
document
.
body
.
getBoundingClientRect
().
width
/
3
this
.
visibleNumber
=
parseInt
(
width
/
85
)
},
},
methods
:
{
// 菜单选择事件
setName
()
{
handleSelect
(
path
,
keyPath
)
{
this
.
topMenus
.
map
((
dd
)
=>
{
this
.
currentIndex
=
path
if
(
this
.
activeMenu
==
dd
.
path
)
{
let
index
=
''
this
.
name
=
dd
.
meta
.
title
this
.
topMenus
.
map
((
dd
,
cc
)
=>
{
}
if
(
path
==
dd
.
path
)
{
})
// this.name = dd.meta.title
},
index
=
cc
// 根据宽度计算设置显示栏数
setVisibleNumber
()
{
const
width
=
document
.
body
.
getBoundingClientRect
().
width
/
3
this
.
visibleNumber
=
parseInt
(
width
/
85
)
},
// 默认激活的路由
defaultRouter
()
{
let
router
Object
.
keys
(
this
.
routers
).
some
((
key
)
=>
{
if
(
!
this
.
routers
[
key
].
hidden
)
{
router
=
this
.
routers
[
key
].
path
return
true
}
})
return
router
},
// 菜单选择事件
handleSelect
(
path
,
keyPath
)
{
this
.
currentIndex
=
path
let
index
=
''
this
.
topMenus
.
map
((
dd
,
cc
)
=>
{
if
(
path
==
dd
.
path
)
{
this
.
name
=
dd
.
meta
.
title
index
=
cc
}
})
if
(
this
.
ishttp
(
path
))
{
// http(s):// 路径新窗口打开
window
.
open
(
path
,
'_blank'
)
}
else
if
(
path
.
indexOf
(
'/redirect'
)
!==
-
1
)
{
// /redirect 路径内部打开
this
.
$router
.
push
({
path
:
path
.
replace
(
'/redirect'
,
''
)
})
}
else
{
// 显示左侧联动菜单
// if (path === '/index') {
// this.$router.push(path)
// } else {
// }
this
.
activeRoutes
(
path
)
let
obj
=
this
.
topMenus
[
index
]
// let path = this.topMenus[index].children[0].path
// console.log(this.topMenus[index].children[0])
let
path
=
''
if
(
obj
.
children
&&
obj
.
children
.
length
)
{
path
=
path
+
obj
.
children
[
0
].
path
}
if
(
obj
.
children
[
0
].
children
&&
obj
.
children
[
0
].
children
.
length
)
{
path
=
path
+
'/'
+
obj
.
children
[
0
].
children
[
0
].
path
}
if
(
!
isExternal
(
path
))
{
this
.
$router
.
push
({
path
})
}
}
},
// 当前激活的路由
activeRoutes
(
key
)
{
var
routes
=
[]
if
(
this
.
childrenMenus
&&
this
.
childrenMenus
.
length
>
0
)
{
this
.
childrenMenus
.
map
((
item
)
=>
{
if
(
key
==
item
.
parentPath
)
{
routes
.
push
(
item
)
}
})
}
}
if
(
routes
.
length
>
0
)
{
})
this
.
$store
.
commit
(
'SET_SIDEBAR_ROUTERS'
,
routes
)
if
(
this
.
ishttp
(
path
))
{
// http(s):// 路径新窗口打开
window
.
open
(
path
,
'_blank'
)
}
else
if
(
path
.
indexOf
(
'/redirect'
)
!==
-
1
)
{
// /redirect 路径内部打开
this
.
$router
.
push
({
path
:
path
.
replace
(
'/redirect'
,
''
)
})
}
else
{
this
.
activeRoutes
(
path
)
if
(
!
isExternal
(
path
))
{
this
.
$router
.
push
({
path
})
}
}
return
routes
},
ishttp
(
url
)
{
return
url
.
indexOf
(
'http://'
)
!==
-
1
||
url
.
indexOf
(
'https://'
)
!==
-
1
}
}
}
},
}
// 当前激活的路由
activeRoutes
(
path
)
{
let
routes
=
this
.
routers
.
filter
((
e
)
=>
e
.
path
==
path
)
if
(
routes
.
length
>
0
)
{
this
.
$store
.
commit
(
'SET_SIDEBAR_ROUTERS'
,
routes
)
}
return
routes
},
ishttp
(
url
)
{
return
/^
(\/
|http
)
/
.
test
(
url
)
},
},
}
</
script
>
</
script
>
<
style
lang=
"scss"
>
<
style
lang=
"scss"
>
.el-menu
{
.el-menu
{
background-color
:
transparent
!important
;
background-color
:
transparent
!important
;
}
}
.el-menu.el-menu--horizontal
{
.el-menu.el-menu--horizontal
{
border
:
none
!important
;
border
:
none
!important
;
}
}
.el-menu--horizontal
>
.el-menu-item
{
.el-menu--horizontal
>
.el-menu-item
{
float
:
left
;
float
:
left
;
height
:
50px
!important
;
height
:
50px
!important
;
line-height
:
50px
!important
;
line-height
:
50px
!important
;
color
:
#fff
!important
;
color
:
#fff
!important
;
//
padding
:
0
5px
!important
;
//
padding
:
0
5px
!important
;
margin
:
0
10px
!important
;
margin
:
0
10px
!important
;
}
}
.el-menu-item
:hover
{
.el-menu-item
:hover
{
background-color
:
transparent
!important
;
background-color
:
transparent
!important
;
}
}
.el-menu--horizontal
>
.el-menu-item.is-active
,
.el-menu--horizontal
>
.el-menu-item.is-active
,
.el-menu--horizontal
>
.el-submenu.is-active
.el-submenu__title
{
.el-menu--horizontal
>
.el-submenu.is-active
.el-submenu__title
{
border-bottom
:
2px
solid
#fff
!important
;
border-bottom
:
2px
solid
#fff
!important
;
//
color
:
#303133
;
//
color
:
#303133
;
}
}
/* submenu item */
/* submenu item */
.el-menu--horizontal
>
.el-submenu
.el-submenu__title
{
.el-menu--horizontal
>
.el-submenu
.el-submenu__title
{
float
:
left
;
float
:
left
;
height
:
50px
!important
;
height
:
50px
!important
;
line-height
:
50px
!important
;
line-height
:
50px
!important
;
color
:
#999093
!important
;
color
:
#999093
!important
;
padding
:
0
5px
!important
;
padding
:
0
5px
!important
;
margin
:
0
10px
!important
;
margin
:
0
10px
!important
;
}
}
</
style
>
</
style
>
linkwe-pc/src/router/index.js
View file @
afca2e1
...
@@ -30,8 +30,12 @@ import visitor from '@/layout/visitor'
...
@@ -30,8 +30,12 @@ import visitor from '@/layout/visitor'
}
}
*/
*/
// 开发路由,总后台配置完菜单务必删除或注释,只在开发环境生效
export
let
devRoutes
=
[]
const
devRoutes
=
[]
// 开发环境路由,总后台配置完菜单务必删除或注释,只在开发环境生效
if
(
process
.
env
.
VUE_APP_ENV
===
'development'
)
{
devRoutes
=
devRoutes
.
concat
()
}
// 公共路由
// 公共路由
export
const
constantRoutes
=
[
export
const
constantRoutes
=
[
...
@@ -44,26 +48,26 @@ export const constantRoutes = [
...
@@ -44,26 +48,26 @@ export const constantRoutes = [
isNoLogin
:
true
,
isNoLogin
:
true
,
},
},
},
},
{
//
{
path
:
'/drainageCode/qrCode
'
,
// path: '
',
component
:
Layout
,
//
component: Layout,
hidden
:
true
,
//
hidden: true,
meta
:
{
//
meta: {
title
:
'客群活码'
,
//
title: '客群活码',
},
//
},
children
:
[
//
children: [
{
//
{
path
:
'
analyse'
,
// path: '/drainageCode/qrCode/
analyse',
name
:
'group-code-analyse'
,
//
name: 'group-code-analyse',
component
:
(
resolve
)
=>
require
([
'@/views/drainageCode/group/analyse'
],
resolve
),
//
component: (resolve) => require(['@/views/drainageCode/group/analyse'], resolve),
meta
:
{
//
meta: {
title
:
'活码统计'
,
//
title: '活码统计',
activeMenu
:
'/drainageCode/qrCode/customerGroup'
,
//
activeMenu: '/drainageCode/qrCode/customerGroup',
breadcrumb
:
true
,
//
breadcrumb: true,
},
//
},
},
//
},
],
//
],
},
//
},
{
{
path
:
'/redirect'
,
path
:
'/redirect'
,
component
:
Layout
,
component
:
Layout
,
...
...
linkwe-pc/src/store/getters.js
View file @
afca2e1
const
getters
=
{
const
getters
=
{
sidebar
:
state
=>
state
.
app
.
sidebar
,
sidebar
:
(
state
)
=>
state
.
app
.
sidebar
,
size
:
state
=>
state
.
app
.
size
,
size
:
(
state
)
=>
state
.
app
.
size
,
device
:
state
=>
state
.
app
.
device
,
device
:
(
state
)
=>
state
.
app
.
device
,
visitedViews
:
state
=>
state
.
tagsView
.
visitedViews
,
visitedViews
:
(
state
)
=>
state
.
tagsView
.
visitedViews
,
cachedViews
:
state
=>
state
.
tagsView
.
cachedViews
,
cachedViews
:
(
state
)
=>
state
.
tagsView
.
cachedViews
,
token
:
state
=>
state
.
user
.
token
,
token
:
(
state
)
=>
state
.
user
.
token
,
avatar
:
state
=>
state
.
user
.
avatar
,
avatar
:
(
state
)
=>
state
.
user
.
avatar
,
name
:
state
=>
state
.
user
.
name
,
name
:
(
state
)
=>
state
.
user
.
name
,
introduction
:
state
=>
state
.
user
.
introduction
,
introduction
:
(
state
)
=>
state
.
user
.
introduction
,
roles
:
state
=>
state
.
user
.
roles
,
roles
:
(
state
)
=>
state
.
user
.
roles
,
permissions
:
state
=>
state
.
user
.
permissions
,
permissions
:
(
state
)
=>
state
.
user
.
permissions
,
configParamInfo
:
state
=>
state
.
user
.
configParamInfo
,
configParamInfo
:
(
state
)
=>
state
.
user
.
configParamInfo
,
permission_routes
:
state
=>
state
.
permission
.
routes
,
permission_routes
:
(
state
)
=>
state
.
permission
.
routes
,
topbarRouters
:
state
=>
state
.
permission
.
topbarRouters
,
topbarRouters
:
(
state
)
=>
state
.
permission
.
topbarRouters
,
defaultRoutes
:
state
=>
state
.
permission
.
defaultRoutes
,
sidebarRouters
:
(
state
)
=>
state
.
permission
.
sidebarRouters
,
sidebarRouters
:
state
=>
state
.
permission
.
sidebarRouters
,
}
}
export
default
getters
export
default
getters
linkwe-pc/src/store/modules/permission.js
View file @
afca2e1
import
router
,
{
constantRoutes
}
from
'@/router'
import
router
,
{
constantRoutes
,
devRoutes
}
from
'@/router'
import
{
getRouters
}
from
'@/api/menu'
import
{
getRouters
}
from
'@/api/menu'
import
Layout
from
'@/layout/index'
import
Layout
from
'@/layout/index'
import
View
from
'@/layout/components/View'
import
View
from
'@/layout/components/View'
...
@@ -8,9 +8,8 @@ const permission = {
...
@@ -8,9 +8,8 @@ const permission = {
state
:
{
state
:
{
routes
:
[],
routes
:
[],
addRoutes
:
[],
addRoutes
:
[],
defaultRoutes
:
[],
topbarRouters
:
[],
topbarRouters
:
[],
sidebarRouters
:
[],
sidebarRouters
:
[],
// 当前显示的侧边栏菜单,通过topbarRouters筛选当前激活的顶部菜单下的子菜单
},
},
mutations
:
{
mutations
:
{
SET_ROUTES
:
(
state
,
routes
)
=>
{
SET_ROUTES
:
(
state
,
routes
)
=>
{
...
@@ -19,17 +18,8 @@ const permission = {
...
@@ -19,17 +18,8 @@ const permission = {
// 根据roles权限生成可访问的路由表
// 根据roles权限生成可访问的路由表
routes
.
forEach
((
e
)
=>
router
.
addRoute
(
e
))
routes
.
forEach
((
e
)
=>
router
.
addRoute
(
e
))
},
},
SET_DEFAULT_ROUTES
:
(
state
,
routes
)
=>
{
state
.
defaultRoutes
=
constantRoutes
.
concat
(
routes
)
},
SET_TOPBAR_ROUTES
:
(
state
,
routes
)
=>
{
SET_TOPBAR_ROUTES
:
(
state
,
routes
)
=>
{
// 顶部导航菜单默认添加统计报表栏指向首页
state
.
topbarRouters
=
routes
.
concat
(
devRoutes
)
// const index = [{
// path: 'index',
// meta: { title: '统计报表', icon: 'dashboard' }
// }]
// state.topbarRouters = routes.concat(index);
state
.
topbarRouters
=
routes
},
},
SET_SIDEBAR_ROUTERS
:
(
state
,
routes
)
=>
{
SET_SIDEBAR_ROUTERS
:
(
state
,
routes
)
=>
{
state
.
sidebarRouters
=
routes
state
.
sidebarRouters
=
routes
...
@@ -42,11 +32,6 @@ const permission = {
...
@@ -42,11 +32,6 @@ const permission = {
// 向后端请求路由数据
// 向后端请求路由数据
getRouters
()
getRouters
()
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
// const accessedRoutes = filterAsyncRouter(data)
// // 设置为匹配路由重定向404
// accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
// commit('SET_ROUTES', accessedRoutes)
// resolve(accessedRoutes)
if
(
!
data
||
!
data
.
length
)
{
if
(
!
data
||
!
data
.
length
)
{
MessageBox
.
confirm
(
'您的角色菜单权限不足,请联系所在企业管理员'
,
'系统提示'
,
{
MessageBox
.
confirm
(
'您的角色菜单权限不足,请联系所在企业管理员'
,
'系统提示'
,
{
confirmButtonText
:
'重新登录'
,
confirmButtonText
:
'重新登录'
,
...
@@ -59,10 +44,8 @@ const permission = {
...
@@ -59,10 +44,8 @@ const permission = {
})
})
return
reject
()
return
reject
()
}
}
const
sdata
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
const
rdata
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
const
rdata
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
const
sidebarRoutes
=
filterAsyncRouter
(
sdata
)
const
rewriteRoutes
=
filterAsyncRouter
(
rdata
)
const
rewriteRoutes
=
filterAsyncRouter
(
rdata
,
false
,
true
)
// // 设置首页重定向
// // 设置首页重定向
let
indexRoute
=
router
.
getRoutes
().
find
((
e
)
=>
e
.
path
==
''
)
let
indexRoute
=
router
.
getRoutes
().
find
((
e
)
=>
e
.
path
==
''
)
...
@@ -70,9 +53,7 @@ const permission = {
...
@@ -70,9 +53,7 @@ const permission = {
rewriteRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
})
rewriteRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
})
commit
(
'SET_ROUTES'
,
rewriteRoutes
)
commit
(
'SET_ROUTES'
,
rewriteRoutes
)
commit
(
'SET_SIDEBAR_ROUTERS'
,
constantRoutes
.
concat
(
sidebarRoutes
))
commit
(
'SET_TOPBAR_ROUTES'
,
rewriteRoutes
)
commit
(
'SET_DEFAULT_ROUTES'
,
sidebarRoutes
)
commit
(
'SET_TOPBAR_ROUTES'
,
sidebarRoutes
)
resolve
(
rewriteRoutes
)
resolve
(
rewriteRoutes
)
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
...
@@ -84,30 +65,6 @@ const permission = {
...
@@ -84,30 +65,6 @@ const permission = {
},
},
}
}
function
filterChildren
(
childrenMap
,
lastRouter
=
false
)
{
var
children
=
[]
childrenMap
.
forEach
((
el
,
index
)
=>
{
if
(
el
.
children
&&
el
.
children
.
length
)
{
if
(
el
.
component
===
'ParentView'
&&
!
lastRouter
)
{
el
.
children
.
forEach
((
c
)
=>
{
c
.
path
=
el
.
path
+
'/'
+
c
.
path
if
(
c
.
children
&&
c
.
children
.
length
)
{
children
=
children
.
concat
(
filterChildren
(
c
.
children
,
c
))
return
}
children
.
push
(
c
)
})
return
}
}
if
(
lastRouter
)
{
el
.
path
=
lastRouter
.
path
+
'/'
+
el
.
path
}
children
=
children
.
concat
(
el
)
})
return
children
}
// export const loadView = (view) => {
// export const loadView = (view) => {
// if (process.env.NODE_ENV === 'development') {
// if (process.env.NODE_ENV === 'development') {
// return (resolve) => require([`@/views/${view}`], resolve)
// return (resolve) => require([`@/views/${view}`], resolve)
...
@@ -119,20 +76,24 @@ function filterChildren(childrenMap, lastRouter = false) {
...
@@ -119,20 +76,24 @@ function filterChildren(childrenMap, lastRouter = false) {
// // 遍历后台传来的路由字符串,转换为组件对象
// // 遍历后台传来的路由字符串,转换为组件对象
let
level
=
0
let
level
=
0
function
filterAsyncRouter
(
asyncRouterMap
)
{
function
filterAsyncRouter
(
asyncRouterMap
,
parentPath
)
{
level
++
level
++
let
res
=
asyncRouterMap
.
filter
((
route
)
=>
{
let
res
=
asyncRouterMap
.
filter
((
route
)
=>
{
route
.
meta
=
route
.
meta
||
{}
route
.
meta
=
route
.
meta
||
{}
route
.
meta
.
hidden
=
route
.
hidden
route
.
meta
.
hidden
=
route
.
hidden
if
(
parentPath
)
{
let
path
=
route
.
path
route
.
path
=
/^
(\/
|http
)
/
.
test
(
path
)
?
path
:
parentPath
+
'/'
+
path
}
if
(
route
.
component
)
{
if
(
route
.
component
)
{
// Layout组件特殊处理
// Layout组件特殊处理
if
(
route
.
redirect
===
'noRedirect'
&&
route
.
children
.
length
)
{
let
firstChildPath
=
route
.
children
[
0
].
path
route
.
redirect
=
firstChildPath
.
startsWith
(
'/'
)
?
firstChildPath
:
route
.
path
+
'/'
+
firstChildPath
}
if
(
route
.
component
===
'Layout'
)
{
if
(
route
.
component
===
'Layout'
)
{
if
(
route
.
redirect
===
'noRedirect'
&&
route
.
children
.
length
)
{
let
firstChildPath
=
route
.
children
[
0
].
path
route
.
redirect
=
firstChildPath
.
startsWith
(
'/'
)
?
firstChildPath
:
route
.
path
+
'/'
+
firstChildPath
}
if
(
level
!=
1
)
{
if
(
level
!=
1
)
{
route
.
component
=
View
route
.
component
=
View
}
else
{
}
else
{
...
@@ -142,8 +103,9 @@ function filterAsyncRouter(asyncRouterMap) {
...
@@ -142,8 +103,9 @@ function filterAsyncRouter(asyncRouterMap) {
route
.
component
=
loadView
(
route
.
component
)
route
.
component
=
loadView
(
route
.
component
)
}
}
}
}
if
(
route
.
children
!=
null
&&
route
.
children
&&
route
.
children
.
length
)
{
let
children
=
route
.
children
route
.
children
=
filterAsyncRouter
(
route
.
children
)
if
(
children
&&
children
.
length
)
{
route
.
children
=
filterAsyncRouter
(
route
.
children
,
route
.
path
)
}
}
return
true
return
true
})
})
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment