index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div class="go-items-list-card">
  3. <n-card hoverable size="small">
  4. <div class="list-content">
  5. <!-- 顶部按钮 -->
  6. <n-space class="list-content-top">
  7. <AppleControlBtn @close="deleteHanlde" />
  8. </n-space>
  9. <!-- 中间 -->
  10. <div class="list-content-img">
  11. <n-image
  12. object-fit="contain"
  13. height="200"
  14. :src="requireUrl('.', '20211219181327.png')"
  15. :alt="CardData.title"
  16. />
  17. </div>
  18. </div>
  19. <template #action>
  20. <Skeleton v-if="loading" :loading="loading" text round size="small" />
  21. <n-space v-else justify="space-between">
  22. <n-text>
  23. {{ CardData.title || '' }}
  24. </n-text>
  25. <!-- 工具 -->
  26. <n-space>
  27. <n-text>
  28. <n-badge class="animation-twinkle" dot :color="CardData.release ? '#34c749' : '#fcbc40'" />
  29. {{ CardData.release ? '已发布' : '未发布' }}
  30. </n-text>
  31. <template v-for="item in fnBtnList" :key="item.key">
  32. <template v-if="item.key === 'select'">
  33. <n-dropdown
  34. trigger="hover"
  35. placement="bottom-start"
  36. :options="selectOptions"
  37. :show-arrow="true"
  38. @select="handleSelect"
  39. >
  40. <n-button size="small">
  41. <template #icon>
  42. <component :is="item.icon" />
  43. </template>
  44. </n-button>
  45. </n-dropdown>
  46. </template>
  47. <n-button v-else size="small">
  48. <template #icon>
  49. <component :is="item.icon" />
  50. </template>
  51. </n-button>
  52. </template>
  53. </n-space>
  54. <!-- end -->
  55. </n-space>
  56. </template>
  57. </n-card>
  58. </div>
  59. </template>
  60. <script setup lang="ts">
  61. import { ref } from 'vue'
  62. import { renderIcon, goDialog } from '@/utils/index'
  63. import { icon } from '@/plugins'
  64. import { AppleControlBtn } from '@/components/AppleControlBtn'
  65. import { useMessage, useDialog } from 'naive-ui'
  66. const {
  67. EllipsisHorizontalCircleSharpIcon,
  68. CopyIcon,
  69. TrashIcon,
  70. PencilIcon,
  71. ApertureSharpIcon,
  72. DownloadIcon
  73. } = icon.ionicons5
  74. const loading = ref<boolean>(true)
  75. const dialog = useDialog()
  76. const message = useMessage()
  77. defineProps({
  78. CardData: Object
  79. })
  80. const fnBtnList = [
  81. {
  82. lable: '更多',
  83. key: 'select',
  84. icon: renderIcon(EllipsisHorizontalCircleSharpIcon)
  85. }
  86. ]
  87. const selectOptions = [
  88. {
  89. label: '预览',
  90. key: 'preview',
  91. icon: renderIcon(ApertureSharpIcon)
  92. },
  93. {
  94. label: '复制',
  95. key: 'copy',
  96. icon: renderIcon(CopyIcon)
  97. },
  98. {
  99. label: '重命名',
  100. key: 'rename',
  101. icon: renderIcon(PencilIcon)
  102. },
  103. {
  104. label: '下载',
  105. key: 'download',
  106. icon: renderIcon(DownloadIcon)
  107. },
  108. {
  109. type: 'divider',
  110. key: 'd1'
  111. },
  112. {
  113. label: '删除',
  114. key: 'delete',
  115. icon: renderIcon(TrashIcon)
  116. }
  117. ]
  118. const handleSelect = (key: string) => {
  119. console.log(key)
  120. }
  121. const requireUrl = (path: string, name: string) => {
  122. return new URL(`${path}/${name}`, import.meta.url).href
  123. }
  124. const deleteHanlde = () => {
  125. goDialog(dialog.warning, {
  126. type: 'delete',
  127. onPositiveCallback: () => {
  128. message.success('确定')
  129. }
  130. })
  131. }
  132. setTimeout(() => {
  133. loading.value = false
  134. }, 1500)
  135. </script>
  136. <style lang="scss" scoped>
  137. $contentHeight: 200px;
  138. @include go('items-list-card') {
  139. position: relative;
  140. .list-content {
  141. margin-top: 20px;
  142. margin-bottom: 5px;
  143. border-radius: $--border-radius-base;
  144. @include background-point('background-point');
  145. @extend .go-point-bg;
  146. &-top {
  147. position: absolute;
  148. top: 5px;
  149. left: 10px;
  150. height: 22px;
  151. }
  152. &-img {
  153. height: $contentHeight;
  154. @extend .go-flex-center;
  155. @extend .go-border-radius;
  156. @include deep() {
  157. img {
  158. @extend .go-border-radius;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. </style>