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