mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
fix upload behavior
This commit is contained in:
parent
2c97f92e75
commit
eaa634c895
@ -6,19 +6,24 @@ import "./index.less"
|
||||
|
||||
export default (props) => {
|
||||
const [value, setValue] = React.useState(props.ctx.currentValue)
|
||||
const [uploading, setUploading] = React.useState(false)
|
||||
|
||||
const uploadImage = async (req) => {
|
||||
setUploading(true)
|
||||
|
||||
const formData = new FormData()
|
||||
|
||||
formData.append("files", req.file)
|
||||
|
||||
const request = await window.app.api.withEndpoints("main").post.upload(formData, undefined).catch((error) => {
|
||||
console.error(error)
|
||||
antd.message.error(error)
|
||||
app.message.error(error)
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
setUploading(false)
|
||||
|
||||
if (request) {
|
||||
setValue(request.files[0].url)
|
||||
props.ctx.dispatchUpdate(request.files[0].url)
|
||||
@ -57,6 +62,7 @@ export default (props) => {
|
||||
>
|
||||
<Button
|
||||
icon={<Icons.Upload />}
|
||||
loading={uploading}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user