permission.js 517 B

1234567891011121314151617181920
  1. import store from '@/store'
  2. /**
  3. * @author chuzhixin 1204505056@qq.com (不想保留author可删除)
  4. * @description 检查权限
  5. * @param value
  6. * @returns {boolean}
  7. */
  8. export default function checkPermission(value) {
  9. if (value && value instanceof Array && value.length > 0) {
  10. const permissions = store.getters['user/permissions']
  11. const permissionPermissions = value
  12. return permissions.some((role) => {
  13. return permissionPermissions.includes(role)
  14. })
  15. } else {
  16. return false
  17. }
  18. }