import { useEffect, useState } from "react"; import { Modal, Space } from "antd"; import TermEdit from "./TermEdit"; import type { ITermDataResponse } from "../../api/Term"; import { Link } from "react-router"; interface IWidget { trigger?: React.ReactNode; open?: boolean; id?: string; word?: string; tags?: string[]; studioName?: string; channelId?: string; parentChannelId?: string; parentStudioId?: string; community?: boolean; onUpdate?: Function; onClose?: Function; } const TermModalWidget = ({ trigger, open = false, id, word, tags, studioName, channelId, parentChannelId, parentStudioId, community = false, onUpdate, onClose, }: IWidget) => { const [isModalOpen, setIsModalOpen] = useState(open); useEffect(() => { if (open) { showModal(); } else { modalClose(); } }, [open]); const modalClose = () => { setIsModalOpen(false); if (document.getElementsByTagName("body")[0].hasAttribute("style")) { document.getElementsByTagName("body")[0].removeAttribute("style"); } }; const showModal = () => { setIsModalOpen(true); }; const handleOk = () => { modalClose(); if (typeof onClose !== "undefined") { onClose(); } }; const handleCancel = () => { modalClose(); if (typeof onClose !== "undefined") { onClose(); } }; return ( <> {trigger} {"术语"} 在studio中打开 } footer={false} destroyOnHidden={true} open={isModalOpen} onOk={handleOk} onCancel={handleCancel} > { modalClose(); if (typeof onUpdate !== "undefined") { onUpdate(value); } }} /> ); }; export default TermModalWidget;