refactor(router): 重构路由配置并删除无用文件
重构了路由配置文件,更新了路由路径和组件名称,并添加了元数据。删除了不再使用的About.vue文件,同时新增了CoursesPage.vue页面。
Showing
5 changed files
with
154 additions
and
77 deletions
| 1 | +/* | ||
| 2 | + * @Date: 2025-03-20 20:36:36 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2025-03-20 20:50:41 | ||
| 5 | + * @FilePath: /mlaj/src/router/index.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 1 | import { createRouter, createWebHistory } from 'vue-router' | 8 | import { createRouter, createWebHistory } from 'vue-router' |
| 2 | 9 | ||
| 3 | const routes = [ | 10 | const routes = [ |
| 4 | { | 11 | { |
| 5 | path: '/', | 12 | path: '/', |
| 6 | - name: 'home', | 13 | + name: 'HomePage', |
| 7 | - component: () => import('../views/Home.vue') | 14 | + component: () => import('../views/HomePage.vue'), |
| 15 | + meta: { title: 'HomePage' }, | ||
| 8 | }, | 16 | }, |
| 9 | { | 17 | { |
| 10 | - path: '/about', | 18 | + path: '/courses', |
| 11 | - name: 'about', | 19 | + name: 'Courses', |
| 12 | - component: () => import('../views/About.vue') | 20 | + component: () => import('../views/courses/CoursesPage.vue'), |
| 13 | - } | 21 | + meta: { title: 'Courses' }, |
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + path: '/courses/:id', | ||
| 25 | + name: 'CourseDetail', | ||
| 26 | + component: () => import('../views/courses/CourseDetailPage.vue'), | ||
| 27 | + meta: { title: 'CourseDetail' }, | ||
| 28 | + }, | ||
| 14 | ] | 29 | ] |
| 15 | 30 | ||
| 16 | const router = createRouter({ | 31 | const router = createRouter({ |
| 17 | history: createWebHistory(), | 32 | history: createWebHistory(), |
| 18 | - routes | 33 | + routes, |
| 19 | }) | 34 | }) |
| 20 | 35 | ||
| 21 | export default router | 36 | export default router | ... | ... |
src/views/About.vue
deleted
100644 → 0
| 1 | -<script setup> | ||
| 2 | -import { Button, NavBar, Tabbar, TabbarItem } from 'vant'; | ||
| 3 | -</script> | ||
| 4 | - | ||
| 5 | -<template> | ||
| 6 | - <div class="min-h-screen flex flex-col bg-gray-100"> | ||
| 7 | - <van-nav-bar | ||
| 8 | - title="关于" | ||
| 9 | - left-text="返回" | ||
| 10 | - right-text="菜单" | ||
| 11 | - left-arrow | ||
| 12 | - @click-left="onClickLeft" | ||
| 13 | - @click-right="onClickRight" | ||
| 14 | - /> | ||
| 15 | - | ||
| 16 | - <div class="flex-1 p-4"> | ||
| 17 | - <div class="bg-white rounded-lg shadow p-4 mb-4"> | ||
| 18 | - <h2 class="text-xl font-bold mb-2">关于我们</h2> | ||
| 19 | - <p class="text-gray-600 mb-4">这是一个示例项目的关于页面,展示了如何使用Vue3、Vite、Vant4和TailwindCSS构建现代化的Web应用。</p> | ||
| 20 | - <van-button type="primary" block>了解更多</van-button> | ||
| 21 | - </div> | ||
| 22 | - | ||
| 23 | - <div class="grid grid-cols-2 gap-4"> | ||
| 24 | - <div class="bg-white rounded-lg shadow p-4"> | ||
| 25 | - <h3 class="text-lg font-semibold mb-2">联系方式</h3> | ||
| 26 | - <ul class="text-gray-600"> | ||
| 27 | - <li>邮箱:example@example.com</li> | ||
| 28 | - <li>电话:123-456-7890</li> | ||
| 29 | - <li>地址:示例地址</li> | ||
| 30 | - </ul> | ||
| 31 | - </div> | ||
| 32 | - <div class="bg-white rounded-lg shadow p-4"> | ||
| 33 | - <h3 class="text-lg font-semibold mb-2">版本信息</h3> | ||
| 34 | - <ul class="text-gray-600"> | ||
| 35 | - <li>当前版本:1.0.0</li> | ||
| 36 | - <li>更新日期:2024-03-20</li> | ||
| 37 | - <li>开源协议:MIT</li> | ||
| 38 | - </ul> | ||
| 39 | - </div> | ||
| 40 | - </div> | ||
| 41 | - </div> | ||
| 42 | - | ||
| 43 | - <van-tabbar v-model="active"> | ||
| 44 | - <van-tabbar-item icon="home-o">首页</van-tabbar-item> | ||
| 45 | - <van-tabbar-item icon="search">搜索</van-tabbar-item> | ||
| 46 | - <van-tabbar-item icon="friends-o">好友</van-tabbar-item> | ||
| 47 | - <van-tabbar-item icon="setting-o">设置</van-tabbar-item> | ||
| 48 | - </van-tabbar> | ||
| 49 | - </div> | ||
| 50 | -</template> | ||
| 51 | - | ||
| 52 | -<script> | ||
| 53 | -export default { | ||
| 54 | - data() { | ||
| 55 | - return { | ||
| 56 | - active: 0 | ||
| 57 | - } | ||
| 58 | - }, | ||
| 59 | - methods: { | ||
| 60 | - onClickLeft() { | ||
| 61 | - this.$router.back() | ||
| 62 | - }, | ||
| 63 | - onClickRight() { | ||
| 64 | - // 处理右侧按钮点击 | ||
| 65 | - } | ||
| 66 | - } | ||
| 67 | -} | ||
| 68 | -</script> |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-20 19:55:21 | 2 | * @Date: 2025-03-20 19:55:21 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-20 20:26:17 | 4 | + * @LastEditTime: 2025-03-20 20:48:08 |
| 5 | - * @FilePath: /vue-vite/src/views/Home.vue | 5 | + * @FilePath: /mlaj/src/views/HomePage.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> | ... | ... |
src/views/courses/CourseDetailPage.vue
0 → 100644
This diff is collapsed. Click to expand it.
src/views/courses/CoursesPage.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <AppLayout title="课程" :rightContent="rightContent"> | ||
| 3 | + <div class="pb-16"> | ||
| 4 | + <!-- Search Bar --> | ||
| 5 | + <div class="pb-2"> | ||
| 6 | + <SearchBar placeholder="搜索" @search="handleSearch" /> | ||
| 7 | + </div> | ||
| 8 | + | ||
| 9 | + <!-- Featured Course Banner --> | ||
| 10 | + <div class="px-4 mb-5"> | ||
| 11 | + <div class="relative rounded-xl overflow-hidden shadow-lg h-40"> | ||
| 12 | + <img | ||
| 13 | + src="https://cdn.ipadbiz.cn/mlaj/images/featured-course.jpg" | ||
| 14 | + alt="传承之道" | ||
| 15 | + class="w-full h-full object-cover" | ||
| 16 | + /> | ||
| 17 | + <div | ||
| 18 | + class="absolute inset-0 bg-gradient-to-b from-transparent to-black/50 flex flex-col justify-end p-4" | ||
| 19 | + > | ||
| 20 | + <h2 class="text-3xl font-bold text-amber-400 drop-shadow-md">传承之道</h2> | ||
| 21 | + <p class="text-xl text-white font-semibold drop-shadow-sm">大理鸡足山游学</p> | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 24 | + </div> | ||
| 25 | + | ||
| 26 | + <!-- Today's Live --> | ||
| 27 | + <div class="px-4 mb-4"> | ||
| 28 | + <div class="flex items-center mb-2"> | ||
| 29 | + <h2 class="font-medium">今日直播</h2> | ||
| 30 | + <div | ||
| 31 | + class="ml-2 flex items-center bg-red-100 text-red-700 rounded px-2 py-1 text-xs" | ||
| 32 | + > | ||
| 33 | + <span class="font-medium">{{ hours }}</span> | ||
| 34 | + <span class="mx-1">:</span> | ||
| 35 | + <span class="font-medium">{{ minutes }}</span> | ||
| 36 | + <span class="mx-1">:</span> | ||
| 37 | + <span class="font-medium">00</span> | ||
| 38 | + </div> | ||
| 39 | + </div> | ||
| 40 | + | ||
| 41 | + <!-- Live Stream Cards --> | ||
| 42 | + <div class="grid grid-cols-2 gap-4"> | ||
| 43 | + <LiveStreamCard | ||
| 44 | + v-for="stream in liveStreams" | ||
| 45 | + :key="stream.id" | ||
| 46 | + :stream="stream" | ||
| 47 | + /> | ||
| 48 | + </div> | ||
| 49 | + </div> | ||
| 50 | + | ||
| 51 | + <!-- Value Online Courses --> | ||
| 52 | + <div class="px-4 mb-4"> | ||
| 53 | + <div class="flex justify-between items-center mb-2"> | ||
| 54 | + <h2 class="font-medium">超值线上课</h2> | ||
| 55 | + <router-link to="#" class="text-xs text-gray-500 flex items-center"> | ||
| 56 | + 更多 | ||
| 57 | + <svg | ||
| 58 | + xmlns="http://www.w3.org/2000/svg" | ||
| 59 | + class="h-3 w-3 ml-1" | ||
| 60 | + fill="none" | ||
| 61 | + viewBox="0 0 24 24" | ||
| 62 | + stroke="currentColor" | ||
| 63 | + > | ||
| 64 | + <path | ||
| 65 | + stroke-linecap="round" | ||
| 66 | + stroke-linejoin="round" | ||
| 67 | + stroke-width="2" | ||
| 68 | + d="M9 5l7 7-7 7" | ||
| 69 | + /> | ||
| 70 | + </svg> | ||
| 71 | + </router-link> | ||
| 72 | + </div> | ||
| 73 | + | ||
| 74 | + <!-- Course Cards --> | ||
| 75 | + <div class="space-y-4"> | ||
| 76 | + <CourseCard v-for="course in courses" :key="course.id" :course="course" /> | ||
| 77 | + </div> | ||
| 78 | + </div> | ||
| 79 | + </div> | ||
| 80 | + </AppLayout> | ||
| 81 | +</template> | ||
| 82 | + | ||
| 83 | +<script setup lang="jsx"> | ||
| 84 | +import { computed, defineComponent, h } from "vue"; | ||
| 85 | +import AppLayout from "@/components/layout/AppLayout.vue"; | ||
| 86 | +import SearchBar from "@/components/ui/SearchBar.vue"; | ||
| 87 | +import FrostedGlass from "@/components/ui/FrostedGlass.vue"; | ||
| 88 | +import CourseCard from "@/components/ui/CourseCard.vue"; | ||
| 89 | +import LiveStreamCard from "@/components/ui/LiveStreamCard.vue"; | ||
| 90 | +import { featuredCourse, liveStreams, courses } from "@/utils/mockData"; | ||
| 91 | + | ||
| 92 | +// Search handler | ||
| 93 | +const handleSearch = (query) => { | ||
| 94 | + console.log("Searching for:", query); | ||
| 95 | + // Would implement actual search logic here | ||
| 96 | +}; | ||
| 97 | + | ||
| 98 | +// Current time for the countdown timer | ||
| 99 | +const todayDate = new Date(); | ||
| 100 | +const formattedTime = featuredCourse.liveTime.split(":"); | ||
| 101 | +const hours = computed(() => formattedTime[0]); | ||
| 102 | +const minutes = computed(() => formattedTime[1]); | ||
| 103 | + | ||
| 104 | +// Right content component | ||
| 105 | + | ||
| 106 | +const RightContent = defineComponent({ | ||
| 107 | + setup() { | ||
| 108 | + return () => ( | ||
| 109 | + <button class="p-2"> | ||
| 110 | + <svg | ||
| 111 | + xmlns="http://www.w3.org/2000/svg" | ||
| 112 | + class="h-6 w-6 text-gray-700" | ||
| 113 | + fill="none" | ||
| 114 | + viewBox="0 0 24 24" | ||
| 115 | + stroke="currentColor" | ||
| 116 | + > | ||
| 117 | + <path | ||
| 118 | + stroke-linecap="round" | ||
| 119 | + stroke-linejoin="round" | ||
| 120 | + stroke-width="2" | ||
| 121 | + d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z" | ||
| 122 | + /> | ||
| 123 | + </svg> | ||
| 124 | + </button> | ||
| 125 | + ); | ||
| 126 | + }, | ||
| 127 | +}); | ||
| 128 | + | ||
| 129 | +const rightContent = h(RightContent); | ||
| 130 | +</script> |
-
Please register or login to post a comment