From d1a3c7b9c3e67ae018f2351cb45c9673dc291f7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com>
Date: Mon, 23 Aug 2021 09:41:57 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=A0=E9=99=A4=E5=87=BD?=
=?UTF-8?q?=E6=95=B0=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/forge/Wiki/components/ModalFun/index.jsx | 94 +++++++-------------
1 file changed, 31 insertions(+), 63 deletions(-)
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||'取消'}
- ,
- ,
]}
>