From 8d50c6dadfa870a3582451fdf437868c1c96371e Mon Sep 17 00:00:00 2001 From: dzl <786316265@qq.com> Date: Tue, 2 Sep 2025 17:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- .env.production | 2 +- src/config/index.js | 17 ++++++++-- src/views/BuyDetails.vue | 3 +- src/views/Cart.vue | 3 +- src/views/Matching.vue | 4 +-- src/views/MyProfile.vue | 33 ++++++++++++++------ src/views/MyShop.vue | 5 +-- src/views/Orders.vue | 11 ++++--- src/views/Pay.vue | 25 +++++++-------- src/views/PayLoading.vue | 11 ++++--- src/views/ProductDetail.vue | 60 +++++++++++++++++++++++++++++++++++- src/views/ProductSummary.vue | 35 ++++++--------------- src/views/Shop.vue | 6 ++-- 14 files changed, 144 insertions(+), 73 deletions(-) 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 @@ 实付
- 融豆 + 融豆 {{ totalPrice }}
@@ -130,6 +130,7 @@ import { ArrowRight } from '@element-plus/icons-vue' import api from '@/utils/api' +import { getImageUrl } from '@/config' const route = useRoute() const router = useRouter() diff --git a/src/views/Cart.vue b/src/views/Cart.vue index 28183c8..7d49698 100644 --- a/src/views/Cart.vue +++ b/src/views/Cart.vue @@ -65,7 +65,7 @@ />
- +
{{ item.name }}
@@ -140,6 +140,7 @@ import { Coin } from '@element-plus/icons-vue' import api from '@/utils/api' +import { getImageUrl } from '@/config' const router = useRouter() diff --git a/src/views/Matching.vue b/src/views/Matching.vue index df27f18..0b9e53c 100644 --- a/src/views/Matching.vue +++ b/src/views/Matching.vue @@ -54,7 +54,7 @@ step="100" placeholder="请输入5000-50000之间的金额" > - +
@@ -349,7 +349,7 @@ :src="getImageUrl(transferDialog.voucher)" :preview-src-list="[getImageUrl(transferDialog.voucher)]" alt="转账凭证" - fit="cover" + fit="contain" :lazy="true" >