diff --git a/src/forge/Wiki/components/ModalFun/index.jsx b/src/forge/Wiki/components/ModalFun/index.jsx index 73fbfd379..d9a62e8fd 100644 --- a/src/forge/Wiki/components/ModalFun/index.jsx +++ b/src/forge/Wiki/components/ModalFun/index.jsx @@ -1,8 +1,16 @@ +/* eslint-disable react/jsx-no-duplicate-props */ import React, { useState } from 'react'; import * as ReactDOM from 'react-dom'; import { Modal, Button } from 'antd'; import './index.scss'; +InitModal.defaultProps = { + okText: '确认', //确定按钮的文字 + cancelText: '取消', //取消按钮的文字 + className: '', // + inputId: 'copyText', //要复制的文本的ID +}; + // 使用函数调用删除组件 export default function DelModal(props) { renderModal({ ...props, type: 'delete' }) @@ -14,11 +22,12 @@ export function Confirm(props) { } function renderModal(props) { - const type = props.type; + const { type, afterClose } = props; const div = document.createElement('div'); document.body.appendChild(div); function destroy() { + afterClose && afterClose(); const unmountResult = ReactDOM.unmountComponentAtNode(div); if (unmountResult && div.parentNode) { div.parentNode.removeChild(div); @@ -27,11 +36,22 @@ function renderModal(props) { function modalType(type) { if (type === 'delete') { - return + return + + {props.contentTitle} + } + /> } else if (type === 'confirm') { - return + return } else { - return + return } } @@ -46,17 +66,17 @@ function renderModal(props) { render(); } - -// 删除组件 -function DeleteModal({ +// 选择模态框组件 +function InitModal({ onCancel, onOk, title, contentTitle, content, - afterClose, okText, cancelText, + afterClose, + className, }) { const [visible, setVisible] = useState(true); @@ -77,66 +97,14 @@ function DeleteModal({ onCancel={onCancelModal} afterClose={afterClose} title={title} - className="myself-modal" + className={`myself-modal ${className}`} centered footer={[ , , - ]} - > -
-

- - {contentTitle}

-

{content}

-
- - ) -} - - -// 选择模态框组件 -function ConfirmModal({ - onCancel, - onOk, - title, - contentTitle, - content, - okText, - cancelText, - afterClose, -}) { - - const [visible, setVisible] = useState(true); - - function onCancelModal() { - setVisible(false); - onCancel && onCancel() - } - - function onSuccess() { - setVisible(false); - onOk && onOk(); - } - - return ( - - {cancelText||'取消'} - , - , ]} >