Files
basic/src/utils/directive.ts
T
2025-01-24 11:44:38 +08:00

12 lines
376 B
TypeScript
Executable File

import type { App, DirectiveBinding } from 'vue'
export default function directive(app: App) {
app.directive('auth', (el: HTMLElement, binding: DirectiveBinding) => {
watch(() => binding.modifiers.all ? useAuth().authAll(binding.value) : useAuth().auth(binding.value), (val) => {
el.style.display = val ? '' : 'none'
}, {
immediate: true,
})
})
}