2025-10-23 18:57:31 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<CourseLearning
|
|
|
|
|
|
v-if="courseId"
|
|
|
|
|
|
:course-id="courseId"
|
|
|
|
|
|
:chapter-index="chapterIndex"
|
|
|
|
|
|
:node-index="nodeIndex"
|
2025-10-24 18:28:35 +08:00
|
|
|
|
:back-button-text="taskId ? '返回任务详情' : '返回课程详情'"
|
2025-10-23 18:57:31 +08:00
|
|
|
|
@back="handleBack"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed } from 'vue';
|
|
|
|
|
|
import { useRouter, useRoute } from 'vue-router';
|
2025-10-27 17:29:25 +08:00
|
|
|
|
import { CourseLearning } from '@/views/public/course/components';
|
2025-10-23 18:57:31 +08:00
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
|
name: 'CourseStudyView'
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
|
|
|
|
|
|
// 从路由参数获取课程ID和节点索引
|
|
|
|
|
|
const courseId = computed(() => route.query.courseId as string || '');
|
|
|
|
|
|
const chapterIndex = computed(() => parseInt(route.query.chapterIndex as string) || 0);
|
|
|
|
|
|
const nodeIndex = computed(() => parseInt(route.query.nodeIndex as string) || 0);
|
2025-10-24 18:28:35 +08:00
|
|
|
|
const taskId = computed(() => route.query.taskId as string || '');
|
2025-10-23 18:57:31 +08:00
|
|
|
|
|
2025-10-24 18:28:35 +08:00
|
|
|
|
// 返回到上一页
|
2025-10-23 18:57:31 +08:00
|
|
|
|
function handleBack() {
|
2025-10-24 18:28:35 +08:00
|
|
|
|
// 如果有 taskId,返回任务详情页
|
|
|
|
|
|
if (taskId.value) {
|
|
|
|
|
|
router.push({
|
|
|
|
|
|
path: '/study-plan/task-detail',
|
|
|
|
|
|
query: {
|
|
|
|
|
|
taskId: taskId.value
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 否则返回课程详情页
|
|
|
|
|
|
router.push({
|
|
|
|
|
|
path: '/study-plan/course-detail',
|
|
|
|
|
|
query: {
|
|
|
|
|
|
courseId: courseId.value
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-10-23 18:57:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
// 此组件只是容器,样式由子组件处理
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|