文件修改

This commit is contained in:
2025-09-02 16:50:08 +08:00
parent 96a47ecfc9
commit b1d9b93be9
3 changed files with 11 additions and 7 deletions

View File

@@ -208,13 +208,14 @@ const handleUploadSuccess = (response) => {
if (response.data.url) {
// 返回相对路径,去掉前缀
url = response.data.url.replace(/^.*\/uploads\//, '')
} else if (response.data.urls && Array.isArray(response.data.urls)) {
url = response.data.path
} else if (response.data.path && Array.isArray(response.data.path)) {
// 处理多文件上传返回的URLs数组
url = response.data.urls[0].replace(/^.*\/uploads\//, '')
url = response.data.path[0]
}
if (url) {
console.log(url);
images.value.push(url)
emit('update:modelValue', [...images.value])
emit('upload-success', response.data)

View File

@@ -1,11 +1,11 @@
// 环境配置
const config = {
development: {
baseURL: 'http://localhost:3001',
baseURL: 'https://minio.zrbjr.com',
uploadURL: 'http://localhost:3001/api/upload'
},
production: {
baseURL: window.location.origin,
baseURL: 'https://minio.zrbjr.com',
uploadURL: `${window.location.origin}/api/upload`
}
}
@@ -25,6 +25,7 @@ export const { baseURL, uploadURL } = config[env]
* @returns {string} 完整的图片URL
*/
export const getImageUrl = (imagePath) => {
const cleanBaseURL = baseURL.replace(/\/$/, '')
if (!imagePath) return ''
if (imagePath.startsWith('http')) return imagePath
@@ -36,11 +37,11 @@ export const getImageUrl = (imagePath) => {
return cleanPath
}
// 否则添加uploads前缀
return `/uploads/${imagePath}`
return `${cleanBaseURL}${imagePath}`
}
// 生产环境下使用完整URL
const cleanBaseURL = baseURL.replace(/\/$/, '')
let cleanImagePath
// 如果路径已经包含uploads直接使用

View File

@@ -527,6 +527,8 @@ const submitForm = async () => {
details: form.details,
status: form.status
}
console.log(submitData);
if (isEdit.value) {
await api.products.updateProduct(route.params.id, submitData)