1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React, { useState, useEffect } from 'react';
import { Modal, Progress, Button } from 'antd';
import ProgressDiy from './ProgressDiy';
const componentList = {
ProgressDiy,
};
export default function DiyModal(props) {
const [show, setShow] = useState(false);
const changeShow = (s) => {
setShow(s);
};
useEffect(() => {
window.showDiyModalInfo = {
// 对外暴露的接口.
open: () => {
changeShow(true);
},
close: () => {
changeShow(false);
},
ModalProps: {
title: '自定义弹框',
width: 1200,
bodyStyle: {
minHeight: '50vh',
overflowY: 'auto',
},
maskClosable: false,
onCancel: () => {
changeShow(false);
},
onOk: () => {
console.log('点击了确定按钮');
},
},
component: 'ProgressDiy',
componentProps: {
progressDefaultProps: {
type: 'circle',
strokeColor: {
'0%': '#108ee9',
'100%': '#87d068',
},
width: 200,
},
},
};
}, []);
const Component = window.showDiyModalInfo && !!window.showDiyModalInfo.component
? componentList[window.showDiyModalInfo.component]
: ProgressDiy;
return (
<div>
{
show &&
<Modal {...window.showDiyModalInfo?.ModalProps} visible={show}>
<Component componentProps={window.showDiyModalInfo.componentProps} />
</Modal>
}
</div>
);
}