zhou zhou
昨天 40905cbd04c2e332cd4bc2b9e0c5b3e1da9cccfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 }