({ closeShareModal, submitShare, title })
| 13 | isAutoApi: Boolean |
| 14 | } |
| 15 | const ShareModal: React.FC<Props> = ({ closeShareModal, submitShare, title }) => { |
| 16 | const [visible, setVisible] = useState<Boolean>(true); |
| 17 | const [customList, setCustomList] = useState<customList>({ url: 'https://moctest.sobeylingyun.com', title: title || '可视化预览 ', isAutoApi: false }) |
| 18 | const [isCustomUrl, setIsCustomUrl] = useState<Boolean>(false) // 是否自定义静态资源地址 |
| 19 | const handleCancel = () => { |
| 20 | closeShareModal() |
| 21 | setVisible(false) |
| 22 | }; |
| 23 | const handleOk = () => { |
| 24 | if (!isCustomUrl) { |
| 25 | customList.url = window.location.origin |
| 26 | } |
| 27 | submitShare(customList) |
| 28 | handleCancel() |
| 29 | setVisible(false) |
| 30 | }; |
| 31 | const onChange = (e: any, type: string) => { |
| 32 | setCustomList({ ...customList, [type]: e.target.value }) |
| 33 | } |
| 34 | const onChangeSwitch = (e: any, type: string) => { |
| 35 | if (type === 'customUrl') { |
| 36 | setIsCustomUrl(e) |
| 37 | } else { |
| 38 | setCustomList({ ...customList, isAutoApi: e }) |
| 39 | } |
| 40 | } |
| 41 | return ( |
| 42 | <Modal |
| 43 | title='下载' |
| 44 | visible={visible} |
| 45 | closable={false} |
| 46 | getContainer={document.getElementById('workspace')} |
| 47 | centered |
| 48 | onCancel={handleCancel} |
| 49 | onOk={handleOk} |
| 50 | > |
| 51 | <div className="share-modal"> |
| 52 | <Input prefix="页面标题" defaultValue={customList.title} onChange={e => onChange(e, 'title')} /> |
| 53 | <span>API地址根据部署环境自动获取<Switch onChange={e => onChangeSwitch(e, 'autoApi')} /></span> |
| 54 | <span>自定义静态资源 <Switch onChange={e => onChangeSwitch(e, 'customUrl')} /></span> |
| 55 | {/* {!isCustomUrl && <span>分享地址:http://172.16.128.31:9237/screen/iframe/productPreview.html?id={props.id}</span>} */} |
| 56 | {isCustomUrl && (<Input prefix="静态资源地址" defaultValue={customList.url} onChange={e => onChange(e, 'url')} />)} |
| 57 | |
| 58 | |
| 59 | </div> |
| 60 | </Modal > |
| 61 | ) |
| 62 | } |
| 63 | |
| 64 | export default ShareModal; |
nothing calls this directly
no test coverage detected