"use client"; import Link from "next/link"; import { getLastWatched, getProgress } from "@/app/cloudphone/lib/learning"; import { CURRICULUM_CONFIG } from "@/app/cloudphone/config/course"; import { useState, useEffect } from "react"; import styles from "../vip.module.css"; const TOTAL_LESSONS = CURRICULUM_CONFIG.modules.reduce((s, m) => s + m.lessons.length, 0); export function ContinueLearning() { const [last, setLast] = useState>(null); const [progress, setProgress] = useState({ completed: 0, percent: 0 }); useEffect(() => { setLast(getLastWatched()); setProgress(getProgress(TOTAL_LESSONS)); const onProgress = () => { setLast(getLastWatched()); setProgress(getProgress(TOTAL_LESSONS)); }; window.addEventListener("learning:progress", onProgress); return () => window.removeEventListener("learning:progress", onProgress); }, []); if (!last || progress.completed >= TOTAL_LESSONS) { return (

继续学习

{progress.completed >= TOTAL_LESSONS ? "复习课程" : "开始学习"} →
); } const module = CURRICULUM_CONFIG.modules[last.moduleIndex]; const lesson = module?.lessons[last.lessonIndex]; const title = lesson?.name || `第 ${last.moduleIndex + 1} 章`; return (

继续学习

{title}
进度 {progress.completed}/{TOTAL_LESSONS} 节
继续学习 →
); }