index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <!-- mask-closable 暂时是失效的,不知道为啥 -->
  3. <n-modal
  4. class="go-modal-box"
  5. v-model:show="showRef"
  6. @afterLeave="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. <mac-os-control-btn
  21. :narrow="true"
  22. :hidden="['close']"
  23. @remove="closeHandle"
  24. ></mac-os-control-btn>
  25. </n-space>
  26. <!-- 中间 -->
  27. <div class="list-content-img">
  28. <img
  29. :src="
  30. requireUrl('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"></n-time>
  41. </n-text>
  42. <!-- 工具 -->
  43. <n-space>
  44. <n-text>
  45. <n-badge
  46. class="go-animation-twinkle"
  47. dot
  48. :color="cardData?.release ? '#34c749' : '#fcbc40'"
  49. ></n-badge>
  50. {{
  51. cardData?.release
  52. ? $t('project.release')
  53. : $t('project.unreleased')
  54. }}
  55. </n-text>
  56. <template v-for="item in fnBtnList" :key="item.key">
  57. <n-tooltip placement="bottom" trigger="hover">
  58. <template #trigger>
  59. <n-button size="small" @click="handleSelect(item.key)">
  60. <template #icon>
  61. <component :is="item.icon"></component>
  62. </template>
  63. </n-button>
  64. </template>
  65. <component :is="item.label"></component>
  66. </n-tooltip>
  67. </template>
  68. </n-space>
  69. <!-- end -->
  70. </n-space>
  71. </template>
  72. </n-card>
  73. </n-modal>
  74. </template>
  75. <script setup lang="ts">
  76. import { ref, reactive, watch } from 'vue'
  77. import { renderIcon, renderLang } from '@/utils'
  78. import { icon } from '@/plugins'
  79. import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn'
  80. const { HammerIcon } = icon.ionicons5
  81. const showRef = ref(false)
  82. const emit = defineEmits(['close', 'edit'])
  83. const props = defineProps({
  84. modalShow: {
  85. required: true,
  86. type: Boolean
  87. },
  88. cardData: {
  89. required: true,
  90. type: Object
  91. }
  92. })
  93. watch(
  94. () => props.modalShow,
  95. newValue => {
  96. showRef.value = newValue
  97. },
  98. {
  99. immediate: true
  100. }
  101. )
  102. // 处理url获取
  103. const requireUrl = (name: string) => {
  104. return new URL(`../../../../../assets/images/${name}`, import.meta.url).href
  105. }
  106. const fnBtnList = reactive([
  107. {
  108. label: renderLang('global.r_edit'),
  109. key: 'edit',
  110. icon: renderIcon(HammerIcon)
  111. }
  112. ])
  113. const handleSelect = (key: string) => {
  114. switch (key) {
  115. case 'edit':
  116. editHandle()
  117. break
  118. }
  119. }
  120. // 编辑处理
  121. const editHandle = () => {
  122. emit('edit', props.cardData)
  123. }
  124. // 关闭对话框
  125. const closeHandle = () => {
  126. emit('close')
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. $padding: 30px;
  131. $contentHeight: calc(80vh);
  132. $contentWidth: calc(82vw);
  133. @include go('modal-box') {
  134. width: $contentWidth;
  135. .list-content {
  136. margin-top: 28px;
  137. border-radius: $--border-radius-base;
  138. overflow: hidden;
  139. @include background-image('background-point');
  140. @extend .go-point-bg;
  141. &-top {
  142. position: absolute;
  143. top: 7px;
  144. left: 0px;
  145. padding-left: 10px;
  146. height: 22px;
  147. width: $contentWidth;
  148. }
  149. &-img {
  150. @extend .go-flex-center;
  151. img {
  152. max-height: $contentHeight;
  153. min-height: 200px;
  154. max-width: 100%;
  155. @extend .go-border-radius;
  156. }
  157. }
  158. }
  159. .list-footer {
  160. line-height: 30px;
  161. }
  162. }
  163. </style>