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