@@ -101,7 +101,11 @@ import { storeToRefs } from "pinia";
101101import { Toast } from " @nutui/nutui" ;
102102import { initStores } from " @/utils/initApp" ;
103103import { useMethodStore } from ' @/store/methodStore' ;
104+ import { useAppNotifyStore } from " @/store/appNotify" ;
105+ import i18n from " @/locales" ;
104106
107+ const { t :i18n_global } = i18n .global ;
108+ const { showNotify } = useAppNotifyStore ();
105109const { t, locale } = useI18n ();
106110const router = useRouter ();
107111const route = useRoute ();
@@ -218,11 +222,26 @@ const setSimpleMode = (isSimpleMode: boolean) => {
218222 changeAppearanceSetting ({ appearanceSetting: data })
219223};
220224
221- const refresh = () => {
225+ const refresh = async () => {
222226 if ([" /subs" , " /sync" , " /files" ].includes (route .path )) {
223227 initStores (true , true , true );
224228 } else {
225- window .location .reload ();
229+ if (" serviceWorker" in navigator ) {
230+ const registrations = await navigator .serviceWorker .getRegistrations ();
231+ for (let registration of registrations ) {
232+ await registration .unregister ();
233+ }
234+ }
235+ if (" caches" in window ) {
236+ const cacheNames = await caches .keys ();
237+ for (let cacheName of cacheNames ) {
238+ await caches .delete (cacheName );
239+ }
240+ }
241+ showNotify ({ title: i18n_global (" globalNotify.refresh.rePwa" ), type: " primary" });
242+ setTimeout (() => {
243+ window .location .reload ();
244+ }, 1000 );
226245 }
227246};
228247watchEffect (() => {
0 commit comments