From 743c73044eb5f077e5c1b265671693b75975aecc 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:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/resources/add.php | 19 +++---------------- app/admin/view/resources/edit.php | 19 +++---------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/app/admin/view/resources/add.php b/app/admin/view/resources/add.php index c5cb78b..d981705 100644 --- a/app/admin/view/resources/add.php +++ b/app/admin/view/resources/add.php @@ -424,22 +424,9 @@ console.error('上传出错', file, err, res) }, customInsert(res, insertFn) { - // res 即服务端的返回结果 - if (res.code === 0 && res.data) { - // 处理URL格式 - let imageUrl = res.url || res.data; - // 确保URL以http开头 - if (!imageUrl.startsWith('http')) { - // 移除开头的斜杠,避免重复 - imageUrl = imageUrl.replace(/^\//, ''); - imageUrl = '{$config["admin_domain"]}/' + imageUrl; - } - - if (imageUrl) { - insertFn(imageUrl); - } else { - layer.msg('图片地址无效', { icon: 2 }); - } + // 只使用返回的url字段 + if (res.code === 0 && res.url) { + insertFn(res.url); } else { layer.msg('图片上传失败:' + (res.msg || '未知错误'), { icon: 2 }); } diff --git a/app/admin/view/resources/edit.php b/app/admin/view/resources/edit.php index a2a7ba6..505a44d 100644 --- a/app/admin/view/resources/edit.php +++ b/app/admin/view/resources/edit.php @@ -442,22 +442,9 @@ console.error('上传出错', file, err, res) }, customInsert(res, insertFn) { - // res 即服务端的返回结果 - if (res.code === 0 && res.data) { - // 处理URL格式 - let imageUrl = res.url || res.data; - // 确保URL以http开头 - if (!imageUrl.startsWith('http')) { - // 移除开头的斜杠,避免重复 - imageUrl = imageUrl.replace(/^\//, ''); - imageUrl = '{$config["admin_domain"]}/' + imageUrl; - } - - if (imageUrl) { - insertFn(imageUrl); - } else { - layer.msg('图片地址无效', { icon: 2 }); - } + // 只使用返回的url字段 + if (res.code === 0 && res.url) { + insertFn(res.url); } else { layer.msg('图片上传失败:' + (res.msg || '未知错误'), { icon: 2 }); }