Browse Source

去掉不要的缓存

lex 1 year ago
parent
commit
7451e71776
1 changed files with 14 additions and 0 deletions
  1. 14 0
      src/App.tsx

+ 14 - 0
src/App.tsx

@@ -204,6 +204,20 @@ export default defineComponent({
         }
       });
       // console.log('app - onounted - test interval');
+
+      if ('serviceWorker' in navigator) {
+        navigator.serviceWorker.getRegistrations().then(registrations => {
+          for (const registration of registrations) {
+            if (registration.scope.startsWith(`https://${location.host}/`)) {
+              registration.unregister().then(() => {
+                console.log(
+                  `Service Worker unregistered for https://${location.host}/`
+                );
+              });
+            }
+          }
+        });
+      }
     });
     onUnmounted(() => {
       window.removeEventListener('message', handleOpen);