From f341d5b423138fa4d5d71bc4cbef3454371805d2 Mon Sep 17 00:00:00 2001 From: menxipeng Date: Sat, 13 Sep 2025 14:46:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/ImageUpload/index.vue | 17 +++++---- ruoyi-ui/src/views/activity/index.vue | 35 +++++-------------- ruoyi-ui/src/views/playlist/normal/index.vue | 3 +- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/ruoyi-ui/src/components/ImageUpload/index.vue b/ruoyi-ui/src/components/ImageUpload/index.vue index 6ac79c3..a679cfb 100644 --- a/ruoyi-ui/src/components/ImageUpload/index.vue +++ b/ruoyi-ui/src/components/ImageUpload/index.vue @@ -130,10 +130,12 @@ export default { // 然后将数组转为对象数组 this.fileList = list.map(item => { if (typeof item === "string") { - if (item.indexOf(this.baseUrl) === -1 && !isExternal(item)) { - item = { name: this.baseUrl + item, url: this.baseUrl + item } + // 如果不是完整URL且不包含baseUrl,则添加baseUrl前缀用于显示 + if (!isExternal(item) && item.indexOf(this.baseUrl) === -1) { + const displayUrl = this.baseUrl + (item.startsWith('/') ? item : '/' + item); + item = { name: displayUrl, url: displayUrl } } else { - item = { name: item, url: item } + item = { name: item, url: item } } } return item @@ -196,13 +198,14 @@ export default { // 上传成功回调 handleUploadSuccess(res, file) { if (res.code === 200) { - // 根据新的接口返回格式,data字段包含图片路径 + // 直接使用接口返回的路径,不做任何修改 let imagePath = res.data || res.fileName; - // 如果路径不是以http开头,则拼接域名前缀 + // 为了显示需要,临时添加baseUrl前缀 + let displayUrl = imagePath; if (imagePath && !imagePath.startsWith('http://') && !imagePath.startsWith('https://')) { - imagePath = this.baseUrl + imagePath; + displayUrl = this.baseUrl + imagePath; } - this.uploadList.push({ name: imagePath, url: imagePath }) + this.uploadList.push({ name: displayUrl, url: displayUrl }) this.uploadedSuccessfully() } else { this.number-- diff --git a/ruoyi-ui/src/views/activity/index.vue b/ruoyi-ui/src/views/activity/index.vue index be3ea64..4fc23cb 100644 --- a/ruoyi-ui/src/views/activity/index.vue +++ b/ruoyi-ui/src/views/activity/index.vue @@ -37,8 +37,8 @@