# 优化权限逻辑
This commit is contained in:
parent
2cc2c2aa6a
commit
5b2f7d7c9d
|
@ -1,4 +1,4 @@
|
|||
import { param2Obj } from '@/utils'
|
||||
import { param2Obj } from '@/utils'
|
||||
|
||||
const userMap = {
|
||||
admin: {
|
||||
|
|
|
@ -131,6 +131,7 @@ export const asyncRouterMap = [
|
|||
{
|
||||
path: '/settings/system',
|
||||
component: Layout,
|
||||
meta: { roles: ['admin'] },
|
||||
children: [{
|
||||
path: 'index',
|
||||
component: () => import('@/views/settings/system'),
|
||||
|
|
|
@ -14,6 +14,7 @@ export default {
|
|||
components: { adminDashboard, editorDashboard },
|
||||
data() {
|
||||
return {
|
||||
allowRoles: ['admin', 'customer'],
|
||||
currentRole: 'adminDashboard'
|
||||
}
|
||||
},
|
||||
|
@ -23,7 +24,11 @@ export default {
|
|||
])
|
||||
},
|
||||
created() {
|
||||
if (!this.roles.includes('admin')) {
|
||||
const adminDashboardRoles = new Set(['admin', 'customer'])
|
||||
const userRoles = new Set(this.roles)
|
||||
const intersection = new Set([...userRoles].filter(role => adminDashboardRoles.has(role)))
|
||||
console.log(intersection.size)
|
||||
if (intersection.size === 0) {
|
||||
this.currentRole = 'editorDashboard'
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue