"use client"; import { useEffect, useState } from "react"; import { useParams, useRouter } from "next/navigation"; import { Link, useTranslation } from "@/i18n/navigation"; import { VideoPlayer } from "@/app/components/course/VideoPlayer"; import { LessonMarkdown } from "./LessonMarkdown"; import { getLesson } from "@/config/lessons"; import { canWatchLesson } from "@/app/lib/course-payment"; import { useAuthAndVip } from "@/app/lib/useAuthAndVip"; import { setLastWatched, markCompleted } from "@/app/lib/learning"; import { DOWNLOAD_CONFIG } from "@/config/course"; import Header from "@/app/components/Header"; export default function LessonPage() { const params = useParams(); const router = useRouter(); const { t } = useTranslation("community"); const { vip } = useAuthAndVip(); const [toast, setToast] = useState(false); const moduleIndex = Number(params.moduleIndex); const lessonIndex = Number(params.lessonIndex); const lesson = getLesson(moduleIndex, lessonIndex); const unlocked = canWatchLesson(moduleIndex, lessonIndex, vip); const isFreeTrial = moduleIndex === 0 && lessonIndex < 2; useEffect(() => { if (lesson && unlocked) setLastWatched(moduleIndex, lessonIndex, lesson.name); }, [moduleIndex, lessonIndex, lesson?.name, unlocked]); if (!lesson || isNaN(moduleIndex) || isNaN(lessonIndex)) { return (

章节不存在

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

← 返回首页
); } return (
{/* 返回导航 */} {/* 标题 */}

{lesson.name} {isFreeTrial && ( 试看 )}

时长 {lesson.duration}

{/* 视频播放器 / 锁定 overlay */}
{unlocked ? ( markCompleted(moduleIndex, lessonIndex)} /> ) : (
🔒

报名解锁本章节

立即报名
)}
{/* 配套文档 - 仅解锁后显示 */} {unlocked && (

配套文档

)} {/* 网盘下载 */} {DOWNLOAD_CONFIG.enabled && unlocked && (

{DOWNLOAD_CONFIG.title}

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

{DOWNLOAD_CONFIG.buttonText}
)}
{toast && (
{t("updating")}
)}
); }