From 13488efdaf6457e532698e93fa440bd0a7cdabe7 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Wed, 11 Mar 2026 00:52:43 +0800 Subject: [PATCH] support clearing application code cache --- src/lib/cache.ts | 17 +++++++++++++++++ src/locales/de.json | 2 ++ src/locales/en.json | 2 ++ src/locales/es.json | 2 ++ src/locales/fr.json | 2 ++ src/locales/it.json | 2 ++ src/locales/ja.json | 2 ++ src/locales/kn.json | 2 ++ src/locales/ko.json | 2 ++ src/locales/nl.json | 2 ++ src/locales/pt_BR.json | 2 ++ src/locales/ru.json | 2 ++ src/locales/sl.json | 2 ++ src/locales/ta.json | 2 ++ src/locales/th.json | 2 ++ src/locales/tr.json | 2 ++ src/locales/uk.json | 2 ++ src/locales/vi.json | 2 ++ src/locales/zh_Hans.json | 2 ++ src/locales/zh_Hant.json | 4 +++- .../settings/AppBrowserCacheSettingPageBase.ts | 2 ++ .../settings/tabs/AppBrowserCacheSettingTab.vue | 13 +++++++++++++ .../mobile/settings/BrowserCacheSettingPage.vue | 11 +++++++++++ 23 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/lib/cache.ts b/src/lib/cache.ts index 8dfe47f8..056fdca5 100644 --- a/src/lib/cache.ts +++ b/src/lib/cache.ts @@ -229,6 +229,23 @@ export function clearMapDataCache(): Promise { }); } +export function clearApplicationCodeCache(): Promise { + 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 { if (!window.caches) { logger.error('caches API is not supported in this browser'); diff --git a/src/locales/de.json b/src/locales/de.json index e788d198..37078812 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Sind Sie sicher, dass Sie sich erneut anmelden möchten?", diff --git a/src/locales/en.json b/src/locales/en.json index bdbb79ba..9790ae47 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Are you sure you want to re-login?", diff --git a/src/locales/es.json b/src/locales/es.json index e676dd87..3666c947 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "¿Seguro que deseas volver a iniciar sesión?", diff --git a/src/locales/fr.json b/src/locales/fr.json index 5133692e..b678e7d4 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Êtes-vous sûr de vouloir vous reconnecter ?", diff --git a/src/locales/it.json b/src/locales/it.json index 4e5911d9..42667dd5 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Sei sicuro di voler accedere di nuovo?", diff --git a/src/locales/ja.json b/src/locales/ja.json index 569c12e2..89063b17 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "再ログインしますか?", diff --git a/src/locales/kn.json b/src/locales/kn.json index bdd7846d..18003ca7 100644 --- a/src/locales/kn.json +++ b/src/locales/kn.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "ಮತ್ತೆ ಲಾಗಿನ್ ಮಾಡಲು ನೀವು ಖಚಿತವೇ?", diff --git a/src/locales/ko.json b/src/locales/ko.json index f4f479f3..84ddb07b 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "다시 로그인하시겠습니까?", diff --git a/src/locales/nl.json b/src/locales/nl.json index f5a4dddd..7f8e4be6 100644 --- a/src/locales/nl.json +++ b/src/locales/nl.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Weet je zeker dat je opnieuw wilt inloggen?", diff --git a/src/locales/pt_BR.json b/src/locales/pt_BR.json index c1d160aa..c7da70e2 100644 --- a/src/locales/pt_BR.json +++ b/src/locales/pt_BR.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Tem certeza de que deseja fazer login novamente?", diff --git a/src/locales/ru.json b/src/locales/ru.json index 750047e3..fd09521a 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Вы уверены, что хотите войти снова?", diff --git a/src/locales/sl.json b/src/locales/sl.json index 10500ee5..cc75e9a4 100644 --- a/src/locales/sl.json +++ b/src/locales/sl.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Ali ste prepričani, da se želite ponovno prijaviti?", diff --git a/src/locales/ta.json b/src/locales/ta.json index 0340dbfc..090298b4 100644 --- a/src/locales/ta.json +++ b/src/locales/ta.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "மீண்டும் உள்நுழை செய்ய நீங்கள் உறுதியா?", diff --git a/src/locales/th.json b/src/locales/th.json index 2378b2aa..3b9558f0 100644 --- a/src/locales/th.json +++ b/src/locales/th.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "คุณแน่ใจหรือว่าต้องการเข้าสู่ระบบอีกครั้ง?", diff --git a/src/locales/tr.json b/src/locales/tr.json index bdbbdf73..b11b13a0 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Tekrar giriş yapmak istediğinize emin misiniz?", diff --git a/src/locales/uk.json b/src/locales/uk.json index 294e5151..1ba23497 100644 --- a/src/locales/uk.json +++ b/src/locales/uk.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Ви впевнені, що хочете увійти знову?", diff --git a/src/locales/vi.json b/src/locales/vi.json index 07486d61..864fb567 100644 --- a/src/locales/vi.json +++ b/src/locales/vi.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "Are you sure you want to clear all file cache?", "Clear Map Data Cache": "Clear Map Data Cache", "Are you sure you want to clear map data cache?": "Are you sure you want to clear map data cache?", + "Clear Application Code Cache": "Clear Application Code Cache", + "Are you sure you want to clear application code cache?": "Are you sure you want to clear application code cache?", "Clear Exchange Rates Data Cache": "Clear Exchange Rates Data Cache", "Are you sure you want to clear exchange rates data cache?": "Are you sure you want to clear exchange rates data cache?", "Are you sure you want to re-login?": "Bạn có chắc chắn muốn đăng nhập lại không?", diff --git a/src/locales/zh_Hans.json b/src/locales/zh_Hans.json index 2db9caf0..c2a1dce2 100644 --- a/src/locales/zh_Hans.json +++ b/src/locales/zh_Hans.json @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "您确定要清除所有文件缓存?", "Clear Map Data Cache": "清除地图数据缓存", "Are you sure you want to clear map data cache?": "您确定要清除地图数据缓存?", + "Clear Application Code Cache": "清除应用代码缓存", + "Are you sure you want to clear application code cache?": "您确定要清除应用代码缓存?", "Clear Exchange Rates Data Cache": "清除汇率数据缓存", "Are you sure you want to clear exchange rates data cache?": "您确定要清除汇率数据缓存?", "Are you sure you want to re-login?": "您确定要重新登录?", diff --git a/src/locales/zh_Hant.json b/src/locales/zh_Hant.json index d236403a..ed89c765 100644 --- a/src/locales/zh_Hant.json +++ b/src/locales/zh_Hant.json @@ -2531,7 +2531,7 @@ "Browser Cache Management": "瀏覽器快取管理", "File Cache": "檔案快取", "Used storage": "已使用的儲存空間", - "Application Code": "應用程式程式碼", + "Application Code": "應用程式碼", "Resource Files": "資源檔案", "Map Data": "地圖資料", "Others": "其他", @@ -2543,6 +2543,8 @@ "Are you sure you want to clear all file cache?": "您確定要清除所有檔案快取?", "Clear Map Data Cache": "清除地圖資料快取", "Are you sure you want to clear map data cache?": "您確定要清除地圖資料快取?", + "Clear Application Code Cache": "清除應用程式碼快取", + "Are you sure you want to clear application code cache?": "您確定要清除應用程式碼快取?", "Clear Exchange Rates Data Cache": "清除匯率資料快取", "Are you sure you want to clear exchange rates data cache?": "您確定要清除匯率資料快取?", "Are you sure you want to re-login?": "您確定要重新登入?", diff --git a/src/views/base/settings/AppBrowserCacheSettingPageBase.ts b/src/views/base/settings/AppBrowserCacheSettingPageBase.ts index 6a28f226..67ce4f2d 100644 --- a/src/views/base/settings/AppBrowserCacheSettingPageBase.ts +++ b/src/views/base/settings/AppBrowserCacheSettingPageBase.ts @@ -12,6 +12,7 @@ import { loadBrowserCacheStatistics, updateMapCacheExpiration, clearMapDataCache, + clearApplicationCodeCache, clearAllBrowserCaches } from '@/lib/cache.ts'; @@ -115,6 +116,7 @@ export function useAppBrowserCacheSettingPageBase() { // functions loadCacheStatistics, clearMapDataCache, + clearApplicationCodeCache, clearAllBrowserCaches, clearExchangeRatesDataCache }; diff --git a/src/views/desktop/app/settings/tabs/AppBrowserCacheSettingTab.vue b/src/views/desktop/app/settings/tabs/AppBrowserCacheSettingTab.vue index 31986b84..142dc3c6 100644 --- a/src/views/desktop/app/settings/tabs/AppBrowserCacheSettingTab.vue +++ b/src/views/desktop/app/settings/tabs/AppBrowserCacheSettingTab.vue @@ -72,6 +72,10 @@ :disabled="loading || !isSupportedFileCache || !fileCacheStatistics" @click="clearMapCache()"> {{ tt('Clear Map Data Cache') }} + + {{ tt('Clear Application Code Cache') }} + {{ tt('Clear All File Cache') }} @@ -180,6 +184,7 @@ const { exchangeRatesDataCacheExpiration, loadCacheStatistics, clearMapDataCache, + clearApplicationCodeCache, clearAllBrowserCaches, clearExchangeRatesDataCache } = useAppBrowserCacheSettingPageBase(); @@ -194,6 +199,14 @@ function clearMapCache(): void { }); } +function clearApplicationCodeFileCache(): void { + confirmDialog.value?.open('Are you sure you want to clear application code cache?').then(() => { + clearApplicationCodeCache().then(() => { + loadCacheStatistics(true); + }); + }); +} + function clearAllFileCache(): void { confirmDialog.value?.open('Are you sure you want to clear all file cache?').then(() => { clearAllBrowserCaches().then(() => { diff --git a/src/views/mobile/settings/BrowserCacheSettingPage.vue b/src/views/mobile/settings/BrowserCacheSettingPage.vue index 761df1ef..22b742ef 100644 --- a/src/views/mobile/settings/BrowserCacheSettingPage.vue +++ b/src/views/mobile/settings/BrowserCacheSettingPage.vue @@ -101,6 +101,8 @@ {{ tt('Clear Map Data Cache') }} + {{ tt('Clear Application Code Cache') }} {{ tt('Clear All File Cache') }} @@ -141,6 +143,7 @@ const { exchangeRatesDataCacheExpiration, loadCacheStatistics, clearMapDataCache, + clearApplicationCodeCache, clearAllBrowserCaches, clearExchangeRatesDataCache } = useAppBrowserCacheSettingPageBase(); @@ -165,6 +168,14 @@ function clearMapCache(): void { }); } +function clearApplicationCodeFileCache(): void { + showConfirm('Are you sure you want to clear application code cache?', () => { + clearApplicationCodeCache().then(() => { + loadCacheStatistics(true); + }); + }); +} + function clearAllFileCache(): void { showConfirm('Are you sure you want to clear all file cache?', () => { clearAllBrowserCaches().then(() => {