refactor(ActivityCard): 优化卡片布局和样式
调整 ActivityCard 组件的布局和样式,使其更加美观和一致。移除了不必要的函数 getActivityImage,直接使用 activity.cover_image 作为图片源。
Showing
2 changed files
with
11 additions
and
9 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-04-17 13:16:20 | 2 | * @Date: 2025-04-17 13:16:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-04-21 13:18:07 | 4 | + * @LastEditTime: 2025-04-21 14:56:50 |
| 5 | * @FilePath: /mlaj-reading-club/src/components/shared/ActivityCard.vue | 5 | * @FilePath: /mlaj-reading-club/src/components/shared/ActivityCard.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div | 9 | <div |
| 10 | - class="block bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition duration-200" | 10 | + class="rounded-xl overflow-hidden shadow-md bg-white hover:shadow-lg transition-shadow duration-300 flex" |
| 11 | :class="isSmall ? 'flex-row h-32' : 'flex-col'"> | 11 | :class="isSmall ? 'flex-row h-32' : 'flex-col'"> |
| 12 | <div :class="['relative', isSmall ? 'w-1/3' : 'w-full h-48']"> | 12 | <div :class="['relative', isSmall ? 'w-1/3' : 'w-full h-48']"> |
| 13 | - <img :src="activity.cover_image" :alt="activity.title" class="w-full h-full object-cover" /> | 13 | + <img |
| 14 | + :src="activity.cover_image" | ||
| 15 | + :alt="activity.title" | ||
| 16 | + class="w-full h-full object-cover" | ||
| 17 | + /> | ||
| 14 | <div class="absolute top-2 left-2"> | 18 | <div class="absolute top-2 left-2"> |
| 15 | <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium" :class="statusBadgeClass"> | 19 | <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium" :class="statusBadgeClass"> |
| 16 | {{ statusText }} | 20 | {{ statusText }} |
| ... | @@ -45,7 +49,8 @@ | ... | @@ -45,7 +49,8 @@ |
| 45 | </div> | 49 | </div> |
| 46 | </div> | 50 | </div> |
| 47 | 51 | ||
| 48 | - <div v-if="!isSmall" class="mt-3"> | 52 | + <div v-if="!isSmall"> |
| 53 | + <div class="mt-3"> | ||
| 49 | <div class="flex items-center justify-between text-sm"> | 54 | <div class="flex items-center justify-between text-sm"> |
| 50 | <span class="text-gray-600">已报名: {{ activity.participant_count }}/{{ activity.max_participants }}</span> | 55 | <span class="text-gray-600">已报名: {{ activity.participant_count }}/{{ activity.max_participants }}</span> |
| 51 | <span class="text-blue-600">{{ Math.round(capacityPercentage) }}%</span> | 56 | <span class="text-blue-600">{{ Math.round(capacityPercentage) }}%</span> |
| ... | @@ -62,6 +67,7 @@ | ... | @@ -62,6 +67,7 @@ |
| 62 | </router-link> | 67 | </router-link> |
| 63 | </div> | 68 | </div> |
| 64 | </div> | 69 | </div> |
| 70 | + </div> | ||
| 65 | </template> | 71 | </template> |
| 66 | 72 | ||
| 67 | <script setup> | 73 | <script setup> | ... | ... |
| ... | @@ -39,7 +39,7 @@ | ... | @@ -39,7 +39,7 @@ |
| 39 | <template v-else> | 39 | <template v-else> |
| 40 | <!-- Activity Cover --> | 40 | <!-- Activity Cover --> |
| 41 | <div class="relative h-64 md:h-80 bg-gray-300 overflow-hidden"> | 41 | <div class="relative h-64 md:h-80 bg-gray-300 overflow-hidden"> |
| 42 | - <img :src="getActivityImage(activity.id)" :alt="activity.title" class="w-full h-full object-cover" /> | 42 | + <img :src="activity.cover_image" :alt="activity.title" class="w-full h-full object-cover" /> |
| 43 | <div class="absolute inset-0 bg-black bg-opacity-40"></div> | 43 | <div class="absolute inset-0 bg-black bg-opacity-40"></div> |
| 44 | <div class="absolute bottom-0 left-0 right-0 p-6"> | 44 | <div class="absolute bottom-0 left-0 right-0 p-6"> |
| 45 | <div class="container mx-auto"> | 45 | <div class="container mx-auto"> |
| ... | @@ -381,10 +381,6 @@ const goBack = () => { | ... | @@ -381,10 +381,6 @@ const goBack = () => { |
| 381 | router.back() | 381 | router.back() |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | -const getActivityImage = (activityId) => { | ||
| 385 | - return `/assets/images/activities/${activityId}.jpg` | ||
| 386 | -} | ||
| 387 | - | ||
| 388 | const formatDate = (dateString) => { | 384 | const formatDate = (dateString) => { |
| 389 | if (!dateString) return '' | 385 | if (!dateString) return '' |
| 390 | const date = new Date(dateString.replace(' ', 'T')) | 386 | const date = new Date(dateString.replace(' ', 'T')) | ... | ... |
-
Please register or login to post a comment