import { router } from '@/router'
|
function checkAuthPermission(el, binding) {
|
const authList = router.currentRoute.value.meta.authList || []
|
const hasPermission = authList.some((item) => item.authMark === binding.value)
|
if (!hasPermission) {
|
removeElement(el)
|
}
|
}
|
function removeElement(el) {
|
if (el.parentNode) {
|
el.parentNode.removeChild(el)
|
}
|
}
|
const authDirective = {
|
mounted: checkAuthPermission,
|
updated: checkAuthPermission
|
}
|
function setupAuthDirective(app) {
|
app.directive('auth', authDirective)
|
}
|
export { setupAuthDirective }
|