Showing
1 changed file
with
35 additions
and
36 deletions
1 | -<script lang="ts" setup> | ||
2 | - import { Icon } from '/@/components/Icon'; | ||
3 | - import { computed, ExtractPropTypes, unref } from 'vue'; | ||
4 | - import { usePermission } from '/@/hooks/web/usePermission'; | ||
5 | - | ||
6 | - interface AuthIconProps extends ExtractPropTypes<typeof Icon> { | ||
7 | - auth?: string; | ||
8 | - } | ||
9 | - | ||
10 | - const props = defineProps<AuthIconProps>(); | ||
11 | - | ||
12 | - const emit = defineEmits(['click']); | ||
13 | - | ||
14 | - const { hasPermission } = usePermission(); | ||
15 | - | ||
16 | - const getHasPermission = computed(() => { | ||
17 | - const { auth } = props; | ||
18 | - console.log(auth); | ||
19 | - return auth ? hasPermission(auth) : true; | ||
20 | - }); | ||
21 | - | ||
22 | - const getBindProps = computed(() => { | ||
23 | - return { | ||
24 | - ...props, | ||
25 | - ...(unref(getHasPermission) ? { onClick: (event: Event) => emit('click', event) } : {}), | ||
26 | - }; | ||
27 | - }); | ||
28 | -</script> | ||
29 | - | ||
30 | -<template> | ||
31 | - <Icon | ||
32 | - v-bind="getBindProps" | ||
33 | - class="justify-center items-center" | ||
34 | - :class="getHasPermission ? '' : '!cursor-not-allowed !text-gray-200'" | ||
35 | - /> | ||
36 | -</template> | 1 | +<script lang="ts" setup> |
2 | + import { Icon } from '/@/components/Icon'; | ||
3 | + import { computed, ExtractPropTypes, unref } from 'vue'; | ||
4 | + import { usePermission } from '/@/hooks/web/usePermission'; | ||
5 | + | ||
6 | + interface AuthIconProps extends ExtractPropTypes<typeof Icon> { | ||
7 | + auth?: string; | ||
8 | + } | ||
9 | + | ||
10 | + const props = defineProps<AuthIconProps>(); | ||
11 | + | ||
12 | + const emit = defineEmits(['click']); | ||
13 | + | ||
14 | + const { hasPermission } = usePermission(); | ||
15 | + | ||
16 | + const getHasPermission = computed(() => { | ||
17 | + const { auth } = props; | ||
18 | + return auth ? hasPermission(auth) : true; | ||
19 | + }); | ||
20 | + | ||
21 | + const getBindProps = computed(() => { | ||
22 | + return { | ||
23 | + ...props, | ||
24 | + ...(unref(getHasPermission) ? { onClick: (event: Event) => emit('click', event) } : {}), | ||
25 | + }; | ||
26 | + }); | ||
27 | +</script> | ||
28 | + | ||
29 | +<template> | ||
30 | + <Icon | ||
31 | + v-bind="getBindProps" | ||
32 | + class="justify-center items-center" | ||
33 | + :class="getHasPermission ? '' : '!cursor-not-allowed !text-gray-200'" | ||
34 | + /> | ||
35 | +</template> |