fix: 优化图片URL处理逻辑并添加错误日志
修改Splash.vue中的图片URL添加压缩参数 在MastersDetail.vue中根据图片大小决定是否添加压缩参数 添加图片加载失败时的错误日志输出
Showing
2 changed files
with
7 additions
and
4 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-10-30 20:00:25 | 2 | * @Date: 2025-10-30 20:00:25 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-11-13 10:33:41 | 4 | + * @LastEditTime: 2025-11-13 14:20:03 |
| 5 | * @FilePath: /stdj_h5/src/views/MastersDetail.vue | 5 | * @FilePath: /stdj_h5/src/views/MastersDetail.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -117,7 +117,8 @@ const initWaterfallImages = function (imgs) { | ... | @@ -117,7 +117,8 @@ const initWaterfallImages = function (imgs) { |
| 117 | const src = typeof item === 'string' ? item : (item?.value || item?.src || '') | 117 | const src = typeof item === 'string' ? item : (item?.value || item?.src || '') |
| 118 | return { | 118 | return { |
| 119 | id: typeof item === 'object' && item?.id ? item.id : idx + 1, | 119 | id: typeof item === 'object' && item?.id ? item.id : idx + 1, |
| 120 | - src: src + '?imageMogr2/thumbnail/400x/strip/quality/70', | 120 | + // 如果item.size 大于 20MB 不加后缀 |
| 121 | + src: src + (item.size > 20 * 1024 * 1024 ? '' : '?imageMogr2/thumbnail/400x/strip/quality/70'), | ||
| 121 | title: typeof item === 'object' && item?.name ? item.name : ('图片' + (idx + 1)), | 122 | title: typeof item === 'object' && item?.name ? item.name : ('图片' + (idx + 1)), |
| 122 | height: Math.floor(Math.random() * 200) + 200 | 123 | height: Math.floor(Math.random() * 200) + 200 |
| 123 | } | 124 | } |
| ... | @@ -158,10 +159,12 @@ const onImageLoad = function (e) { | ... | @@ -158,10 +159,12 @@ const onImageLoad = function (e) { |
| 158 | /** | 159 | /** |
| 159 | * 图片加载失败回调 | 160 | * 图片加载失败回调 |
| 160 | * 说明:记录或上报错误,必要时移除该项 | 161 | * 说明:记录或上报错误,必要时移除该项 |
| 162 | + * @param {Event} evt 图片加载事件 | ||
| 161 | * @returns {void} | 163 | * @returns {void} |
| 162 | */ | 164 | */ |
| 163 | -const onImageError = function () { | 165 | +const onImageError = function (evt) { |
| 164 | // 预留:可移除该图片项或替换为占位图 | 166 | // 预留:可移除该图片项或替换为占位图 |
| 167 | + console.warn(`图片加载失败:${evt.target.src}`) | ||
| 165 | } | 168 | } |
| 166 | 169 | ||
| 167 | /** | 170 | /** | ... | ... |
| ... | @@ -68,7 +68,7 @@ const is_video_ready = ref(false) | ... | @@ -68,7 +68,7 @@ const is_video_ready = ref(false) |
| 68 | 68 | ||
| 69 | // TODO: 视频配置 | 69 | // TODO: 视频配置 |
| 70 | const videoUrl = ref('https://cdn.ipadbiz.cn/stdj/video/cover.mp4') | 70 | const videoUrl = ref('https://cdn.ipadbiz.cn/stdj/video/cover.mp4') |
| 71 | -const imgUrl = ref('https://cdn.ipadbiz.cn/stdj/images/%E5%90%AF%E5%8A%A8%E9%A1%B5%E6%B5%B7%E6%8A%A5%E8%83%8C%E6%99%AF@2x.png') | 71 | +const imgUrl = ref('https://cdn.ipadbiz.cn/stdj/images/%E5%90%AF%E5%8A%A8%E9%A1%B5%E6%B5%B7%E6%8A%A5%E8%83%8C%E6%99%AF@2x.png?imageMogr2/thumbnail/400x/strip/quality/70') |
| 72 | 72 | ||
| 73 | // 进入应用函数 | 73 | // 进入应用函数 |
| 74 | /** | 74 | /** | ... | ... |
-
Please register or login to post a comment