diff --git a/src/components/Auth/index.vue b/src/components/Auth/index.vue
old mode 100644
new mode 100755
index a25fe087..369fd05c
--- a/src/components/Auth/index.vue
+++ b/src/components/Auth/index.vue
@@ -5,16 +5,19 @@ defineOptions({
const props = defineProps<{
value: string | string[]
+ all?: boolean
}>()
+const auth = useAuth()
+
function check() {
- return useAuth().auth(props.value)
+ return props.all
+ ? auth.authAll(typeof props.value === 'string' ? [props.value] : props.value)
+ : auth.auth(props.value)
}
-
-
-
-
+
+
diff --git a/src/components/AuthAll/index.vue b/src/components/AuthAll/index.vue
deleted file mode 100644
index 3c0f36ec..00000000
--- a/src/components/AuthAll/index.vue
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/src/types/components.d.ts b/src/types/components.d.ts
index 6f1c9042..42b5582b 100644
--- a/src/types/components.d.ts
+++ b/src/types/components.d.ts
@@ -9,7 +9,6 @@ declare module 'vue' {
export interface GlobalComponents {
ActionContainer: typeof import('./../components/ActionContainer/index.vue')['default']
Auth: typeof import('./../components/Auth/index.vue')['default']
- AuthAll: typeof import('./../components/AuthAll/index.vue')['default']
ComponentBasicExampleAlert: typeof import('./../components/ComponentBasicExampleAlert/index.vue')['default']
FileUpload: typeof import('./../components/FileUpload/index.vue')['default']
HBadge: typeof import('./../views/ui-kit/HBadge.vue')['default']
diff --git a/src/utils/directive.ts b/src/utils/directive.ts
index bbd2481a..93d4df78 100644
--- a/src/utils/directive.ts
+++ b/src/utils/directive.ts
@@ -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'
+ }
})
}
diff --git a/src/views/windows/PermissionExample/index.vue b/src/views/windows/PermissionExample/index.vue
index bdb47d4d..2687f69c 100644
--- a/src/views/windows/PermissionExample/index.vue
+++ b/src/views/windows/PermissionExample/index.vue
@@ -1,26 +1,19 @@