From 7447661a21bfc99c18fad300ccb277e6f7dc94b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E6=B3=BD=E7=BD=91?= <”357099073@qq.com“> Date: Wed, 21 May 2025 01:17:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=9F=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/resources/add.php | 11 +++++++++-- app/admin/view/resources/edit.php | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/admin/view/resources/add.php b/app/admin/view/resources/add.php index d981705..c9f52b6 100644 --- a/app/admin/view/resources/add.php +++ b/app/admin/view/resources/add.php @@ -424,9 +424,16 @@ console.error('上传出错', file, err, res) }, customInsert(res, insertFn) { - // 只使用返回的url字段 + // 只使用返回的url字段,并确保使用完整的URL if (res.code === 0 && res.url) { - insertFn(res.url); + // 如果URL不是以http开头,添加https:// + let imageUrl = res.url; + if (!imageUrl.startsWith('http')) { + imageUrl = 'https://' + imageUrl; + } + // 移除可能存在的重复域名和路径 + imageUrl = imageUrl.replace(/^https?:\/\/[^\/]+\/admin\/resources\//, 'https://www.yunzer.cn/'); + insertFn(imageUrl); } else { layer.msg('图片上传失败:' + (res.msg || '未知错误'), { icon: 2 }); } diff --git a/app/admin/view/resources/edit.php b/app/admin/view/resources/edit.php index 505a44d..10cdd70 100644 --- a/app/admin/view/resources/edit.php +++ b/app/admin/view/resources/edit.php @@ -442,9 +442,16 @@ console.error('上传出错', file, err, res) }, customInsert(res, insertFn) { - // 只使用返回的url字段 + // 只使用返回的url字段,并确保使用完整的URL if (res.code === 0 && res.url) { - insertFn(res.url); + // 如果URL不是以http开头,添加https:// + let imageUrl = res.url; + if (!imageUrl.startsWith('http')) { + imageUrl = 'https://' + imageUrl; + } + // 移除可能存在的重复域名和路径 + imageUrl = imageUrl.replace(/^https?:\/\/[^\/]+\/admin\/resources\//, 'https://www.yunzer.cn/'); + insertFn(imageUrl); } else { layer.msg('图片上传失败:' + (res.msg || '未知错误'), { icon: 2 }); }