diff --git a/src/utils/permission.js b/src/utils/permission.js index 8e2bbada..53d27ac8 100644 --- a/src/utils/permission.js +++ b/src/utils/permission.js @@ -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 { - console.error(`need roles! Like v-permission="['admin','editor']"`) - return false + // has permission + return roles.some(role => permissionRoles.includes(role)) } + + console.error(`need roles! Like v-permission="['admin','editor']"`) + return false } diff --git a/src/utils/request.js b/src/utils/request.js index 2fb95ac0..de2131bf 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -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