"use client"; import { useEffect, useState } from "react"; import { useParams } from "next/navigation"; import Link from "next/link"; import { Header } from "../../../components"; import { VideoPlayer } from "../../../components/VideoPlayer"; import { LessonMarkdown } from "./LessonMarkdown"; import { LessonLayout } from "@/app/components/content/LessonLayout"; import { getLesson } from "../../../config/lessons"; import { canWatchLesson } from "../../../lib/payment"; import { setLastWatched, markCompleted, getCompletedLessons } from "../../../lib/learning"; import { CURRICULUM_CONFIG, DOWNLOAD_CONFIG } from "../../../config/course"; import { CLOUDPHONE_COURSE_CONFIG } from "@/config/content.config"; import { getPrevNextLesson } from "@/lib/content/course-utils"; const TOTAL_LESSONS = CURRICULUM_CONFIG.modules.reduce((s, m) => s + m.lessons.length, 0); export default function LessonPage() { const params = useParams(); const moduleIndex = Number(params.moduleIndex); const lessonIndex = Number(params.lessonIndex); const lesson = getLesson(moduleIndex, lessonIndex); const unlocked = canWatchLesson(moduleIndex, lessonIndex); const isFreeTrial = moduleIndex === 0 && lessonIndex < 2; const [completed, setCompleted] = useState(() => getCompletedLessons().size); const { prev: prevLesson, next: nextLesson } = getPrevNextLesson( CURRICULUM_CONFIG.modules, moduleIndex, lessonIndex ); useEffect(() => { if (lesson && unlocked) setLastWatched(moduleIndex, lessonIndex, lesson.name); }, [moduleIndex, lessonIndex, lesson?.name, unlocked]); useEffect(() => { const onProgress = () => setCompleted(getCompletedLessons().size); window.addEventListener("learning:progress", onProgress); return () => window.removeEventListener("learning:progress", onProgress); }, []); if (!lesson || isNaN(moduleIndex) || isNaN(lessonIndex)) { return (

章节不存在

请检查链接或返回课程首页

← 返回首页
); } return (
{unlocked ? ( markCompleted(moduleIndex, lessonIndex)} /> ) : (
🔒

报名解锁本章节

立即报名
)}
{unlocked && (

配套文档

)} {DOWNLOAD_CONFIG.enabled && unlocked && (

{DOWNLOAD_CONFIG.title}

课程配套资料已上传至网盘,报名后可前往下载

{DOWNLOAD_CONFIG.buttonText}
)}
); }