index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <!-- mask-closable 暂时是失效的,不知道为啥 -->
  3. <n-modal
  4. class="go-modal-box"
  5. v-model:show="show"
  6. @on-after-leave="closeHandle"
  7. >
  8. <n-card hoverable size="small">
  9. <div class="list-content">
  10. <!-- 标题 -->
  11. <n-space class="list-content-top go-px-0" justify="center">
  12. <n-space>
  13. <n-text>
  14. {{ cardData?.title || '' }}
  15. </n-text>
  16. </n-space>
  17. </n-space>
  18. <!-- 顶部按钮 -->
  19. <n-space class="list-content-top">
  20. <AppleControlBtn
  21. :narrow="true"
  22. :hidden="['close']"
  23. @remove="closeHandle"
  24. />
  25. </n-space>
  26. <!-- 中间 -->
  27. <div class="list-content-img">
  28. <img
  29. :src="
  30. requireUrl('../assets/images/project', 'moke-20211219181327.png')
  31. "
  32. :alt="cardData?.title"
  33. />
  34. </div>
  35. </div>
  36. <template #action>
  37. <n-space class="list-footer" justify="space-between">
  38. <n-text depth="3">
  39. {{$t('project.last_edit')}}:
  40. <n-time :time="new Date()" format="yyyy-MM-dd hh:mm" />
  41. </n-text>
  42. <!-- 工具 -->
  43. <n-space>
  44. <n-text>
  45. <n-badge
  46. class="animation-twinkle"
  47. dot
  48. :color="cardData?.release ? '#34c749' : '#fcbc40'"
  49. />
  50. {{ cardData?.release ? $t('project.release') : $t('project.unreleased') }}
  51. </n-text>
  52. <template v-for="item in fnBtnList" :key="item.key">
  53. <n-tooltip placement="bottom" trigger="hover">
  54. <template #trigger>
  55. <n-button size="small" @click="handleSelect(item.key)">
  56. <template #icon>
  57. <component :is="item.icon" />
  58. </template>
  59. </n-button>
  60. </template>
  61. <span> {{ item.label }}</span>
  62. </n-tooltip>
  63. </template>
  64. </n-space>
  65. <!-- end -->
  66. </n-space>
  67. </template>
  68. </n-card>
  69. </n-modal>
  70. </template>
  71. <script setup lang="ts">
  72. import { watchEffect, reactive } from 'vue'
  73. import { renderIcon, requireUrl, requireFallbackImg } from '@/utils'
  74. import { icon } from '@/plugins'
  75. import { AppleControlBtn } from '@/components/AppleControlBtn'
  76. const { HammerIcon } = icon.ionicons5
  77. const emit = defineEmits(['close', 'edit'])
  78. const t = window['$t']
  79. const props = defineProps({
  80. show: Boolean,
  81. cardData: Object
  82. })
  83. // 解决点击模态层不会触发 @on-after-leave 的问题
  84. watchEffect(() => {
  85. if (!props.show && props.cardData) {
  86. closeHandle()
  87. }
  88. })
  89. const fnBtnList = reactive([
  90. {
  91. label: t('global.r_edit'),
  92. key: 'edit',
  93. icon: renderIcon(HammerIcon)
  94. }
  95. ])
  96. const handleSelect = (key: string) => {
  97. switch (key) {
  98. case 'edit':
  99. editHandle()
  100. break
  101. }
  102. }
  103. // 编辑处理
  104. const editHandle = () => {
  105. emit('edit', props.cardData)
  106. }
  107. // 关闭对话框
  108. const closeHandle = () => {
  109. emit('close')
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. $padding: 30px;
  114. $contentHeight: calc(80vh);
  115. $contentWidth: calc(82vw);
  116. @include go('modal-box') {
  117. width: $contentWidth;
  118. .list-content {
  119. margin-top: 20px;
  120. border-radius: $--border-radius-base;
  121. overflow: hidden;
  122. @include background-image('background-point');
  123. @extend .go-point-bg;
  124. &-top {
  125. position: absolute;
  126. top: 7px;
  127. left: 0px;
  128. padding-left: 10px;
  129. height: 22px;
  130. width: $contentWidth;
  131. }
  132. &-img {
  133. @extend .go-flex-center;
  134. img {
  135. max-height: $contentHeight;
  136. min-height: 200px;
  137. max-width: 100%;
  138. @extend .go-border-radius;
  139. }
  140. }
  141. }
  142. .list-footer {
  143. line-height: 30px;
  144. }
  145. }
  146. </style>