Skip to content

Commit

Permalink
fix(@uform/antd): fix upload field is not work when uploading some fi…
Browse files Browse the repository at this point in the history
…les #18
  • Loading branch information
janryWang committed Apr 28, 2019
1 parent 1838894 commit fbc22e7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing Guide

Hi! I’m really excited that you are interested in contributing to Rax. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.
Hi! I’m really excited that you are interested in contributing to UForm. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.

- [Issue Reporting Guidelines](#issue-reporting-guidelines)
- [Pull Request Guidelines](#pull-request-guidelines)
Expand All @@ -17,7 +17,7 @@ Hi! I’m really excited that you are interested in contributing to Rax. Before

- Try to search for your issue, it may have already been answered or even fixed in the development branch.

- Check if the issue is reproducible with the latest stable version of Rax. If you are using a pre-release, please indicate the specific version you are using.
- Check if the issue is reproducible with the latest stable version of UForm. If you are using a pre-release, please indicate the specific version you are using.

- It is **required** that you clearly describe the steps necessary to reproduce the issue you are running into. Issues with no clear repro steps will not be triaged. If an issue labeled "need repro" receives no further input from the issue author for more than 5 days, it will be closed.

Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

- What is the current behavior?
- What is the expected behavior?
- Which versions of Rax, and which browser / OS are affected by this issue?
- Did this work in previous versions of Rax?
- Which versions of UForm?
- Did this work in previous versions of UForm?

3. If your issue is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via [Bug Report Template](http://codepen.io/taobaofed/pen/oByQGb) on CodePen
3. If your issue is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via [Bug Report Template](https://codesandbox.io/s/1ry7zxv983) on CodeSandbox
.
4 changes: 3 additions & 1 deletion docs/Examples/antd/Sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ ReactDOM.render(
type="upload"
title="卡片上传文件"
name="upload"
x-props={{ listType: 'card' }}
x-props={{
listType: 'card',
}}
/>
<Field
type="upload"
Expand Down
6 changes: 5 additions & 1 deletion docs/Examples/next/Detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ const App = () => {
type="upload"
title="卡片上传文件"
name="upload"
x-props={{ listType: 'card' }}
x-props={{
listType: 'card',
action:
'https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload'
}}
/>
<Field
type="upload"
Expand Down
12 changes: 7 additions & 5 deletions packages/antd/src/fields/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const testOpts = (ext, options) => {
const getImageByUrl = (url, options) => {
for (let i = 0; i < exts.length; i++) {
if (exts[i].ext.test(url) && testOpts(exts[i].ext, options)) {
return exts[i].icon
return exts[i].icon || url
}
}

Expand All @@ -101,10 +101,12 @@ const normalizeFileList = fileList => {
if (fileList && fileList.length) {
return fileList.map(file => {
return {
uid: file.uid,
status: file.status,
name: file.name,
downloadURL: file.downloadURL || file.imgURL,
url: file.downloadURL || file.imgURL || file.url,
...file.response,
imgURL: getImageByUrl(file.imgURL, {
thumbUrl: getImageByUrl(file.imgURL || file.downloadURL || file.url, {
exclude: ['.png', '.jpg', '.jpeg', '.gif']
})
}
Expand Down Expand Up @@ -140,7 +142,7 @@ registerFormField(
})(
class Uploader extends React.Component {
static defaultProps = {
action: '',
action: 'https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload',
listType: 'text',
multiple: true,
className: 'antd-uploader'
Expand Down Expand Up @@ -182,7 +184,7 @@ registerFormField(
onChange(fileList.length > 0 ? fileList : undefined)
}
)
} else if (file.status !== 'error' && file.status !== 'uploading') {
} else {
this.setState({
value: fileList
})
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/fields/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ registerFormField(
class Uploader extends React.Component {
static defaultProps = {
action:
'//www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload',
'https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload',
listType: 'text',
multiple: true
}
Expand Down

0 comments on commit fbc22e7

Please sign in to comment.