🐛 fix头像、文章资源上传失败

This commit is contained in:
不做码农 2023-07-05 20:28:45 +08:00
parent 032d88c996
commit d95fdf0021
3 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@ export function upload(data) {
url: '/common/UploadFile', url: '/common/UploadFile',
method: 'POST', method: 'POST',
data: data, data: data,
headers: { "Content-Type": "multipart/form-data" }, headers: { 'Content-Type': 'multipart/form-data' }
}) })
} }
@ -18,6 +18,6 @@ export function sendEmail(data) {
return request({ return request({
url: '/common/SendEmail', url: '/common/SendEmail',
method: 'POST', method: 'POST',
data: data, data: data
}) })
} }

View File

@ -116,7 +116,8 @@ export function uploadAvatar(data) {
return request({ return request({
url: '/system/user/profile/avatar', url: '/system/user/profile/avatar',
method: 'post', method: 'post',
data: data data: data,
headers: { 'Content-Type': 'multipart/form-data' }
}) })
} }

View File

@ -29,8 +29,9 @@ service.interceptors.request.use(
config.headers['userName'] = useUserStore().userName config.headers['userName'] = useUserStore().userName
} }
const method = config?.method || 'get' 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) config.data = delEmptyQueryNodes(config.data)
} }
return config return config