mod:修改路由判断角色权限的写法

This commit is contained in:
zhangchuanlong 2022-01-25 15:21:55 +08:00
parent 044ab5ea4c
commit 9b4a1d223d

View File

@ -1,13 +1,12 @@
import { defineStore } from 'pinia'
import { asyncRoutes, basicRoutes } from '@/router/routes'
import { difference } from 'lodash-es'
function hasPermission(route, role) {
const routeRole = route.meta?.role ? route.meta.role : []
if (!role.length || !routeRole.length) {
return false
}
return difference(routeRole, role).length < routeRole.length
return role.some((item) => routeRole.includes(item))
}
function filterAsyncRoutes(routes = [], role) {