Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 229f133

Browse files
committed
feat(aside): routes rendering with meta.title
仅当存在 meta.title 且 meta.hidden 为 falsy 值时才会将该路由加入侧栏渲染
1 parent 3fec701 commit 229f133

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/layout/Material/Aside/Item.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<template>
2-
<div class="recursive__list__item">
2+
<!-- Component default behavior: route rendering when route has a title value
3+
and no hidden setting. -->
4+
<div
5+
class="recursive__list__item"
6+
v-if="!route.meta.hidden && route.meta.title"
7+
>
38

4-
<!-- route without child route -->
9+
<!-- route rendering without child route -->
510
<template v-if="!route.children">
611
<el-menu-item
712
:index="resolvePath(route.path)"
813
>{{route.meta.title}}</el-menu-item>
914
</template>
1015

11-
<!-- route with child route: recursive area -->
16+
<!-- route rendering with child route: recursive area -->
1217
<el-submenu
1318
v-else
1419
:index="route.path"

src/router/routes/constant.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
import { constantComponents, plainExport } from 'ROUTER/components'
22
import permission from 'PERMISSION/roles-map'
33

4+
/**
5+
* meta: {
6+
* title: 'route title', // Route will be hidden if meta.title is falsy value
7+
* icon: '', // title text icon name
8+
* layout: '', // layout name, 'plain' or 'material'(default value)
9+
* roles: ['admin', 'user'] // current route access
10+
* }
11+
*/
412
export default [
513
{
614
path: '/',
7-
redirect: '/home',
8-
meta: {
9-
hidden: true
10-
}
15+
redirect: '/home'
1116
},
1217
{
1318
path: '/home',
1419
name: 'home',
15-
component: constantComponents.pagesHome,
16-
meta: {
17-
title: 'Home'
18-
}
20+
component: constantComponents.pagesHome
1921
},
2022
{
2123
path: '/login',
2224
name: 'login',
2325
component: constantComponents.pagesLogin,
2426
meta: {
25-
title: 'Login',
2627
layout: 'plain'
2728
}
2829
},
@@ -69,16 +70,10 @@ export default [
6970
},
7071
{
7172
path: '/403',
72-
component: constantComponents.pagesErrorUnauthorized,
73-
meta: {
74-
title: 'Unauthorized'
75-
}
73+
component: constantComponents.pagesErrorUnauthorized
7674
},
7775
{
7876
path: '/404',
79-
component: constantComponents.pagesErrorNotFound,
80-
meta: {
81-
title: 'NotFound'
82-
}
77+
component: constantComponents.pagesErrorNotFound
8378
}
8479
]

0 commit comments

Comments
 (0)