feat(StudyCoursePage): 添加goToStudyDetail方法并移除无用注释
在StudyCoursePage.vue中添加了goToStudyDetail方法,用于处理课程详情页面的跳转逻辑,并移除了无用的注释代码。同时,在main.js中添加了Array.prototype.at的polyfill,以支持旧版浏览器。
Showing
2 changed files
with
17 additions
and
4 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-05-08 12:23:36 | 4 | + * @LastEditTime: 2025-05-16 16:42:32 |
| 5 | * @FilePath: /mlaj/src/main.js | 5 | * @FilePath: /mlaj/src/main.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -23,6 +23,15 @@ import { faCirclePause, faCirclePlay, faPlay, faPause, faBackwardStep, faForward | ... | @@ -23,6 +23,15 @@ import { faCirclePause, faCirclePlay, faPlay, faPause, faBackwardStep, faForward |
| 23 | /* add icons to the library */ | 23 | /* add icons to the library */ |
| 24 | library.add(faCirclePause, faCirclePlay, faPlay, faPause, faBackwardStep, faForwardStep, faVolumeUp, faRedo, faRepeat, faList, faChevronDown, faVolumeOff, faXmark, faFileAlt, faTimes, faEye, faFilePdf, faExternalLinkAlt, faSpinner, faExclamationCircle, faDownload ) | 24 | library.add(faCirclePause, faCirclePlay, faPlay, faPause, faBackwardStep, faForwardStep, faVolumeUp, faRedo, faRepeat, faList, faChevronDown, faVolumeOff, faXmark, faFileAlt, faTimes, faEye, faFilePdf, faExternalLinkAlt, faSpinner, faExclamationCircle, faDownload ) |
| 25 | 25 | ||
| 26 | +if (!Array.prototype.at) { | ||
| 27 | + Array.prototype.at = function(n) { | ||
| 28 | + n = Math.trunc(n) || 0; | ||
| 29 | + if (n < 0) n += this.length; | ||
| 30 | + if (n < 0 || n >= this.length) return undefined; | ||
| 31 | + return this[n]; | ||
| 32 | + }; | ||
| 33 | +} | ||
| 34 | + | ||
| 26 | const app = createApp(App) | 35 | const app = createApp(App) |
| 27 | // 屏蔽警告信息 | 36 | // 屏蔽警告信息 |
| 28 | app.config.warnHandler = () => null; | 37 | app.config.warnHandler = () => null; | ... | ... |
| ... | @@ -73,11 +73,11 @@ | ... | @@ -73,11 +73,11 @@ |
| 73 | <div id="catalog" class="py-4"> | 73 | <div id="catalog" class="py-4"> |
| 74 | <div v-if="course_lessons.length" class="space-y-4"> | 74 | <div v-if="course_lessons.length" class="space-y-4"> |
| 75 | <div v-for="(lesson, index) in course_lessons" :key="index" | 75 | <div v-for="(lesson, index) in course_lessons" :key="index" |
| 76 | - @click="router.push(`/studyDetail/${lesson.id}`)" | 76 | + @click="goToStudyDetail(lesson.id)" |
| 77 | class="bg-white p-4 cursor-pointer hover:bg-gray-50 transition-colors border-b border-gray-200 relative"> | 77 | class="bg-white p-4 cursor-pointer hover:bg-gray-50 transition-colors border-b border-gray-200 relative"> |
| 78 | - <div v-if="lesson.progress > 0 && lesson.progress < 100" | 78 | + <!-- <div v-if="lesson.progress > 0 && lesson.progress < 100" |
| 79 | class="absolute top-2 right-2 px-2 py-1 bg-green-100 text-green-600 text-xs rounded"> | 79 | class="absolute top-2 right-2 px-2 py-1 bg-green-100 text-green-600 text-xs rounded"> |
| 80 | - 没有字段=>上次看到</div> | 80 | + 没有字段=>上次看到</div> --> |
| 81 | <div class="text-black text-base font-medium mb-2">{{ lesson.title }}</div> | 81 | <div class="text-black text-base font-medium mb-2">{{ lesson.title }}</div> |
| 82 | <div class="flex items-center text-sm text-gray-500"> | 82 | <div class="flex items-center text-sm text-gray-500"> |
| 83 | <span>{{ course_type_maps[lesson.course_type] }}</span> | 83 | <span>{{ course_type_maps[lesson.course_type] }}</span> |
| ... | @@ -317,6 +317,10 @@ const handleTabChange = (name) => { | ... | @@ -317,6 +317,10 @@ const handleTabChange = (name) => { |
| 317 | // } | 317 | // } |
| 318 | // ] | 318 | // ] |
| 319 | // }); | 319 | // }); |
| 320 | + | ||
| 321 | +const goToStudyDetail = (lessonId) => { | ||
| 322 | + router.push(`/studyDetail/${lessonId}`); | ||
| 323 | +}; | ||
| 320 | </script> | 324 | </script> |
| 321 | 325 | ||
| 322 | <style scoped> | 326 | <style scoped> | ... | ... |
-
Please register or login to post a comment