From 55c855936c9f072f9d660fea2939bab2e4ead67c Mon Sep 17 00:00:00 2001 From: sunzhuangzhuang <961120009@qq.com> Date: Mon, 8 Sep 2025 11:53:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/config.js | 39 +++---- src/views/Users.vue | 274 +++++++++++++++++++++++++++----------------- vite.config.js | 12 +- 3 files changed, 196 insertions(+), 129 deletions(-) diff --git a/src/utils/config.js b/src/utils/config.js index c3b681f..a2e80e9 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -25,34 +25,33 @@ export const { baseURL, uploadURL } = config[env] * @returns {string} 完整的图片URL */ export const getImageUrl = (imagePath) => { - const cleanBaseURL = baseURL.replace(/\/$/, '') + // console.log('getImageUrl called with:', imagePath) if (!imagePath) return '' if (imagePath.startsWith('http')) return imagePath + console.log(imagePath,'imagePath'); - // 在开发环境下,使用代理路径 + // 如果图片路径以/uploads开头,直接返回原路径 + if (imagePath.startsWith('/uploads')) { + const cleanBaseURL = baseURL.replace(/\/$/, '') + // console.log('Image starts with /uploads, returning original path:', imagePath) + return `${imagePath}` + } + + // 在开发环境下,也需要根据路径前缀处理 if (env === 'development') { - // 如果路径已经包含uploads,直接使用 - if (imagePath.startsWith('/uploads/') || imagePath.startsWith('uploads/')) { - const cleanPath = imagePath.startsWith('/') ? imagePath : `/${imagePath}` - return cleanPath - } - // 否则添加uploads前缀 - return `${cleanBaseURL}${imagePath}` + const cleanBaseURL = baseURL.replace(/\/$/, '') + const cleanImagePath = imagePath.startsWith('/') ? imagePath : `/${imagePath}` + const fullUrl = `${cleanBaseURL}${cleanImagePath}` + // console.log('Development environment, returning:', fullUrl) + return fullUrl } // 生产环境下使用完整URL - - let cleanImagePath + const cleanBaseURL = baseURL.replace(/\/$/, '') + const cleanImagePath = imagePath.startsWith('/') ? imagePath : `/${imagePath}` + const fullUrl = `${cleanBaseURL}${cleanImagePath}` - // 如果路径已经包含uploads,直接使用 - if (imagePath.startsWith('/uploads/') || imagePath.startsWith('uploads/')) { - cleanImagePath = imagePath.startsWith('/') ? imagePath : `/${imagePath}` - } else { - // 否则添加uploads前缀 - cleanImagePath = `/uploads/${imagePath}` - } - - return `${cleanBaseURL}${cleanImagePath}` + return fullUrl } /** diff --git a/src/views/Users.vue b/src/views/Users.vue index 33dd0d4..0a59652 100644 --- a/src/views/Users.vue +++ b/src/views/Users.vue @@ -55,39 +55,17 @@ - - + - - - - - - - - - + @change="handleSearchRegionChange" + /> @@ -146,17 +124,11 @@ - - - - + -