@@ -101,7 +101,11 @@ import { storeToRefs } from "pinia";
101
101
import { Toast } from " @nutui/nutui" ;
102
102
import { initStores } from " @/utils/initApp" ;
103
103
import { useMethodStore } from ' @/store/methodStore' ;
104
+ import { useAppNotifyStore } from " @/store/appNotify" ;
105
+ import i18n from " @/locales" ;
104
106
107
+ const { t :i18n_global } = i18n .global ;
108
+ const { showNotify } = useAppNotifyStore ();
105
109
const { t, locale } = useI18n ();
106
110
const router = useRouter ();
107
111
const route = useRoute ();
@@ -218,11 +222,26 @@ const setSimpleMode = (isSimpleMode: boolean) => {
218
222
changeAppearanceSetting ({ appearanceSetting: data })
219
223
};
220
224
221
- const refresh = () => {
225
+ const refresh = async () => {
222
226
if ([" /subs" , " /sync" , " /files" ].includes (route .path )) {
223
227
initStores (true , true , true );
224
228
} 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 );
226
245
}
227
246
};
228
247
watchEffect (() => {
0 commit comments