diff --git a/src/utils/imageCacheManager.js b/src/utils/imageCacheManager.js index 693a1bc..020afb7 100644 --- a/src/utils/imageCacheManager.js +++ b/src/utils/imageCacheManager.js @@ -482,18 +482,17 @@ class ImageCacheManager { const cachedResponse = await this.getCachedImage(normalizedSrc) // 3. 获取对应的缓存图片 // 4. 缓存命中,处理图片 if (cachedResponse) { - const blob = await cachedResponse.blob() - const imageUrl = URL.createObjectURL(blob) + const blob = await cachedResponse.blob() //将缓存响应转换为 Blob 对象 + const imageUrl = URL.createObjectURL(blob) //生成临时的 Blob URL 供 Image 对象使用 const img = new Image() // 5. 创建Image对象并设置src - // 6. 加载成功,清理临时URL并resolve + // 设置 onload 和 onerror 回调 img.onload = () => { URL.revokeObjectURL(imageUrl) // 清理临时URL resolve(img) } - // 7. 关键:加载失败时的处理 img.onerror = () => { URL.revokeObjectURL(imageUrl) // 8. 清理临时URL this.loadImageFromNetwork(normalizedSrc, resolve, reject) // 9. 回退到网络加载