zhengyiming
2025-02-14 aec795ff58c4b76007f85aa95c734a8dfce83fe1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<template>
  <nut-button v-if="props.access" v-bind="omitAttrs" :open-type="attrs['open-type']">
    <template v-for="(item, key, i) in $slots" :key="i" v-slot:[key]>
      <slot :name="key"></slot>
    </template>
  </nut-button>
  <nut-button v-else v-bind="omitAttrs" @click="emit('noAccess')">
    <template v-for="(item, key, i) in $slots" :key="i" v-slot:[key]>
      <slot :name="key"></slot>
    </template>
  </nut-button>
</template>
 
<script setup lang="ts">
import _ from 'lodash';
import { useAttrs, computed } from 'vue';
 
defineOptions({
  name: 'AccessOpenTypeButton',
  inheritAttrs: false,
});
 
const props = defineProps<{
  access?: boolean;
}>();
 
const emit = defineEmits<{
  (e: 'noAccess'): void;
}>();
 
const attrs = useAttrs();
 
const omitAttrs = computed(() => _.omit(attrs, ['open-type']));
</script>