training_data/apps/web/src/components/models/course/detail/CourseDetailDisplayArea.tsx

92 lines
2.8 KiB
TypeScript
Raw Normal View History

2025-01-08 20:29:07 +08:00
// components/CourseDetailDisplayArea.tsx
2025-01-08 00:56:15 +08:00
import { motion, useScroll, useTransform } from "framer-motion";
2025-02-21 17:32:25 +08:00
import React, { useContext, useRef, useState } from "react";
2025-01-08 00:56:15 +08:00
import { VideoPlayer } from "@web/src/components/presentation/video-player/VideoPlayer";
2025-02-23 22:51:23 +08:00
import { CourseDetailDescription } from "./CourseDetailDescription";
2025-02-21 17:32:25 +08:00
import { Course, LectureType, PostType } from "@nice/common";
2025-02-21 16:11:02 +08:00
import { CourseDetailContext } from "./CourseDetailContext";
2025-02-21 17:32:25 +08:00
import CollapsibleContent from "@web/src/components/common/container/CollapsibleContent";
2025-02-23 18:59:42 +08:00
import { Skeleton } from "antd";
2025-02-24 10:16:42 +08:00
import { CoursePreview } from "./CoursePreview/CoursePreview";
2025-02-26 16:11:08 +08:00
import ResourcesShower from "@web/src/components/common/uploader/ResourceShower";
2025-02-26 23:01:58 +08:00
import {
BookOutlined,
CalendarOutlined,
EditTwoTone,
EyeOutlined,
ReloadOutlined,
} from "@ant-design/icons";
import dayjs from "dayjs";
import { useNavigate } from "react-router-dom";
import CourseDetailTitle from "./CourseDetailTitle";
2025-01-08 00:56:15 +08:00
2025-02-23 22:51:23 +08:00
// interface CourseDetailDisplayAreaProps {
// // course: Course;
// // videoSrc?: string;
// // videoPoster?: string;
// // isLoading?: boolean;
// }
2025-01-08 00:56:15 +08:00
2025-02-23 22:51:23 +08:00
export const CourseDetailDisplayArea: React.FC = () => {
2025-01-08 00:56:15 +08:00
// 创建滚动动画效果
2025-02-26 23:01:58 +08:00
const {
course,
isLoading,
canEdit,
lecture,
lectureIsLoading,
selectedLectureId,
} = useContext(CourseDetailContext);
const navigate = useNavigate();
2025-01-08 00:56:15 +08:00
const { scrollY } = useScroll();
const videoOpacity = useTransform(scrollY, [0, 200], [1, 0.8]);
return (
<div className="min-h-screen bg-gray-50">
{/* 固定的视频区域 */}
2025-02-23 18:59:42 +08:00
{lectureIsLoading && (
<Skeleton active paragraph={{ rows: 4 }} title={false} />
)}
2025-02-26 23:01:58 +08:00
<CourseDetailTitle></CourseDetailTitle>
2025-02-24 09:41:48 +08:00
{selectedLectureId &&
!lectureIsLoading &&
lecture?.meta?.type === LectureType.VIDEO && (
<div className="flex justify-center flex-col items-center gap-2 w-full mt-2 px-4">
<motion.div
style={{
opacity: videoOpacity,
}}
className="w-full bg-black rounded-lg ">
<div className=" w-full ">
<VideoPlayer src={lecture?.meta?.videoUrl} />
</div>
</motion.div>
</div>
)}
2025-02-23 18:59:42 +08:00
{!lectureIsLoading &&
2025-02-24 09:41:48 +08:00
selectedLectureId &&
2025-02-23 18:59:42 +08:00
lecture?.meta?.type === LectureType.ARTICLE && (
2025-02-27 21:45:40 +08:00
<div className="flex justify-center flex-col items-center gap-2 w-full my-2 ">
<div className="w-full rounded-lg ">
2025-02-23 18:59:42 +08:00
<CollapsibleContent
content={lecture?.content || ""}
2025-02-26 10:19:29 +08:00
maxHeight={500} // Optional, defaults to 150
2025-02-23 18:59:42 +08:00
/>
2025-02-26 16:11:08 +08:00
<div className="px-6">
<ResourcesShower
resources={
lecture?.resources
}></ResourcesShower>
</div>
2025-02-23 18:59:42 +08:00
</div>
2025-02-21 17:32:25 +08:00
</div>
2025-02-23 18:59:42 +08:00
)}
2025-02-26 23:01:58 +08:00
<div className="flex justify-center flex-col items-center gap-2 w-full my-2 ">
2025-02-24 10:16:42 +08:00
<CourseDetailDescription />
2025-02-23 22:51:23 +08:00
</div>
{/* 课程内容区域 */}
2025-01-08 00:56:15 +08:00
</div>
);
};
2025-02-23 18:59:42 +08:00
2025-01-08 20:29:07 +08:00
export default CourseDetailDisplayArea;