diff --git a/apps/admin/src/view/Course/Create/Chatpter/index.less b/apps/admin/src/view/Course/Create/Chatpter/index.less new file mode 100644 index 0000000..17caf3f --- /dev/null +++ b/apps/admin/src/view/Course/Create/Chatpter/index.less @@ -0,0 +1,12 @@ +.chapter-list { + li { + display: flex; + justify-content: space-between; + &.l1 { + margin-top: 20px; + &:first-of-type { + margin-top: 0; + } + } + } +} diff --git a/apps/admin/src/view/Course/Create/Chatpter/index.tsx b/apps/admin/src/view/Course/Create/Chatpter/index.tsx index 9fd791e..27f24f8 100644 --- a/apps/admin/src/view/Course/Create/Chatpter/index.tsx +++ b/apps/admin/src/view/Course/Create/Chatpter/index.tsx @@ -1,69 +1,80 @@ import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons"; -import { Button, Col, Form, Input, Row, Space, Typography } from "antd"; +import { + Button, + Checkbox, + Col, + Form, + Input, + Radio, + Row, + Space, + Typography, +} from "antd"; const { Text } = Typography; +import {} from "antd"; +import { useEffect, useState } from "react"; +import "./index.less"; interface IProps { onChange?: Function; styles?: React.CSSProperties; } +interface IChapter { + level: string; + title: string; + fileId?: string; +} + const Chatpter = (props: IProps) => { const [form] = Form.useForm(); + const [chapterList, setChapterList] = useState([]); - const onBlur = () => { - console.log(form.getFieldsValue().chapter); + const onTocChange = () => { + const { toc } = form.getFieldsValue(); + const process = toc.split("\n").map((row: string) => { + const [level, title, fileId] = row.split("|"); + return !fileId ? { level, title } : { level, title, fileId }; + }); + setChapterList(process); }; + useEffect(() => { + console.log(chapterList); + }, [chapterList]); + return (
-
- - {(fields, { add, remove }, { errors }) => ( - <> - {fields.map((field, index) => ( - - - - {JSON.stringify(field)} - - {fields.length > 1 ? ( - remove(field.name)} /> - ) : null} - - ))} - - - - - - - - )} - -
+ + +
+ + + +
+ + +
    + {chapterList.map((chapter, index) => ( +
  • + + {chapter.title} + + {chapter.fileId && ( + {chapter.fileId} + )} +
  • + ))} +
+ +
); };