support clearing application code cache

This commit is contained in:
MaysWind
2026-03-11 00:52:43 +08:00
parent edcf33f49c
commit 13488efdaf
23 changed files with 82 additions and 1 deletions
+17
View File
@@ -229,6 +229,23 @@ export function clearMapDataCache(): Promise<void> {
});
}
export function clearApplicationCodeCache(): Promise<void> {
if (!window.caches) {
logger.error('caches API is not supported in this browser');
return Promise.reject();
}
return window.caches.delete(SW_CODE_CACHE_NAME).then(success => {
if (success) {
logger.info(`cache "${SW_CODE_CACHE_NAME}" cleared successfully`);
} else {
logger.warn(`failed to clear cache "${SW_CODE_CACHE_NAME}"`);
}
}).catch(error => {
logger.error(`failed to clear cache "${SW_CODE_CACHE_NAME}"`, error);
});
}
export function clearAllBrowserCaches(): Promise<void> {
if (!window.caches) {
logger.error('caches API is not supported in this browser');