mp-empty.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <script setup>
  2. /**
  3. * 全局空态(方案 B · 插画文件夹)
  4. * 用法:
  5. * <mp-empty title="暂无产品分类" description="可先新增一个顶级分类" action-text="新增分类" @action="goAdd" />
  6. * <mp-empty title="暂无线索" />
  7. * <mp-empty compact title="暂无跟进" />
  8. */
  9. defineProps({
  10. /** 主文案 */
  11. title: { type: String, default: '暂无数据' },
  12. /** 辅助说明,可选 */
  13. description: { type: String, default: '' },
  14. /** 主按钮文案;空则不展示按钮 */
  15. actionText: { type: String, default: '' },
  16. /** 次要按钮文案,可选 */
  17. secondaryText: { type: String, default: '' },
  18. /** 详情内嵌等紧凑场景 */
  19. compact: { type: Boolean, default: false }
  20. })
  21. const emit = defineEmits(['action', 'secondary'])
  22. </script>
  23. <template>
  24. <view class="mp-empty" :class="{ 'mp-empty--compact': compact }">
  25. <view class="mp-empty__art" aria-hidden="true">
  26. <view class="mp-empty__shadow" />
  27. <view class="mp-empty__folder">
  28. <view class="mp-empty__folder-tab" />
  29. <view class="mp-empty__folder-back" />
  30. <view class="mp-empty__folder-front">
  31. <view class="mp-empty__lines">
  32. <view class="mp-empty__line" />
  33. <view class="mp-empty__line mp-empty__line--mid" />
  34. <view class="mp-empty__line mp-empty__line--short" />
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <text class="mp-empty__title">{{ title }}</text>
  40. <text v-if="description" class="mp-empty__desc">{{ description }}</text>
  41. <view v-if="actionText || secondaryText" class="mp-empty__actions">
  42. <view
  43. v-if="secondaryText"
  44. class="mp-btn mp-btn--ghost"
  45. @click="emit('secondary')"
  46. >
  47. {{ secondaryText }}
  48. </view>
  49. <view
  50. v-if="actionText"
  51. class="mp-btn mp-btn--primary"
  52. @click="emit('action')"
  53. >
  54. {{ actionText }}
  55. </view>
  56. </view>
  57. </view>
  58. </template>