Commit c4b22a225d0088d87be0c0068f543366312521db

Authored by Vben
1 parent 60b80c96

fix(upload): make sure to carry custom parameters, fix #802

.gitignore
@@ -4,7 +4,8 @@ dist @@ -4,7 +4,8 @@ dist
4 .npmrc 4 .npmrc
5 .cache 5 .cache
6 6
7 -test/server/static 7 +tests/server/static
  8 +tests/server/static/upload
8 9
9 .local 10 .local
10 # local env files 11 # local env files
CHANGELOG.zh_CN.md
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 ### 🐛 Bug Fixes 3 ### 🐛 Bug Fixes
4 4
5 - **Table** 修复分页抖动问题 5 - **Table** 修复分页抖动问题
  6 +- **Upload** 确保携带自定义参数
6 7
7 ## 2.5.0(2021-06-20) 8 ## 2.5.0(2021-06-20)
8 9
src/utils/http/axios/Axios.ts
@@ -5,7 +5,7 @@ import axios from 'axios'; @@ -5,7 +5,7 @@ import axios from 'axios';
5 import qs from 'qs'; 5 import qs from 'qs';
6 import { AxiosCanceler } from './axiosCancel'; 6 import { AxiosCanceler } from './axiosCancel';
7 import { isFunction } from '/@/utils/is'; 7 import { isFunction } from '/@/utils/is';
8 -import { cloneDeep } from 'lodash-es'; 8 +import { cloneDeep, omit } from 'lodash-es';
9 import { ContentTypeEnum } from '/@/enums/httpEnum'; 9 import { ContentTypeEnum } from '/@/enums/httpEnum';
10 import { RequestEnum } from '/@/enums/httpEnum'; 10 import { RequestEnum } from '/@/enums/httpEnum';
11 11
@@ -136,8 +136,12 @@ export class VAxios { @@ -136,8 +136,12 @@ export class VAxios {
136 formData.append(key, params.data[key]); 136 formData.append(key, params.data[key]);
137 }); 137 });
138 } 138 }
139 -  
140 formData.append(params.name || 'file', params.file, params.filename); 139 formData.append(params.name || 'file', params.file, params.filename);
  140 + const customParams = omit(params, 'file', 'filename', 'file');
  141 +
  142 + Object.keys(customParams).forEach((key) => {
  143 + formData.append(key, customParams[key]);
  144 + });
141 145
142 return this.axiosInstance.request<T>({ 146 return this.axiosInstance.request<T>({
143 ...config, 147 ...config,
tests/server/static/upload/11.jpg deleted 100644 → 0

215 KB

tests/server/static/upload/5ab46a3cN616bdc41.jpg deleted 100644 → 0

114 KB

tests/server/static/upload/5ac1bf5fN2522b9dc.jpg deleted 100644 → 0

405 KB

tests/server/static/upload/5c9ccca8a27f0.png deleted 100644 → 0

2.68 KB

tests/server/static/upload/5c9ccca8b27f1.jpg deleted 100644 → 0

37.8 KB

tests/server/static/upload/5c9ccca8bc1e0.png deleted 100644 → 0

2.12 KB