import { useUserStore } from '@/stores/user'
import type { App } from 'vue'

export default {
  install(app: App) {
    const userStore = useUserStore()

    app.directive('permission', {
      // 指令的定义
      mounted(el, binding) {
        if (userStore.hasPermission(binding.value)) {
          return
        } else {
          el.parentNode && el.parentNode.removeChild(el)
        }
      }
    })
  }
}
