75 lines
1.5 KiB
Vue
75 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
import { InboxOutlined, SearchOutlined, LockOutlined } from '@ant-design/icons-vue'
|
|
|
|
interface Props {
|
|
type?: 'empty' | 'search' | 'permission'
|
|
title?: string
|
|
description?: string
|
|
actionText?: string
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
type: 'empty'
|
|
})
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'action'): void
|
|
}>()
|
|
|
|
const iconMap = {
|
|
empty: InboxOutlined,
|
|
search: SearchOutlined,
|
|
permission: LockOutlined
|
|
}
|
|
|
|
const currentIcon = computed(() => iconMap[props.type!] || InboxOutlined)
|
|
</script>
|
|
|
|
<template>
|
|
<div class="empty-state">
|
|
<div class="empty-icon">
|
|
<component :is="currentIcon" />
|
|
</div>
|
|
<div class="empty-title">{{ title }}</div>
|
|
<div v-if="description" class="empty-description">{{ description }}</div>
|
|
<a-button
|
|
v-if="actionText"
|
|
type="primary"
|
|
@click="emit('action')"
|
|
>
|
|
{{ actionText }}
|
|
</a-button>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.empty-state {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 48px 24px;
|
|
text-align: center;
|
|
}
|
|
|
|
.empty-icon {
|
|
font-size: 48px;
|
|
color: var(--color-text-disabled, #d9d9d9);
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.empty-title {
|
|
font-size: 16px;
|
|
color: var(--color-text, #262626);
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.empty-description {
|
|
font-size: 14px;
|
|
color: var(--color-text-placeholder, #8c8c8c);
|
|
margin-bottom: 24px;
|
|
max-width: 300px;
|
|
}
|
|
</style>
|