diff --git a/apps/web/src/components/common/editor/MindEditor.tsx b/apps/web/src/components/common/editor/MindEditor.tsx index 5693436..d49a126 100755 --- a/apps/web/src/components/common/editor/MindEditor.tsx +++ b/apps/web/src/components/common/editor/MindEditor.tsx @@ -21,6 +21,7 @@ import { useNavigate } from "react-router-dom"; import { useAuth } from "@web/src/providers/auth-provider"; import { MIND_OPTIONS } from "./constant"; export default function MindEditor({ id }: { id?: string }) { + //containerRef 容器ref instance 实例 const containerRef = useRef(null); const [instance, setInstance] = useState(null); const { isAuthenticated, user, hasSomePermissions } = useAuth(); @@ -31,7 +32,7 @@ export default function MindEditor({ id }: { id?: string }) { id, }, select: postDetailSelect, - }); + }, { enabled: Boolean(id) }); const canEdit: boolean = useMemo(() => { //登录了且是作者、超管、无id新建模式 const isAuth = isAuthenticated && user?.id === post?.author?.id; @@ -45,7 +46,7 @@ export default function MindEditor({ id }: { id?: string }) { const { handleFileUpload } = useTusUpload(); const [form] = Form.useForm(); useEffect(() => { - if (post?.id) { + if (post?.id && id) { read.mutateAsync({ data: { visitorId: user?.id || null, @@ -64,8 +65,8 @@ export default function MindEditor({ id }: { id?: string }) { deptIds: deptIds, }; post.terms?.forEach((term) => { - formData[term.taxonomyId] = term.id; // 假设 taxonomyName 是您在 Form.Item 中使用的 name - }); + formData[term.taxonomyId] = term.id // 假设 taxonomyName是您在 Form.Item 中使用的name + }) form.setFieldsValue(formData); } }, [post, form, instance, id]); @@ -87,6 +88,7 @@ export default function MindEditor({ id }: { id?: string }) { }); mind.init(MindElixir.new("新思维导图")); containerRef.current.hidden = true; + //挂载实例 setInstance(mind); }, [canEdit]); useEffect(() => { @@ -98,6 +100,7 @@ export default function MindEditor({ id }: { id?: string }) { } } }, [id, post, instance]); + //保存 按钮 函数 const handleSave = async () => { if (!instance) return; const values = form.getFieldsValue(); diff --git a/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx b/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx index bc84b18..90bcd04 100755 --- a/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx +++ b/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx @@ -82,7 +82,7 @@ export function CourseFormProvider({ }, [course, form]); const onSubmit = async (values: any) => { - console.log(values); + const sections = values?.sections || []; const deptIds = values?.deptIds || []; const termIds = taxonomies @@ -149,6 +149,7 @@ export function CourseFormProvider({ } }; + return ( ({ label: value,