From cbba92b380bc5febb6b064a226da5a3e35db625c Mon Sep 17 00:00:00 2001 From: ditiqi Date: Sun, 23 Feb 2025 20:12:20 +0800 Subject: [PATCH] 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 ? (