From d95fdf0021cc21be005802fbb385d98385374f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Wed, 5 Jul 2023 20:28:45 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20fix=E5=A4=B4=E5=83=8F=E3=80=81=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E8=B5=84=E6=BA=90=E4=B8=8A=E4=BC=A0=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.js | 4 ++-- src/api/system/user.js | 3 ++- src/utils/request.js | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/common.js b/src/api/common.js index c57228f..7932a9f 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -5,7 +5,7 @@ export function upload(data) { url: '/common/UploadFile', method: 'POST', data: data, - headers: { "Content-Type": "multipart/form-data" }, + headers: { 'Content-Type': 'multipart/form-data' } }) } @@ -18,6 +18,6 @@ export function sendEmail(data) { return request({ url: '/common/SendEmail', method: 'POST', - data: data, + data: data }) } diff --git a/src/api/system/user.js b/src/api/system/user.js index c660261..b3477bf 100644 --- a/src/api/system/user.js +++ b/src/api/system/user.js @@ -116,7 +116,8 @@ export function uploadAvatar(data) { return request({ url: '/system/user/profile/avatar', method: 'post', - data: data + data: data, + headers: { 'Content-Type': 'multipart/form-data' } }) } diff --git a/src/utils/request.js b/src/utils/request.js index 3d507b2..e94874f 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -29,8 +29,9 @@ service.interceptors.request.use( config.headers['userName'] = useUserStore().userName } const method = config?.method || 'get' + const header = config?.headers['Content-Type'] ?? '' - if (method.toLowerCase() === 'post' || method.toLowerCase() === 'put') { + if ((method.toLowerCase() === 'post' || method.toLowerCase() === 'put') && header != 'multipart/form-data') { config.data = delEmptyQueryNodes(config.data) } return config