数据结构重构优化

This commit is contained in:
unknown
2023-08-07 12:58:05 +08:00
parent 2a6e451417
commit 0cda0e0a73
7 changed files with 52 additions and 27 deletions

View File

@@ -57,16 +57,18 @@ export const CourseCreate: React.FC<PropInterface> = ({
const [thumb, setThumb] = useState("");
const [type, setType] = useState("open");
const [chapterType, setChapterType] = useState(0);
const [chapters, setChapters] = useState<any>([]);
const [hours, setHours] = useState<any>([]);
const [chapters, setChapters] = useState<CourseChaptersModel[]>([]);
const [hours, setHours] = useState<number[]>([]);
const [chapterHours, setChapterHours] = useState<any>([]);
const [videoVisible, setVideoVisible] = useState(false);
const [treeData, setTreeData] = useState<any>([]);
const [treeData, setTreeData] = useState<CourseHourModel[]>([]);
const [addvideoCurrent, setAddvideoCurrent] = useState(0);
const [showDrop, setShowDrop] = useState(false);
const [attachmentVisible, setAttachmentVisible] = useState(false);
const [attachmentData, setAttachmentData] = useState<any>([]);
const [attachments, setAttachments] = useState<any>([]);
const [attachmentData, setAttachmentData] = useState<AttachmentDataModel[]>(
[]
);
const [attachments, setAttachments] = useState<number[]>([]);
useEffect(() => {
if (open) {
@@ -265,6 +267,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
setHours(keys);
setTreeData(data);
setVideoVisible(false);
console.log(keys, data);
};
const selectChapterData = (arr: any, videos: any) => {
@@ -444,7 +447,6 @@ export const CourseCreate: React.FC<PropInterface> = ({
const keys = [...chapterHours];
keys[index] = arr;
setChapterHours(keys);
const data = [...chapters];
const newArr: any = [];
for (let i = 0; i < arr.length; i++) {