2023-06-27 15:53:29 +08:00
|
|
|
<script setup>
|
|
|
|
import { computed } from 'vue'
|
|
|
|
import { NIcon } from 'naive-ui'
|
|
|
|
|
|
|
|
const emit = defineEmits(['click'])
|
|
|
|
|
|
|
|
const props = defineProps({
|
2023-07-02 12:33:41 +08:00
|
|
|
tooltip: String,
|
|
|
|
tTooltip: String,
|
|
|
|
icon: [String, Object],
|
2023-06-27 15:53:29 +08:00
|
|
|
size: {
|
|
|
|
type: [Number, String],
|
|
|
|
default: 20,
|
|
|
|
},
|
|
|
|
color: {
|
|
|
|
type: String,
|
2023-10-28 22:42:15 +08:00
|
|
|
default: '',
|
2023-06-27 15:53:29 +08:00
|
|
|
},
|
|
|
|
strokeWidth: {
|
|
|
|
type: [Number, String],
|
|
|
|
default: 3,
|
|
|
|
},
|
2023-10-20 18:22:22 +08:00
|
|
|
loading: Boolean,
|
2023-07-03 17:53:28 +08:00
|
|
|
border: Boolean,
|
2023-07-02 12:33:41 +08:00
|
|
|
disabled: Boolean,
|
|
|
|
})
|
|
|
|
|
2023-06-27 15:53:29 +08:00
|
|
|
const hasTooltip = computed(() => {
|
|
|
|
return props.tooltip || props.tTooltip
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-10-20 18:22:22 +08:00
|
|
|
<n-tooltip v-if="hasTooltip" :show-arrow="false">
|
2023-06-27 15:53:29 +08:00
|
|
|
<template #trigger>
|
2023-10-20 18:22:22 +08:00
|
|
|
<n-button
|
|
|
|
:disabled="disabled"
|
|
|
|
:focusable="false"
|
|
|
|
:loading="loading"
|
|
|
|
:text="!border"
|
2023-10-28 22:42:15 +08:00
|
|
|
:color="props.color"
|
2023-10-20 18:22:22 +08:00
|
|
|
@click.prevent="emit('click')">
|
|
|
|
<template #icon>
|
2023-10-28 22:42:15 +08:00
|
|
|
<n-icon :color="props.color || 'currentColor'" :size="props.size">
|
2023-10-20 18:22:22 +08:00
|
|
|
<component :is="props.icon" :stroke-width="props.strokeWidth" />
|
|
|
|
</n-icon>
|
|
|
|
</template>
|
2023-07-02 12:33:41 +08:00
|
|
|
</n-button>
|
2023-06-27 15:53:29 +08:00
|
|
|
</template>
|
|
|
|
{{ props.tTooltip ? $t(props.tTooltip) : props.tooltip }}
|
|
|
|
</n-tooltip>
|
2023-10-20 18:22:22 +08:00
|
|
|
<n-button
|
|
|
|
v-else
|
|
|
|
:disabled="disabled"
|
|
|
|
:focusable="false"
|
|
|
|
:loading="loading"
|
|
|
|
:text="!border"
|
2023-10-28 22:42:15 +08:00
|
|
|
:color="props.color"
|
2023-10-20 18:22:22 +08:00
|
|
|
@click.prevent="emit('click')">
|
|
|
|
<template #icon>
|
2023-10-28 22:42:15 +08:00
|
|
|
<n-icon :color="props.color || 'currentColor'" :size="props.size">
|
2023-10-20 18:22:22 +08:00
|
|
|
<component :is="props.icon" :stroke-width="props.strokeWidth" />
|
|
|
|
</n-icon>
|
|
|
|
</template>
|
2023-07-02 12:33:41 +08:00
|
|
|
</n-button>
|
2023-06-27 15:53:29 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss"></style>
|