zhou zhou
19 小时以前 46d872c1a5b77aa8799de4a64888a0a24a1422d6
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 }