prompt-list.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <view class="cu-list menu-avatar margin-bottom">
  4. <view v-for="item in promptList" :key="item.title" class="cu-item">
  5. <text v-show="$store.getters.favorPromptList.indexOf(item.id) >= 0" class="cuIcon-favorfill text-orange"></text>
  6. <image class="cu-avatar radius lg" :src="`/static/icon/prompt/${item.icon}`">
  7. <view class="content" @tap="runPrompt(item)">
  8. <view class="text-shadow text-black">{{ item.title }}</view>
  9. <view class="text-gray text-sm flex">
  10. <text class="desc">{{ item.remark }}</text>
  11. </view>
  12. </view>
  13. <view class="action">
  14. <view class="text-grey">{{ renderWeight(item) }}</view>
  15. <button class="cu-btn round sm line-cyan flex" @tap="showDetail(item)">
  16. 详情
  17. </button>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="cu-modal bottom-modal" :class="showDetailModal ? 'show' : ''" @tap="showDetailModal = false">
  22. <view class="cu-dialog bg-white" @tap.stop="" style="height: 60%;overflow: auto;">
  23. <view class="cu-bar bg-white justify-end">
  24. <view class="action" @tap="toggleFavor(curItem)">
  25. <text :class="[$store.getters.favorPromptList.indexOf(curItem.id) >= 0 ? 'cuIcon-favorfill' : 'cuIcon-favor', 'text-orange']"></text>
  26. </view>
  27. <view class="content">提示词详细</view>
  28. <view class="action text-cyan" @tap="runPrompt(curItem)">进入对话</view>
  29. <view class="action" @tap="showDetailModal = false">
  30. <text class="cuIcon-close"></text>
  31. </view>
  32. </view>
  33. <view class="padding-bottom-lg">
  34. <view class="cu-bar bg-white solid-bottom">
  35. <view class="action">
  36. <text class="cuIcon-titles text-cyan"></text> 提示词
  37. </view>
  38. </view>
  39. <view class="text-left padding-lr-sm padding-top-sm bg-white flex justify-between">
  40. <view>{{ curItem.title }}</view>
  41. <view>{{ renderWeight(curItem) }}</view>
  42. </view>
  43. <view class="cu-bar bg-white solid-bottom">
  44. <view class="action">
  45. <text class="cuIcon-titles text-cyan"></text> 说明
  46. </view>
  47. </view>
  48. <view class="text-left padding-lr-sm padding-top-sm bg-white">
  49. {{ curItem.remark }}
  50. </view>
  51. <view class="cu-bar bg-white solid-bottom">
  52. <view class="action">
  53. <text class="cuIcon-titles text-cyan"></text> 中文提示
  54. </view>
  55. </view>
  56. <view class="text-left padding-lr-sm padding-top-sm bg-white">
  57. {{ curItem.desc_cn }}
  58. </view>
  59. <view class="cu-bar bg-white solid-bottom">
  60. <view class="action">
  61. <text class="cuIcon-titles text-cyan"></text> 英文提示
  62. </view>
  63. </view>
  64. <view class="text-left padding-lr-sm padding-top-sm bg-white">
  65. {{ curItem.desc_en }}
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. name: 'PromptList',
  75. props: {
  76. promptList: {
  77. type: Array,
  78. default: () => []
  79. }
  80. },
  81. data() {
  82. return {
  83. curItem: {},
  84. showDetailModal: false
  85. }
  86. },
  87. methods: {
  88. showDetail(item) {
  89. this.curItem = item
  90. this.showDetailModal = true
  91. },
  92. runPrompt(item) {
  93. this.$squni.navigateTo('/pages/main/index?promptId=' + item.id)
  94. },
  95. toggleFavor(item) {
  96. let favorPromptList = this.$store.getters.favorPromptList
  97. const index = favorPromptList.indexOf(item.id)
  98. if(index >= 0) {
  99. favorPromptList.splice(index, 1)
  100. } else {
  101. favorPromptList.push(item.id)
  102. }
  103. this.$store.commit('setFavorPromptList', favorPromptList)
  104. this.$emit('toggle-favor')
  105. },
  106. renderWeight(item) {
  107. return item.weight > 10000 ? ('🚀 ' + (item.weight / 10000).toFixed(1) + 'w') : (item.weight > 1000 ? ('🔥 ' + (item.weight / 1000).toFixed(1) + 'k') : '🧊 ' + item.weight)
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. .cu-list.menu-avatar>.cu-item {
  114. .content {
  115. width: calc(100% - 96upx - 60upx - 110upx - 20upx);
  116. }
  117. .action {
  118. width: 110upx;
  119. }
  120. }
  121. .cu-list .cu-item {
  122. .cuIcon-favorfill {
  123. position: absolute;
  124. bottom: 2upx;
  125. left: 12upx;
  126. }
  127. .cu-avatar {
  128. background-color: transparent;
  129. }
  130. .content .desc {
  131. overflow : hidden;
  132. text-overflow: ellipsis;
  133. display: -webkit-box;
  134. -webkit-line-clamp: 2;
  135. -webkit-box-orient: vertical;
  136. }
  137. }
  138. </style>