mod:修改路由判断角色权限的写法
This commit is contained in:
parent
044ab5ea4c
commit
9b4a1d223d
@ -1,13 +1,12 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { asyncRoutes, basicRoutes } from '@/router/routes'
|
import { asyncRoutes, basicRoutes } from '@/router/routes'
|
||||||
import { difference } from 'lodash-es'
|
|
||||||
|
|
||||||
function hasPermission(route, role) {
|
function hasPermission(route, role) {
|
||||||
const routeRole = route.meta?.role ? route.meta.role : []
|
const routeRole = route.meta?.role ? route.meta.role : []
|
||||||
if (!role.length || !routeRole.length) {
|
if (!role.length || !routeRole.length) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return difference(routeRole, role).length < routeRole.length
|
return role.some((item) => routeRole.includes(item))
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterAsyncRoutes(routes = [], role) {
|
function filterAsyncRoutes(routes = [], role) {
|
||||||
|
Loading…
Reference in New Issue
Block a user