Merge a61e652b52
into 33a93a12b4
This commit is contained in:
commit
4c6803c767
|
@ -1,21 +1,18 @@
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array} value
|
* @param {Array} permissionRoles
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
* @example see @/views/permission/directive.vue
|
* @example see @/views/permission/directive.vue
|
||||||
*/
|
*/
|
||||||
export default function checkPermission(value) {
|
export default function checkPermission(permissionRoles) {
|
||||||
if (value && value instanceof Array && value.length > 0) {
|
if (permissionRoles && Array.isArray(permissionRoles) && permissionRoles.length > 0) {
|
||||||
const roles = store.getters && store.getters.roles
|
const roles = store.getters && store.getters.roles
|
||||||
const permissionRoles = value
|
|
||||||
|
|
||||||
const hasPermission = roles.some(role => {
|
// has permission
|
||||||
return permissionRoles.includes(role)
|
return roles.some(role => permissionRoles.includes(role))
|
||||||
})
|
}
|
||||||
return hasPermission
|
|
||||||
} else {
|
|
||||||
console.error(`need roles! Like v-permission="['admin','editor']"`)
|
console.error(`need roles! Like v-permission="['admin','editor']"`)
|
||||||
return false
|
return false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,8 @@ service.interceptors.response.use(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return Promise.reject(new Error(res.message || 'Error'))
|
return Promise.reject(new Error(res.message || 'Error'))
|
||||||
} else {
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
return res
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
console.log('err' + error) // for debug
|
console.log('err' + error) // for debug
|
||||||
|
|
Loading…
Reference in New Issue