refactor: 为路由设置roles
This commit is contained in:
parent
db635a2c6f
commit
a487a1f2aa
|
@ -35,7 +35,8 @@
|
|||
<font-awesome-icon class="icon" :icon="['far', 'user']" size="lg"/>
|
||||
<span>{{ $t('commons.personal_info') }}</span>
|
||||
</template>
|
||||
<el-menu-item v-for="menu in persons" :key="menu.index" :index="menu.index" class="setting-item">
|
||||
<el-menu-item v-for="menu in persons" :key="menu.index" :index="menu.index" class="setting-item"
|
||||
v-permission="menu.roles">
|
||||
{{ $t(menu.title) }}
|
||||
</el-menu-item>
|
||||
</el-submenu>
|
||||
|
@ -56,6 +57,7 @@ export default {
|
|||
if (child.meta[group] === true) {
|
||||
let menu = {index: Setting.path + "/" + child.path}
|
||||
menu.title = child.meta.title;
|
||||
menu.roles = child.meta.roles;
|
||||
menus.push(menu);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -67,7 +67,11 @@ export default {
|
|||
{
|
||||
path: 'apikeys',
|
||||
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/personal/ApiKeys'),
|
||||
meta: {person: true, title: 'commons.api_keys'}
|
||||
meta: {
|
||||
person: true,
|
||||
title: 'commons.api_keys',
|
||||
roles: ['test_manager', 'test_user', 'test_viewer', 'org_admin', 'admin']
|
||||
}
|
||||
},
|
||||
|
||||
]
|
||||
|
|
|
@ -32,7 +32,7 @@ function checkRolePermission(el, binding, type) {
|
|||
el.parentNode && el.parentNode.removeChild(el)
|
||||
}
|
||||
} else {
|
||||
throw new Error(`need roles! Like v-permission="['admin','editor']"`)
|
||||
// throw new Error(`need roles! Like v-permission="['admin','editor']"`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue