diff --git a/.gitignore b/.gitignore index 2f4e661106807de4857577577a4bd43ecde460da..a4b670db709815f8c262a5157e5acf3769bf21b5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,8 @@ dist .npmrc .cache -test/server/static +tests/server/static +tests/server/static/upload .local # local env files diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 8b0f54cc39d26af2fa519a2bbe5ed99997447924..8b9faa1bc31dbbf907d5032949af9b4e1615309f 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -3,6 +3,7 @@ ### 🐛 Bug Fixes - **Table** 修复分页抖动问题 +- **Upload** 确保携带自定义参数 ## 2.5.0(2021-06-20) diff --git a/src/utils/http/axios/Axios.ts b/src/utils/http/axios/Axios.ts index 855ffb53d0d88837e789b1f572189331216edd32..f7882a748dd0f50b578400ff2aa1a9bd8d58bd09 100644 --- a/src/utils/http/axios/Axios.ts +++ b/src/utils/http/axios/Axios.ts @@ -5,7 +5,7 @@ import axios from 'axios'; import qs from 'qs'; import { AxiosCanceler } from './axiosCancel'; import { isFunction } from '/@/utils/is'; -import { cloneDeep } from 'lodash-es'; +import { cloneDeep, omit } from 'lodash-es'; import { ContentTypeEnum } from '/@/enums/httpEnum'; import { RequestEnum } from '/@/enums/httpEnum'; @@ -136,8 +136,12 @@ export class VAxios { formData.append(key, params.data[key]); }); } - formData.append(params.name || 'file', params.file, params.filename); + const customParams = omit(params, 'file', 'filename', 'file'); + + Object.keys(customParams).forEach((key) => { + formData.append(key, customParams[key]); + }); return this.axiosInstance.request({ ...config, diff --git a/tests/server/static/upload/11.jpg b/tests/server/static/upload/11.jpg deleted file mode 100644 index 5a63c3df032bec24a33ee9fc22508fdc629bc941..0000000000000000000000000000000000000000 Binary files a/tests/server/static/upload/11.jpg and /dev/null differ diff --git a/tests/server/static/upload/5ab46a3cN616bdc41.jpg b/tests/server/static/upload/5ab46a3cN616bdc41.jpg deleted file mode 100644 index d5cb2bb6f74ff73bc53264148c09f5373ba947ca..0000000000000000000000000000000000000000 Binary files a/tests/server/static/upload/5ab46a3cN616bdc41.jpg and /dev/null differ diff --git a/tests/server/static/upload/5ac1bf5fN2522b9dc.jpg b/tests/server/static/upload/5ac1bf5fN2522b9dc.jpg deleted file mode 100644 index ee69ac62257cb5c2aff0a7ca26a654841c6036f6..0000000000000000000000000000000000000000 Binary files a/tests/server/static/upload/5ac1bf5fN2522b9dc.jpg and /dev/null differ diff --git a/tests/server/static/upload/5c9ccca8a27f0.png b/tests/server/static/upload/5c9ccca8a27f0.png deleted file mode 100644 index 5b82f6cbb7cabd53b5886efbfa54e54b61311cf1..0000000000000000000000000000000000000000 Binary files a/tests/server/static/upload/5c9ccca8a27f0.png and /dev/null differ diff --git a/tests/server/static/upload/5c9ccca8b27f1.jpg b/tests/server/static/upload/5c9ccca8b27f1.jpg deleted file mode 100644 index d678ec98c8d5b0c7c09236cb4580014553694727..0000000000000000000000000000000000000000 Binary files a/tests/server/static/upload/5c9ccca8b27f1.jpg and /dev/null differ diff --git a/tests/server/static/upload/5c9ccca8bc1e0.png b/tests/server/static/upload/5c9ccca8bc1e0.png deleted file mode 100644 index 2c320a2b3aee784f44f49910e4a1e253caaa7818..0000000000000000000000000000000000000000 Binary files a/tests/server/static/upload/5c9ccca8bc1e0.png and /dev/null differ