hookehuyr

refactor(ActivityCard): 优化卡片布局和样式

调整 ActivityCard 组件的布局和样式,使其更加美观和一致。移除了不必要的函数 getActivityImage,直接使用 activity.cover_image 作为图片源。
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,21 +49,23 @@ ...@@ -45,21 +49,23 @@
45 </div> 49 </div>
46 </div> 50 </div>
47 51
48 - <div v-if="!isSmall" class="mt-3"> 52 + <div v-if="!isSmall">
49 - <div class="flex items-center justify-between text-sm"> 53 + <div class="mt-3">
50 - <span class="text-gray-600">已报名: {{ activity.participant_count }}/{{ activity.max_participants }}</span> 54 + <div class="flex items-center justify-between text-sm">
51 - <span class="text-blue-600">{{ Math.round(capacityPercentage) }}%</span> 55 + <span class="text-gray-600">已报名: {{ activity.participant_count }}/{{ activity.max_participants }}</span>
56 + <span class="text-blue-600">{{ Math.round(capacityPercentage) }}%</span>
57 + </div>
58 + <div class="w-full bg-gray-200 rounded-full h-1.5 mt-1">
59 + <div class="bg-gradient-to-r from-green-400 to-blue-500 h-1.5 rounded-full"
60 + :style="{ width: capacityPercentage + '%' }"></div>
61 + </div>
52 </div> 62 </div>
53 - <div class="w-full bg-gray-200 rounded-full h-1.5 mt-1">
54 - <div class="bg-gradient-to-r from-green-400 to-blue-500 h-1.5 rounded-full"
55 - :style="{ width: capacityPercentage + '%' }"></div>
56 - </div>
57 - </div>
58 63
59 - <router-link :to="`/activity/${activity.id}`" 64 + <router-link :to="`/activity/${activity.id}`"
60 - class="mt-4 inline-flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-gradient-to-r from-green-500 to-blue-500 hover:from-green-600 hover:to-blue-600"> 65 + class="mt-4 inline-flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-gradient-to-r from-green-500 to-blue-500 hover:from-green-600 hover:to-blue-600">
61 - {{ isPast ? '查看详情' : isRegistrationOpen ? '立即报名' : '了解更多' }} 66 + {{ isPast ? '查看详情' : isRegistrationOpen ? '立即报名' : '了解更多' }}
62 - </router-link> 67 + </router-link>
68 + </div>
63 </div> 69 </div>
64 </div> 70 </div>
65 </template> 71 </template>
......
...@@ -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'))
......