feat(router): 添加我的活动页面并清理重复路由
清理了重复的课程评价路由,并添加了新的“我的活动”页面路由,以支持用户查看个人活动记录
Showing
2 changed files
with
80 additions
and
53 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-03-20 20:36:36 | 2 | * @Date: 2025-03-20 20:36:36 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-21 11:33:55 | 4 | + * @LastEditTime: 2025-03-21 12:08:30 |
| 5 | * @FilePath: /mlaj/src/router/index.js | 5 | * @FilePath: /mlaj/src/router/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -15,24 +15,12 @@ const routes = [ | ... | @@ -15,24 +15,12 @@ const routes = [ |
| 15 | meta: { title: '首页' }, | 15 | meta: { title: '首页' }, |
| 16 | }, | 16 | }, |
| 17 | { | 17 | { |
| 18 | - path: '/courses/:id/reviews', | ||
| 19 | - name: 'CourseReviews', | ||
| 20 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 21 | - meta: { title: '课程评价' } | ||
| 22 | - }, | ||
| 23 | - { | ||
| 24 | path: '/courses', | 18 | path: '/courses', |
| 25 | name: 'Courses', | 19 | name: 'Courses', |
| 26 | component: () => import('../views/courses/CoursesPage.vue'), | 20 | component: () => import('../views/courses/CoursesPage.vue'), |
| 27 | meta: { title: '课程列表' }, | 21 | meta: { title: '课程列表' }, |
| 28 | }, | 22 | }, |
| 29 | { | 23 | { |
| 30 | - path: '/courses/:id/reviews', | ||
| 31 | - name: 'CourseReviews', | ||
| 32 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 33 | - meta: { title: '课程评价' } | ||
| 34 | - }, | ||
| 35 | - { | ||
| 36 | path: '/courses/:id', | 24 | path: '/courses/:id', |
| 37 | name: 'CourseDetail', | 25 | name: 'CourseDetail', |
| 38 | component: () => import('../views/courses/CourseDetailPage.vue'), | 26 | component: () => import('../views/courses/CourseDetailPage.vue'), |
| ... | @@ -51,60 +39,30 @@ const routes = [ | ... | @@ -51,60 +39,30 @@ const routes = [ |
| 51 | meta: { title: '个人中心' }, | 39 | meta: { title: '个人中心' }, |
| 52 | }, | 40 | }, |
| 53 | { | 41 | { |
| 54 | - path: '/courses/:id/reviews', | ||
| 55 | - name: 'CourseReviews', | ||
| 56 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 57 | - meta: { title: '课程评价' } | ||
| 58 | - }, | ||
| 59 | - { | ||
| 60 | path: '/login', | 42 | path: '/login', |
| 61 | name: 'Login', | 43 | name: 'Login', |
| 62 | component: () => import('../views/auth/LoginPage.vue'), | 44 | component: () => import('../views/auth/LoginPage.vue'), |
| 63 | meta: { title: '登录' } | 45 | meta: { title: '登录' } |
| 64 | }, | 46 | }, |
| 65 | { | 47 | { |
| 66 | - path: '/courses/:id/reviews', | ||
| 67 | - name: 'CourseReviews', | ||
| 68 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 69 | - meta: { title: '课程评价' } | ||
| 70 | - }, | ||
| 71 | - { | ||
| 72 | path: '/register', | 48 | path: '/register', |
| 73 | name: 'Register', | 49 | name: 'Register', |
| 74 | component: () => import('../views/auth/RegisterPage.vue'), | 50 | component: () => import('../views/auth/RegisterPage.vue'), |
| 75 | meta: { title: '注册' } | 51 | meta: { title: '注册' } |
| 76 | }, | 52 | }, |
| 77 | { | 53 | { |
| 78 | - path: '/courses/:id/reviews', | ||
| 79 | - name: 'CourseReviews', | ||
| 80 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 81 | - meta: { title: '课程评价' } | ||
| 82 | - }, | ||
| 83 | - { | ||
| 84 | path: '/forgotPwd', | 54 | path: '/forgotPwd', |
| 85 | name: 'ForgotPassword', | 55 | name: 'ForgotPassword', |
| 86 | component: () => import('../views/auth/ForgotPasswordPage.vue'), | 56 | component: () => import('../views/auth/ForgotPasswordPage.vue'), |
| 87 | meta: { title: '忘记密码' } | 57 | meta: { title: '忘记密码' } |
| 88 | }, | 58 | }, |
| 89 | { | 59 | { |
| 90 | - path: '/courses/:id/reviews', | ||
| 91 | - name: 'CourseReviews', | ||
| 92 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 93 | - meta: { title: '课程评价' } | ||
| 94 | - }, | ||
| 95 | - { | ||
| 96 | path: '/activities', | 60 | path: '/activities', |
| 97 | name: 'Activities', | 61 | name: 'Activities', |
| 98 | component: () => import('../views/activities/ActivitiesPage.vue'), | 62 | component: () => import('../views/activities/ActivitiesPage.vue'), |
| 99 | meta: { title: '活动列表' } | 63 | meta: { title: '活动列表' } |
| 100 | }, | 64 | }, |
| 101 | { | 65 | { |
| 102 | - path: '/courses/:id/reviews', | ||
| 103 | - name: 'CourseReviews', | ||
| 104 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 105 | - meta: { title: '课程评价' } | ||
| 106 | - }, | ||
| 107 | - { | ||
| 108 | path: '/activities/:id', | 66 | path: '/activities/:id', |
| 109 | name: 'ActivityDetail', | 67 | name: 'ActivityDetail', |
| 110 | component: () => import('../views/activities/ActivityDetailPage.vue'), | 68 | component: () => import('../views/activities/ActivityDetailPage.vue'), |
| ... | @@ -112,12 +70,6 @@ const routes = [ | ... | @@ -112,12 +70,6 @@ const routes = [ |
| 112 | meta: { title: '活动详情' } | 70 | meta: { title: '活动详情' } |
| 113 | }, | 71 | }, |
| 114 | { | 72 | { |
| 115 | - path: '/courses/:id/reviews', | ||
| 116 | - name: 'CourseReviews', | ||
| 117 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | ||
| 118 | - meta: { title: '课程评价' } | ||
| 119 | - }, | ||
| 120 | - { | ||
| 121 | path: '/activities/:id/signup', | 73 | path: '/activities/:id/signup', |
| 122 | name: 'ActivitySignup', | 74 | name: 'ActivitySignup', |
| 123 | component: () => import('../views/activities/ActivitySignupPage.vue'), | 75 | component: () => import('../views/activities/ActivitySignupPage.vue'), |
| ... | @@ -126,10 +78,10 @@ const routes = [ | ... | @@ -126,10 +78,10 @@ const routes = [ |
| 126 | } | 78 | } |
| 127 | }, | 79 | }, |
| 128 | { | 80 | { |
| 129 | - path: '/courses/:id/reviews', | 81 | + path: '/profile/activities', |
| 130 | - name: 'CourseReviews', | 82 | + name: 'MyActivities', |
| 131 | - component: () => import('../views/courses/CourseReviewsPage.vue'), | 83 | + component: () => import('../views/activities/MyActivitiesPage.vue'), |
| 132 | - meta: { title: '课程评价' } | 84 | + meta: { title: '我的活动' } |
| 133 | }, | 85 | }, |
| 134 | { | 86 | { |
| 135 | path: '/checkout', | 87 | path: '/checkout', | ... | ... |
src/views/activities/MyActivitiesPage.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2025-03-21 11:47:47 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2025-03-21 11:47:48 | ||
| 5 | + * @FilePath: /mlaj/src/views/activities/MyActivitiesPage.vue | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div class="bg-gradient-to-b from-green-50/70 to-white/90 min-h-screen pb-20"> | ||
| 10 | + <!-- 活动列表 --> | ||
| 11 | + <van-list | ||
| 12 | + v-model:loading="loading" | ||
| 13 | + :finished="finished" | ||
| 14 | + finished-text="没有更多了" | ||
| 15 | + @load="onLoad" | ||
| 16 | + class="px-4 py-3 space-y-4" | ||
| 17 | + > | ||
| 18 | + <ActivityCard | ||
| 19 | + v-for="activity in activities" | ||
| 20 | + :key="activity.id" | ||
| 21 | + :activity="activity" | ||
| 22 | + /> | ||
| 23 | + </van-list> | ||
| 24 | + | ||
| 25 | + <!-- 无数据提示 --> | ||
| 26 | + <div v-if="!loading && activities.length === 0" class="flex flex-col items-center justify-center py-12"> | ||
| 27 | + <svg xmlns="http://www.w3.org/2000/svg" class="h-16 w-16 text-gray-300" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
| 28 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" /> | ||
| 29 | + </svg> | ||
| 30 | + <p class="mt-4 text-gray-500">暂无活动记录</p> | ||
| 31 | + </div> | ||
| 32 | + </div> | ||
| 33 | +</template> | ||
| 34 | + | ||
| 35 | +<script setup> | ||
| 36 | +import { ref } from 'vue' | ||
| 37 | +import { useRoute, useRouter } from 'vue-router' | ||
| 38 | +import ActivityCard from '@/components/ui/ActivityCard.vue' | ||
| 39 | +import { activities as mockActivities } from '@/utils/mockData' | ||
| 40 | +import { useTitle } from '@vueuse/core'; | ||
| 41 | +const $route = useRoute(); | ||
| 42 | +const $router = useRouter(); | ||
| 43 | +useTitle($route.meta.title); | ||
| 44 | +const router = useRouter() | ||
| 45 | +const activities = ref([]) | ||
| 46 | +const loading = ref(false) | ||
| 47 | +const finished = ref(false) | ||
| 48 | +const page = ref(1) | ||
| 49 | +const pageSize = 10 | ||
| 50 | + | ||
| 51 | +// 加载活动数据 | ||
| 52 | +const onLoad = async () => { | ||
| 53 | + try { | ||
| 54 | + loading.value = true | ||
| 55 | + // 模拟异步加载数据 | ||
| 56 | + await new Promise(resolve => setTimeout(resolve, 1000)) | ||
| 57 | + | ||
| 58 | + const start = (page.value - 1) * pageSize | ||
| 59 | + const end = start + pageSize | ||
| 60 | + const newActivities = mockActivities.slice(start, end) | ||
| 61 | + | ||
| 62 | + activities.value.push(...newActivities) | ||
| 63 | + | ||
| 64 | + if (newActivities.length < pageSize) { | ||
| 65 | + finished.value = true | ||
| 66 | + } else { | ||
| 67 | + page.value += 1 | ||
| 68 | + } | ||
| 69 | + } catch (error) { | ||
| 70 | + console.error('加载活动数据失败:', error) | ||
| 71 | + } finally { | ||
| 72 | + loading.value = false | ||
| 73 | + } | ||
| 74 | +} | ||
| 75 | +</script> |
-
Please register or login to post a comment