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 }); }