From 56497898ff53d05ede48c3c75194b590bf68ac8f 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:07:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=9C=B0=E5=9D=80?= 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 45f05fa..09b8b5d 100644 --- a/app/admin/view/resources/add.php +++ b/app/admin/view/resources/add.php @@ -426,8 +426,15 @@ customInsert(res, insertFn) { // res 即服务端的返回结果 if (res.code === 0 && res.data) { - // 使用完整的URL - const imageUrl = res.url || res.data; + // 处理URL格式 + let imageUrl = res.url || res.data; + // 确保URL以http开头 + if (!imageUrl.startsWith('http')) { + imageUrl = '{$config["admin_domain"]}' + imageUrl; + } + // 移除多余的域名部分 + imageUrl = imageUrl.replace('{$config["admin_domain"]}/{$config["admin_domain"]}', '{$config["admin_domain"]}'); + if (imageUrl) { insertFn(imageUrl); } else { diff --git a/app/admin/view/resources/edit.php b/app/admin/view/resources/edit.php index 474406d..674f783 100644 --- a/app/admin/view/resources/edit.php +++ b/app/admin/view/resources/edit.php @@ -444,8 +444,15 @@ customInsert(res, insertFn) { // res 即服务端的返回结果 if (res.code === 0 && res.data) { - // 使用完整的URL - const imageUrl = res.url || res.data; + // 处理URL格式 + let imageUrl = res.url || res.data; + // 确保URL以http开头 + if (!imageUrl.startsWith('http')) { + imageUrl = '{$config["admin_domain"]}' + imageUrl; + } + // 移除多余的域名部分 + imageUrl = imageUrl.replace('{$config["admin_domain"]}/{$config["admin_domain"]}', '{$config["admin_domain"]}'); + if (imageUrl) { insertFn(imageUrl); } else {