+ diff --git a/.env.development b/.env.development index 8686c0c..304410c 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ # 开发环境配置 VITE_API_BASE_URL=/api -VITE_UPLOAD_BASE_URL=http://localhost:3000/api/upload \ No newline at end of file +VITE_UPLOAD_BASE_URL=/api/upload \ No newline at end of file diff --git a/.env.production b/.env.production index 8c9f662..070f7a2 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,5 @@ # 生产环境配置 VITE_API_BASE_URL=https://www.zrbjr.com/api -VITE_UPLOAD_BASE_URL=https://www.zrbjr.com/api/upload +VITE_UPLOAD_BASE_URL=https://minio.zrbjr.com/api/upload # VITE_API_BASE_URL=http://114.55.111.44:3001/api # VITE_UPLOAD_BASE_URL=http://114.55.111.44:3001/api/upload diff --git a/src/config/index.js b/src/config/index.js index 4af2945..c874e11 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -21,20 +21,31 @@ export const { baseURL, uploadURL } = config[env] // 获取完整的图片URL export const getImageUrl = (imagePath) => { + // console.log('getImageUrl called with:', imagePath) if (!imagePath) return '' if (imagePath.startsWith('http')) return imagePath - // 在开发环境下,直接返回相对路径,让Vite代理处理 + // 如果图片路径以/uploads开头,直接返回原路径 + if (imagePath.startsWith('/uploads')) { + // console.log('Image starts with /uploads, returning original path:', imagePath) + return imagePath + } + + // 在开发环境下,也需要根据路径前缀处理 if (env === 'development') { + const cleanBaseURL = baseURL.replace(/\/$/, '') const cleanImagePath = imagePath.startsWith('/') ? imagePath : `/${imagePath}` - return cleanImagePath + const fullUrl = `${cleanBaseURL}${cleanImagePath}` + console.log('Development environment, returning:', fullUrl) + return fullUrl } // 生产环境下使用完整URL const cleanBaseURL = baseURL.replace(/\/$/, '') const cleanImagePath = imagePath.startsWith('/') ? imagePath : `/${imagePath}` + const fullUrl = `${cleanBaseURL}${cleanImagePath}` - return `${cleanBaseURL}${cleanImagePath}` + return fullUrl } // 获取上传配置 diff --git a/src/views/BuyDetails.vue b/src/views/BuyDetails.vue index e68ed67..1531917 100644 --- a/src/views/BuyDetails.vue +++ b/src/views/BuyDetails.vue @@ -32,7 +32,7 @@ 实付
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+