| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- <template>
- <div
- class="market-card"
- @mouseenter="isHovered = true"
- @mouseleave="isHovered = false"
- >
- <!-- 封面图 -->
- <div class="market-card-cover" @click.stop.prevent="goWorkflowDetail">
- <img :src="info.coverImage" :alt="info.workflowTitle" class="market-cover-img" />
- <div class="market-cover-overlay"></div>
- <div class="market-platform-chip">{{ info.categoryName1 }}</div>
- <!-- <div class="market-views">▶ {{ info.downCount || 0 }}</div> -->
- </div>
- <!-- 卡片内容 -->
- <div class="market-card-body">
- <div class="market-card-top">
- <h4 class="market-title" @click.stop.prevent="goWorkflowDetail">{{ info.workflowTitle }}</h4>
- </div>
- <p class="market-desc">{{ info.description }}</p>
- <div class="market-footer">
- <div class="market-author">
- <el-avatar :size="22" :src="info.userAvatar || appStore.avatarDefault" />
- <span>{{ info.nickName }}</span>
- </div>
- <button class="market-use-btn" @click.stop.prevent="startUsing">{{ $t('marketplace.cta.use') }} →</button>
- </div>
- </div>
- <!-- 悬停遮罩 -->
- <div class="market-hover-overlay" :class="{ visible: isHovered }">
- <button class="overlay-btn primary" @click.stop.prevent="startUsing">{{ $t('marketplace.cta.use2') }}</button>
- <button class="overlay-btn secondary" @click.stop.prevent="goWorkflowDetail">{{ $t('marketplace.cta.details') }}</button>
- </div>
- </div>
- </template>
- <script setup>
- import { ref } from 'vue'
- import { useAppStore } from '@/pinia/appStore'
- import { inject } from 'vue'
- import { isLogin, openNewTab } from '@/utils/util.js'
- import { useI18n } from 'vue-i18n'
- import { useRouter } from 'vue-router'
- const { t } = useI18n()
- const appStore = useAppStore()
- const router = useRouter()
- const openLoginDialog = inject('openLoginDialog')
- const props = defineProps({
- info: {
- type: Object,
- default: () => ({})
- },
- fromPage: {
- type: String,
- default: () => ''
- }
- })
- const isHovered = ref(false)
- const goWorkflowDetail = () => {
- if (!isLogin({ callback: openLoginDialog, t })) {
- return
- }
- let path = `/search-platform/workflow-detail`
- if (props.fromPage === 'home') {
- path = `/workflow-detail`
- }
- router.push({
- path: path,
- query: {
- publishId: props.info.publishId,
- metaTitle: 'route.WorkflowDetail'
- }
- })
- }
- const startUsing = () => {
- if (!isLogin({ callback: openLoginDialog, t })) {
- return
- }
- openNewTab(props.info.categoryUrl)
- }
- </script>
- <style scoped lang="scss">
- .market-card {
- background: white;
- border-radius: 16px;
- border: 1px solid rgba(0, 0, 0, 0.06);
- overflow: hidden;
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
- transition: all 0.3s ease;
- position: relative;
- cursor: pointer;
- &:hover {
- transform: translateY(-6px);
- box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
- }
- &.hidden {
- opacity: 0.3;
- transform: scale(0.95);
- }
- }
- /* 封面图 */
- .market-card-cover {
- position: relative;
- height: 160px;
- overflow: hidden;
- }
- .market-cover-img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- transition: transform 0.4s;
- }
- .market-card:hover .market-cover-img {
- transform: scale(1.05);
- }
- .market-cover-overlay {
- position: absolute;
- inset: 0;
- background: linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, 0.4));
- }
- .market-platform-chip {
- position: absolute;
- top: 10px;
- left: 10px;
- padding: 3px 10px;
- border-radius: 100px;
- font-size: 11px;
- font-weight: 700;
- color: white;
- background: linear-gradient(135deg, #6366F1, #8B5CF6);
- }
- .market-views {
- position: absolute;
- bottom: 10px;
- right: 10px;
- color: white;
- font-size: 12px;
- font-weight: 600;
- }
- /* 卡片内容 */
- .market-card-body {
- padding: 16px;
- }
- .market-card-top {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- margin-bottom: 8px;
- }
- .market-title {
- font-size: 14px;
- font-weight: 700;
- color: #111827;
- flex: 1;
- margin: 0;
- line-height: 1.3;
- &:hover {
- text-decoration: underline;
- }
- }
- .market-rating {
- font-size: 12px;
- color: #F59E0B;
- font-weight: 600;
- white-space: nowrap;
- }
- .market-desc {
- font-size: 12px;
- color: #6B7280;
- line-height: 1.5;
- margin: 0 0 10px 0;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
- text-overflow: ellipsis;
- min-height: 36px;
- }
- .market-tags {
- display: flex;
- flex-wrap: wrap;
- gap: 4px;
- margin-bottom: 12px;
- }
- .market-tag {
- padding: 2px 8px;
- background: #F3F4F6;
- border-radius: 100px;
- font-size: 10px;
- color: #6B7280;
- }
- .market-footer {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 12px;
- }
- .market-author {
- display: flex;
- align-items: center;
- gap: 6px;
- font-size: 12px;
- color: #6B7280;
- overflow: hidden;
- flex-shrink: 0;
- max-width: 50%;
- span {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- }
- .market-avatar {
- width: 22px;
- height: 22px;
- border-radius: 50%;
- object-fit: cover;
- flex-shrink: 0;
- }
- .market-use-btn {
- padding: 5px 12px;
- background: #F5F3FF;
- color: #6366F1;
- border: 1px solid rgba(99, 102, 241, 0.2);
- border-radius: 8px;
- font-size: 12px;
- font-weight: 600;
- cursor: pointer;
- transition: all 0.2s;
- white-space: nowrap;
- &:hover {
- background: #6366F1;
- color: white;
- }
- }
- /* 悬停遮罩 */
- .market-hover-overlay {
- position: absolute;
- inset: 0;
- background: rgba(99, 102, 241, 0.92);
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: 12px;
- opacity: 0;
- transition: opacity 0.3s;
- z-index: 10;
- &.visible {
- opacity: 1;
- }
- }
- .overlay-btn {
- width: 160px;
- padding: 10px;
- border-radius: 10px;
- font-size: 14px;
- font-weight: 600;
- cursor: pointer;
- border: none;
- transition: all 0.2s;
- &.primary {
- background: white;
- color: #6366F1;
- &:hover {
- transform: translateY(-2px);
- box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
- }
- }
- &.secondary {
- background: rgba(255, 255, 255, 0.15);
- color: white;
- border: 1px solid rgba(255, 255, 255, 0.3);
- &:hover {
- background: rgba(255, 255, 255, 0.25);
- transform: translateY(-2px);
- }
- }
- }
- </style>
|