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-01-08 20:29:07 +08:00
|
|
|
import { CourseDetailDescription } from "./CourseDetailDescription/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-01-08 00:56:15 +08:00
|
|
|
|
2025-01-08 20:29:07 +08:00
|
|
|
interface CourseDetailDisplayAreaProps {
|
2025-02-21 16:11:02 +08:00
|
|
|
// course: Course;
|
2025-01-08 00:56:15 +08:00
|
|
|
videoSrc?: string;
|
|
|
|
videoPoster?: string;
|
2025-02-21 16:11:02 +08:00
|
|
|
// isLoading?: boolean;
|
2025-01-08 00:56:15 +08:00
|
|
|
}
|
|
|
|
|
2025-01-08 20:29:07 +08:00
|
|
|
export const CourseDetailDisplayArea: React.FC<
|
|
|
|
CourseDetailDisplayAreaProps
|
2025-02-21 16:11:02 +08:00
|
|
|
> = ({ videoSrc, videoPoster }) => {
|
2025-01-08 00:56:15 +08:00
|
|
|
// 创建滚动动画效果
|
2025-02-23 18:59:42 +08:00
|
|
|
const { course, isLoading, lecture, lectureIsLoading } =
|
|
|
|
useContext(CourseDetailContext);
|
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} />
|
|
|
|
)}
|
|
|
|
{!lectureIsLoading && lecture?.meta?.type === LectureType.VIDEO && (
|
2025-02-21 17:32:25 +08:00
|
|
|
<motion.div
|
|
|
|
style={{
|
|
|
|
opacity: videoOpacity,
|
|
|
|
}}
|
|
|
|
className="w-full bg-black">
|
2025-02-21 16:11:02 +08:00
|
|
|
<div className=" w-full ">
|
|
|
|
<VideoPlayer src={videoSrc} poster={videoPoster} />
|
|
|
|
</div>
|
2025-02-21 17:32:25 +08:00
|
|
|
</motion.div>
|
|
|
|
)}
|
2025-02-23 18:59:42 +08:00
|
|
|
{!lectureIsLoading &&
|
|
|
|
lecture?.meta?.type === LectureType.ARTICLE && (
|
|
|
|
<div className="flex justify-center w-full my-2">
|
|
|
|
<div className="w-4/5 bg-white shadow-md rounded-lg border border-gray-200 p-6 ">
|
|
|
|
<CollapsibleContent
|
|
|
|
content={lecture?.content || ""}
|
|
|
|
maxHeight={150} // Optional, defaults to 150
|
|
|
|
/>
|
|
|
|
</div>
|
2025-02-21 17:32:25 +08:00
|
|
|
</div>
|
2025-02-23 18:59:42 +08:00
|
|
|
)}
|
2025-01-08 00:56:15 +08:00
|
|
|
{/* 课程内容区域 */}
|
|
|
|
<motion.div
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
transition={{ duration: 0.5, delay: 0.2 }}
|
2025-01-08 20:29:07 +08:00
|
|
|
className="w-full">
|
|
|
|
<CourseDetailDescription
|
|
|
|
course={course}
|
|
|
|
isLoading={isLoading}
|
|
|
|
/>
|
2025-01-08 00:56:15 +08:00
|
|
|
</motion.div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2025-02-23 18:59:42 +08:00
|
|
|
|
2025-01-08 20:29:07 +08:00
|
|
|
export default CourseDetailDisplayArea;
|