fix: 修复图片上传回显、登录认证和API路径问题
- 修复上传图片响应解析,正确处理 Arco Upload 返回的 response 对象 - 修复后端 AuthInterceptor 路径匹配,正确放行 /api/auth/login 等公开接口 - 统一前端 API 路径配置,移除重复 /api 前缀 - 添加 /uploads 静态资源代理配置 - 修复图片 URL 生成,添加 origin 前缀确保回显正常
This commit is contained in:
@@ -145,13 +145,22 @@ const beforeUpload = (file) => {
|
||||
return true
|
||||
}
|
||||
|
||||
const onUploadSuccess = (response) => {
|
||||
if (response && response.data) {
|
||||
productForm.imageUrl = response.data
|
||||
Message.success('图片上传成功')
|
||||
} else if (typeof response === 'string') {
|
||||
productForm.imageUrl = response
|
||||
const onUploadSuccess = (uploadInfo) => {
|
||||
const response = uploadInfo.response
|
||||
console.log('Upload server response:', response)
|
||||
if (response && response.code === 0 && response.data) {
|
||||
const imageUrl = response.data
|
||||
console.log('Image URL from response:', imageUrl)
|
||||
if (imageUrl.startsWith('/')) {
|
||||
productForm.imageUrl = window.location.origin + imageUrl
|
||||
} else {
|
||||
productForm.imageUrl = imageUrl
|
||||
}
|
||||
console.log('Final imageUrl:', productForm.imageUrl)
|
||||
Message.success('图片上传成功')
|
||||
} else {
|
||||
console.warn('Unexpected response format:', response)
|
||||
Message.warning('上传成功,但无法解析图片地址')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user