course-card.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <div
  3. class="market-card"
  4. @mouseenter="isHovered = true"
  5. @mouseleave="isHovered = false"
  6. >
  7. <!-- 封面图 -->
  8. <div class="market-card-cover" @click.stop.prevent="goWorkflowDetail">
  9. <img :src="info.coverImage" :alt="info.workflowTitle" class="market-cover-img" />
  10. <div class="market-cover-overlay"></div>
  11. <div class="market-platform-chip">{{ info.categoryName1 }}</div>
  12. <!-- <div class="market-views">▶ {{ info.downCount || 0 }}</div> -->
  13. </div>
  14. <!-- 卡片内容 -->
  15. <div class="market-card-body">
  16. <div class="market-card-top">
  17. <h4 class="market-title" @click.stop.prevent="goWorkflowDetail">{{ info.workflowTitle }}</h4>
  18. </div>
  19. <p class="market-desc">{{ info.description }}</p>
  20. <div class="market-footer">
  21. <div class="market-author">
  22. <el-avatar :size="22" :src="info.userAvatar || appStore.avatarDefault" />
  23. <span>{{ info.nickName }}</span>
  24. </div>
  25. <button class="market-use-btn" @click.stop.prevent="startUsing">{{ $t('marketplace.cta.use') }} →</button>
  26. </div>
  27. </div>
  28. <!-- 悬停遮罩 -->
  29. <div class="market-hover-overlay" :class="{ visible: isHovered }">
  30. <button class="overlay-btn primary" @click.stop.prevent="startUsing">{{ $t('marketplace.cta.use2') }}</button>
  31. <button class="overlay-btn secondary" @click.stop.prevent="goWorkflowDetail">{{ $t('marketplace.cta.details') }}</button>
  32. </div>
  33. </div>
  34. </template>
  35. <script setup>
  36. import { ref } from 'vue'
  37. import { useAppStore } from '@/pinia/appStore'
  38. import { inject } from 'vue'
  39. import { isLogin, openNewTab } from '@/utils/util.js'
  40. import { useI18n } from 'vue-i18n'
  41. import { useRouter } from 'vue-router'
  42. const { t } = useI18n()
  43. const appStore = useAppStore()
  44. const router = useRouter()
  45. const openLoginDialog = inject('openLoginDialog')
  46. const props = defineProps({
  47. info: {
  48. type: Object,
  49. default: () => ({})
  50. },
  51. fromPage: {
  52. type: String,
  53. default: () => ''
  54. }
  55. })
  56. const isHovered = ref(false)
  57. const goWorkflowDetail = () => {
  58. if (!isLogin({ callback: openLoginDialog, t })) {
  59. return
  60. }
  61. let path = `/search-platform/workflow-detail`
  62. if (props.fromPage === 'home') {
  63. path = `/workflow-detail`
  64. }
  65. router.push({
  66. path: path,
  67. query: {
  68. publishId: props.info.publishId,
  69. metaTitle: 'route.WorkflowDetail'
  70. }
  71. })
  72. }
  73. const startUsing = () => {
  74. if (!isLogin({ callback: openLoginDialog, t })) {
  75. return
  76. }
  77. openNewTab(props.info.categoryUrl)
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .market-card {
  82. background: white;
  83. border-radius: 16px;
  84. border: 1px solid rgba(0, 0, 0, 0.06);
  85. overflow: hidden;
  86. box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  87. transition: all 0.3s ease;
  88. position: relative;
  89. cursor: pointer;
  90. &:hover {
  91. transform: translateY(-6px);
  92. box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  93. }
  94. &.hidden {
  95. opacity: 0.3;
  96. transform: scale(0.95);
  97. }
  98. }
  99. /* 封面图 */
  100. .market-card-cover {
  101. position: relative;
  102. height: 160px;
  103. overflow: hidden;
  104. }
  105. .market-cover-img {
  106. width: 100%;
  107. height: 100%;
  108. object-fit: cover;
  109. transition: transform 0.4s;
  110. }
  111. .market-card:hover .market-cover-img {
  112. transform: scale(1.05);
  113. }
  114. .market-cover-overlay {
  115. position: absolute;
  116. inset: 0;
  117. background: linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, 0.4));
  118. }
  119. .market-platform-chip {
  120. position: absolute;
  121. top: 10px;
  122. left: 10px;
  123. padding: 3px 10px;
  124. border-radius: 100px;
  125. font-size: 11px;
  126. font-weight: 700;
  127. color: white;
  128. background: linear-gradient(135deg, #6366F1, #8B5CF6);
  129. }
  130. .market-views {
  131. position: absolute;
  132. bottom: 10px;
  133. right: 10px;
  134. color: white;
  135. font-size: 12px;
  136. font-weight: 600;
  137. }
  138. /* 卡片内容 */
  139. .market-card-body {
  140. padding: 16px;
  141. }
  142. .market-card-top {
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: flex-start;
  146. margin-bottom: 8px;
  147. }
  148. .market-title {
  149. font-size: 14px;
  150. font-weight: 700;
  151. color: #111827;
  152. flex: 1;
  153. margin: 0;
  154. line-height: 1.3;
  155. &:hover {
  156. text-decoration: underline;
  157. }
  158. }
  159. .market-rating {
  160. font-size: 12px;
  161. color: #F59E0B;
  162. font-weight: 600;
  163. white-space: nowrap;
  164. }
  165. .market-desc {
  166. font-size: 12px;
  167. color: #6B7280;
  168. line-height: 1.5;
  169. margin: 0 0 10px 0;
  170. display: -webkit-box;
  171. -webkit-line-clamp: 2;
  172. -webkit-box-orient: vertical;
  173. overflow: hidden;
  174. text-overflow: ellipsis;
  175. min-height: 36px;
  176. }
  177. .market-tags {
  178. display: flex;
  179. flex-wrap: wrap;
  180. gap: 4px;
  181. margin-bottom: 12px;
  182. }
  183. .market-tag {
  184. padding: 2px 8px;
  185. background: #F3F4F6;
  186. border-radius: 100px;
  187. font-size: 10px;
  188. color: #6B7280;
  189. }
  190. .market-footer {
  191. display: flex;
  192. justify-content: space-between;
  193. align-items: center;
  194. margin-top: 12px;
  195. }
  196. .market-author {
  197. display: flex;
  198. align-items: center;
  199. gap: 6px;
  200. font-size: 12px;
  201. color: #6B7280;
  202. overflow: hidden;
  203. flex-shrink: 0;
  204. max-width: 50%;
  205. span {
  206. overflow: hidden;
  207. white-space: nowrap;
  208. text-overflow: ellipsis;
  209. }
  210. }
  211. .market-avatar {
  212. width: 22px;
  213. height: 22px;
  214. border-radius: 50%;
  215. object-fit: cover;
  216. flex-shrink: 0;
  217. }
  218. .market-use-btn {
  219. padding: 5px 12px;
  220. background: #F5F3FF;
  221. color: #6366F1;
  222. border: 1px solid rgba(99, 102, 241, 0.2);
  223. border-radius: 8px;
  224. font-size: 12px;
  225. font-weight: 600;
  226. cursor: pointer;
  227. transition: all 0.2s;
  228. white-space: nowrap;
  229. &:hover {
  230. background: #6366F1;
  231. color: white;
  232. }
  233. }
  234. /* 悬停遮罩 */
  235. .market-hover-overlay {
  236. position: absolute;
  237. inset: 0;
  238. background: rgba(99, 102, 241, 0.92);
  239. display: flex;
  240. flex-direction: column;
  241. align-items: center;
  242. justify-content: center;
  243. gap: 12px;
  244. opacity: 0;
  245. transition: opacity 0.3s;
  246. z-index: 10;
  247. &.visible {
  248. opacity: 1;
  249. }
  250. }
  251. .overlay-btn {
  252. width: 160px;
  253. padding: 10px;
  254. border-radius: 10px;
  255. font-size: 14px;
  256. font-weight: 600;
  257. cursor: pointer;
  258. border: none;
  259. transition: all 0.2s;
  260. &.primary {
  261. background: white;
  262. color: #6366F1;
  263. &:hover {
  264. transform: translateY(-2px);
  265. box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
  266. }
  267. }
  268. &.secondary {
  269. background: rgba(255, 255, 255, 0.15);
  270. color: white;
  271. border: 1px solid rgba(255, 255, 255, 0.3);
  272. &:hover {
  273. background: rgba(255, 255, 255, 0.25);
  274. transform: translateY(-2px);
  275. }
  276. }
  277. }
  278. </style>