chore(图片缓存管理器): 新增注释
This commit is contained in:
parent
055166551d
commit
30f19537c4
@ -22,7 +22,11 @@ class ImageCacheManager {
|
||||
this.maxRetries = 3 // 最大重试次数
|
||||
|
||||
// ✅ 新增:防抖版本的缓存限制检查(1 秒防抖,合并多次调用)
|
||||
this.enforceCacheLimitsDebounced = useDebounce(this.enforceCacheLimits.bind(this), 1000, false)
|
||||
this.enforceCacheLimitsDebounced = useDebounce(
|
||||
this.enforceCacheLimits.bind(this), // ⚠️ 只绑定 this,不绑定参数
|
||||
1000,
|
||||
false,
|
||||
)
|
||||
|
||||
this.init()
|
||||
}
|
||||
@ -465,6 +469,7 @@ class ImageCacheManager {
|
||||
|
||||
// 异步检查缓存限制
|
||||
// ✅ 修复:包装为 Promise 确保错误捕获
|
||||
// 等价于enforceCacheLimits.call(this, cache, cacheName)
|
||||
Promise.resolve(this.enforceCacheLimitsDebounced(cache, cacheName)).catch((error) => {
|
||||
console.warn('检查缓存限制时出错:', error)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user