feat: 添加清除 Service Worker 缓存功能,优化缓存管理逻辑

This commit is contained in:
2025-12-21 02:53:02 +07:00
parent 7fcb2555a3
commit fcaf7db923
3 changed files with 27 additions and 13 deletions

View File

@@ -75,6 +75,14 @@ export function useCacheSize() {
// 清除 sessionStorage
sessionStorage.clear();
// 清除 Service Worker 缓存
if ("serviceWorker" in navigator) {
const registrations = await navigator.serviceWorker.getRegistrations();
for (const registration of registrations) {
await registration.unregister();
}
}
// 清除 Cache API 缓存
if ("caches" in window) {
const cacheNames = await caches.keys();