mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 17:18:04 +08:00
重构鉴权指令、鉴权组件
This commit is contained in:
+8
-15
@@ -1,19 +1,12 @@
|
||||
import type { App } from 'vue'
|
||||
import type { App, DirectiveBinding } from 'vue'
|
||||
|
||||
export default function directive(app: App) {
|
||||
// 注册 v-auth 和 v-auth-all 指令
|
||||
app.directive('auth', {
|
||||
mounted: (el, binding) => {
|
||||
if (!useAuth().auth(binding.value)) {
|
||||
el.remove()
|
||||
}
|
||||
},
|
||||
})
|
||||
app.directive('auth-all', {
|
||||
mounted: (el, binding) => {
|
||||
if (!useAuth().authAll(binding.value)) {
|
||||
el.remove()
|
||||
}
|
||||
},
|
||||
app.directive('auth', (el: HTMLElement, binding: DirectiveBinding) => {
|
||||
if (binding.modifiers.all ? useAuth().authAll(binding.value) : useAuth().auth(binding.value)) {
|
||||
el.style.display = ''
|
||||
}
|
||||
else {
|
||||
el.style.display = 'none'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user