From 1d6eb48bb642e444168ce35466fc9b6f857fe756 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 18:59:32 +0800 Subject: [PATCH 001/260] add --- .../src/components/common/input/InputList.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/common/input/InputList.tsx b/apps/web/src/components/common/input/InputList.tsx index f6247d5..b0964a5 100644 --- a/apps/web/src/components/common/input/InputList.tsx +++ b/apps/web/src/components/common/input/InputList.tsx @@ -1,22 +1,29 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Input, Button } from "antd"; import { DeleteOutlined } from "@ant-design/icons"; interface InputListProps { - initialValue?: string[]; + value?: string[]; onChange?: (value: string[]) => void; placeholder?: string; } const InputList: React.FC = ({ - initialValue, + value, onChange, placeholder = "请输入内容", }) => { // Internal state management with fallback to initial value or empty array - const [inputValues, setInputValues] = useState( - initialValue && initialValue.length > 0 ? initialValue : [""] - ); + const [inputValues, setInputValues] = useState([""]); + + // Update inputValues when value changes + useEffect(() => { + if (value && value.length > 0) { + setInputValues(value); + } else { + setInputValues([""]); + } + }, [value]); // Handle individual input value change const handleInputChange = (index: number, newValue: string) => { From 079a705d9e29da39ae85439eff0bd70d62df5138 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 18:59:38 +0800 Subject: [PATCH 002/260] add --- .../src/components/models/course/detail/CourseDetailContext.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/web/src/components/models/course/detail/CourseDetailContext.tsx b/apps/web/src/components/models/course/detail/CourseDetailContext.tsx index c67a896..62e1be6 100755 --- a/apps/web/src/components/models/course/detail/CourseDetailContext.tsx +++ b/apps/web/src/components/models/course/detail/CourseDetailContext.tsx @@ -10,6 +10,7 @@ interface CourseDetailContextType { selectedLectureId?: string | undefined; setSelectedLectureId?: React.Dispatch>; isLoading?: boolean; + lectureIsLoading?: boolean; isHeaderVisible: boolean; // 新增 setIsHeaderVisible: (visible: boolean) => void; // 新增 } @@ -59,6 +60,7 @@ export function CourseDetailProvider({ selectedLectureId, setSelectedLectureId, isLoading, + lectureIsLoading, isHeaderVisible, setIsHeaderVisible, }}> From 0e9ac6713a4f9ea21bcc81a86aea8eceae8b6675 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 18:59:42 +0800 Subject: [PATCH 003/260] add --- .../course/detail/CourseDetailDisplayArea.tsx | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/apps/web/src/components/models/course/detail/CourseDetailDisplayArea.tsx b/apps/web/src/components/models/course/detail/CourseDetailDisplayArea.tsx index 3a2d6ff..ee99da1 100755 --- a/apps/web/src/components/models/course/detail/CourseDetailDisplayArea.tsx +++ b/apps/web/src/components/models/course/detail/CourseDetailDisplayArea.tsx @@ -6,6 +6,7 @@ import { CourseDetailDescription } from "./CourseDetailDescription/CourseDetailD import { Course, LectureType, PostType } from "@nice/common"; import { CourseDetailContext } from "./CourseDetailContext"; import CollapsibleContent from "@web/src/components/common/container/CollapsibleContent"; +import { Skeleton } from "antd"; interface CourseDetailDisplayAreaProps { // course: Course; @@ -18,18 +19,17 @@ export const CourseDetailDisplayArea: React.FC< CourseDetailDisplayAreaProps > = ({ videoSrc, videoPoster }) => { // 创建滚动动画效果 - const { course, isLoading, lecture } = useContext(CourseDetailContext); + const { course, isLoading, lecture, lectureIsLoading } = + useContext(CourseDetailContext); const { scrollY } = useScroll(); - const videoScale = useTransform(scrollY, [0, 200], [1, 0.8]); const videoOpacity = useTransform(scrollY, [0, 200], [1, 0.8]); - const contentWrapperRef = useRef(null); - const [isExpanded, setIsExpanded] = useState(false); - const [shouldCollapse, setShouldCollapse] = useState(false); return (
{/* 固定的视频区域 */} - {/* 移除 sticky 定位,让视频区域随页面滚动 */} - {lecture?.meta?.type === LectureType.VIDEO && ( + {lectureIsLoading && ( + + )} + {!lectureIsLoading && lecture?.meta?.type === LectureType.VIDEO && ( )} - {lecture?.meta?.type === LectureType.ARTICLE && ( -
-
- + {!lectureIsLoading && + lecture?.meta?.type === LectureType.ARTICLE && ( +
+
+ +
-
- )} + )} {/* 课程内容区域 */} ); }; + export default CourseDetailDisplayArea; From cbba92b380bc5febb6b064a226da5a3e35db625c Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 20:12:20 +0800 Subject: [PATCH 004/260] add --- .../CourseContentForm/SortableLecture.tsx | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableLecture.tsx b/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableLecture.tsx index 4f11be4..42fbfef 100755 --- a/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableLecture.tsx +++ b/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableLecture.tsx @@ -13,6 +13,7 @@ import { LectureType, LessonTypeLabel, PostType } from "@nice/common"; import { usePost } from "@nice/client"; import toast from "react-hot-toast"; import { LectureData } from "./interface"; +import { env } from "@web/src/env"; interface SortableLectureProps { field: LectureData; @@ -43,6 +44,11 @@ export const SortableLecture: React.FC = ({ setLoading(true); const values = await form.validateFields(); let result; + const videoUrlId = Array.isArray(values?.videoUrlIds) + ? values.videoUrlIds[0] + : typeof values?.videoUrlIds === "string" + ? values.videoUrlIds + : undefined; if (!field.id) { result = await create.mutateAsync({ @@ -52,14 +58,17 @@ export const SortableLecture: React.FC = ({ title: values?.title, meta: { type: values?.meta?.type, - fileIds: values?.meta?.fileIds, + // fileIds: values?.meta?.fileIds, + videoUrl: videoUrlId + ? `http://${env.SERVER_IP}:${env.FILE_PORT}/uploads/${videoUrlId}/stream/index.m3u8` + : undefined, }, resources: { - connect: (values?.meta?.fileIds || []).map( - (fileId) => ({ + connect: [videoUrlId] + .filter(Boolean) + .map((fileId) => ({ fileId, - }) - ), + })), }, content: values?.content, }, @@ -73,14 +82,16 @@ export const SortableLecture: React.FC = ({ title: values?.title, meta: { type: values?.meta?.type, - fieldIds: values?.meta?.fileIds, + videoUrl: videoUrlId + ? `http://${env.SERVER_IP}:${env.FILE_PORT}/uploads/${videoUrlId}/stream/index.m3u8` + : undefined, }, resources: { - connect: (values?.meta?.fileIds || []).map( - (fileId) => ({ + connect: [videoUrlId] + .filter(Boolean) + .map((fileId) => ({ fileId, - }) - ), + })), }, content: values?.content, }, @@ -135,7 +146,7 @@ export const SortableLecture: React.FC = ({
{lectureType === LectureType.VIDEO ? ( From 564e275f2e5eb2f19c6a71288e5f399b6055b24a Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 20:12:25 +0800 Subject: [PATCH 005/260] add --- packages/common/src/models/post.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/common/src/models/post.ts b/packages/common/src/models/post.ts index a82d22a..d66a0d1 100755 --- a/packages/common/src/models/post.ts +++ b/packages/common/src/models/post.ts @@ -46,6 +46,7 @@ export type LectureMeta = { type?: string; videoUrl?: string; videoThumbnail?: string; + fileIds?: string[]; }; export type Lecture = Post & { From e212ec788bb25e85973c06830273a0ef451c29c1 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 21:41:14 +0800 Subject: [PATCH 006/260] add --- apps/server/src/models/base/base.tree.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/src/models/base/base.tree.service.ts b/apps/server/src/models/base/base.tree.service.ts index f62aecc..aa0e643 100755 --- a/apps/server/src/models/base/base.tree.service.ts +++ b/apps/server/src/models/base/base.tree.service.ts @@ -139,7 +139,7 @@ export class BaseTreeService< const result: any = await super.update(anyArgs, { tx: transaction }); - if (anyArgs.data.parentId !== current.parentId) { + if (anyArgs.data.parentId && anyArgs.data.parentId !== current.parentId) { await transaction[this.ancestryType].deleteMany({ where: { descendantId: result.id }, }); From 2ec36f32a8c223ecdafa86019e96f2643aee4428 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 21:41:17 +0800 Subject: [PATCH 007/260] add --- apps/server/src/models/post/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/server/src/models/post/utils.ts b/apps/server/src/models/post/utils.ts index 9185a0f..20bbe59 100755 --- a/apps/server/src/models/post/utils.ts +++ b/apps/server/src/models/post/utils.ts @@ -156,6 +156,7 @@ export async function setCourseInfo({ data }: { data: Post }) { sections.map((section) => section.id).includes(descendant.parentId) ); }); + sections.forEach((section) => { section.lectures = lectures.filter( (lecture) => lecture.parentId === section.id, From 51f5a8e3416581d87b40ce2fd780d26431d47b91 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 21:41:33 +0800 Subject: [PATCH 008/260] add --- .../detail/CourseDetailHeader/CourseDetailHeader.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/apps/web/src/components/models/course/detail/CourseDetailHeader/CourseDetailHeader.tsx b/apps/web/src/components/models/course/detail/CourseDetailHeader/CourseDetailHeader.tsx index bbcdffc..9cc983d 100755 --- a/apps/web/src/components/models/course/detail/CourseDetailHeader/CourseDetailHeader.tsx +++ b/apps/web/src/components/models/course/detail/CourseDetailHeader/CourseDetailHeader.tsx @@ -44,12 +44,7 @@ export const CourseDetailHeader = () => {

{course?.title}

- +
); }; From 8e28fbf9094c0eebedf560d8074fa93ab0831630 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 21:42:47 +0800 Subject: [PATCH 011/260] add --- .../video-player/VideoDisplay.tsx | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/apps/web/src/components/presentation/video-player/VideoDisplay.tsx b/apps/web/src/components/presentation/video-player/VideoDisplay.tsx index fb1b40d..b786739 100755 --- a/apps/web/src/components/presentation/video-player/VideoDisplay.tsx +++ b/apps/web/src/components/presentation/video-player/VideoDisplay.tsx @@ -14,6 +14,7 @@ export const VideoDisplay: React.FC = ({ onError, videoRef, setIsReady, + isPlaying, setIsPlaying, setError, setBufferingState, @@ -204,19 +205,21 @@ export const VideoDisplay: React.FC = ({ }, [src, onError, autoPlay]); return ( -