1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-04-06 03:57:53 +08:00

Merge a61e652b52aef5ebc9504a769af8be202da4bd40 into 6858a9ad67483025f6a9432a926beb9327037be3

This commit is contained in:
Edwin Betancourt 2024-11-28 00:29:01 +00:00 committed by GitHub
commit 02154ba20c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 13 deletions

View File

@ -1,21 +1,18 @@
import store from '@/store'
/**
* @param {Array} value
* @param {Array} permissionRoles
* @returns {Boolean}
* @example see @/views/permission/directive.vue
*/
export default function checkPermission(value) {
if (value && value instanceof Array && value.length > 0) {
export default function checkPermission(permissionRoles) {
if (permissionRoles && Array.isArray(permissionRoles) && permissionRoles.length > 0) {
const roles = store.getters && store.getters.roles
const permissionRoles = value
const hasPermission = roles.some(role => {
return permissionRoles.includes(role)
})
return hasPermission
} else {
// has permission
return roles.some(role => permissionRoles.includes(role))
}
console.error(`need roles! Like v-permission="['admin','editor']"`)
return false
}
}

View File

@ -67,9 +67,8 @@ service.interceptors.response.use(
})
}
return Promise.reject(new Error(res.message || 'Error'))
} else {
return res
}
return res
},
error => {
console.log('err' + error) // for debug