mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 19:08:45 +08:00
修复 file downloadUrl 处理不正确的问题
This commit is contained in:
parent
6ff5214522
commit
ce86019b71
@ -538,7 +538,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
const apiObject = normalizeApi(api);
|
||||
|
||||
if (apiObject.method?.toLowerCase() === 'get' && !apiObject.data) {
|
||||
window.open(apiObject.url);
|
||||
window.open(buildApi(apiObject, ctx).url);
|
||||
} else {
|
||||
apiObject.responseType = apiObject.responseType ?? 'blob';
|
||||
env.fetcher(apiObject, ctx, {
|
||||
@ -1100,6 +1100,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
} = this.props;
|
||||
let {files, uploading, error} = this.state;
|
||||
const nameField = this.props.nameField || 'name';
|
||||
const urlField = this.props.urlField || 'url';
|
||||
|
||||
const hasPending = files.some(file => file.state == 'pending');
|
||||
|
||||
@ -1181,7 +1182,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
})}
|
||||
>
|
||||
<Icon icon="file" className="icon" />
|
||||
{(file as FileValue).url || downloadUrl ? (
|
||||
{(file as FileValue)[urlField] || downloadUrl ? (
|
||||
<a
|
||||
className={cx('FileControl-itemInfoText')}
|
||||
target="_blank"
|
||||
|
@ -22,7 +22,10 @@ interface ApiCacheConfig extends ApiObject {
|
||||
|
||||
const apiCaches: Array<ApiCacheConfig> = [];
|
||||
|
||||
export function normalizeApi(api: Api, defaultMethod?: string): ApiObject {
|
||||
export function normalizeApi(
|
||||
api: Api,
|
||||
defaultMethod: string = 'get'
|
||||
): ApiObject {
|
||||
if (typeof api === 'string') {
|
||||
let method = rSchema.test(api) ? RegExp.$1 : '';
|
||||
method && (api = api.replace(method + ':', ''));
|
||||
|
Loading…
Reference in New Issue
Block a user