Skip to content

Commit f11a004

Browse files
long-wooivyhaswell
authored andcommitted
fix: 修复下载无法输入文件名问题
1 parent a8ef7f3 commit f11a004

File tree

1 file changed

+8
-2
lines changed
  • playground/page/application/file-manager/download/demo

1 file changed

+8
-2
lines changed

playground/page/application/file-manager/download/demo/create.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect, useMemo } from 'react'
2-
import { Form, Input, Modal } from 'antd'
2+
import { Form, Input, message, Modal } from 'antd'
33
import { EllipsisOutlined } from '@ant-design/icons'
44

55
import {
@@ -39,6 +39,11 @@ const CreateModal = ({ show, onClose }: CreateModalProps) => {
3939

4040
// 下载开始
4141
const handleOk = async () => {
42+
if (!/^(http(s?)|ftp|blob):|data:.*;base64/.test(formData.url)) {
43+
message.error('下载地址只支持 http、ftp、base64、blob 协议')
44+
return
45+
}
46+
4247
const item = await newDownloadFile(formData)
4348
if (!item) return
4449

@@ -104,6 +109,7 @@ const CreateModal = ({ show, onClose }: CreateModalProps) => {
104109
<Form labelCol={{ span: 3 }}>
105110
<Form.Item label='地址:'>
106111
<Input
112+
placeholder='支持 http、ftp、base64、blob 协议'
107113
value={formData?.url}
108114
onChange={e => handleFormChange('url', e.target.value)}
109115
onFocus={handleFocus}
@@ -112,7 +118,7 @@ const CreateModal = ({ show, onClose }: CreateModalProps) => {
112118
<Form.Item label='文件名:'>
113119
<Input
114120
value={formData?.fileName}
115-
onChange={e => handleFormChange('filename', e.target.value)}
121+
onChange={e => handleFormChange('fileName', e.target.value)}
116122
onFocus={handleFocus}
117123
/>
118124
</Form.Item>

0 commit comments

Comments
 (0)