Browse Source

添加配置

lex 1 year ago
parent
commit
b5021da164
1 changed files with 20 additions and 0 deletions
  1. 20 0
      src/App.tsx

+ 20 - 0
src/App.tsx

@@ -9,11 +9,31 @@ import { useRegisterSW } from 'virtual:pwa-register/vue';
 import { useUserStore } from './store/modules/users';
 export function unregister() {
   console.log('unregister - outer');
+
   if ('serviceWorker' in navigator) {
     console.log('unregister - pwa');
     navigator.serviceWorker.ready.then(registration => {
       registration.unregister();
     });
+
+    navigator.serviceWorker
+      .getRegistrations()
+      .then(registrations => {
+        for (const registration of registrations) {
+          registration.unregister().then(boolean => {
+            if (boolean) {
+              console.log('Service Worker unregistered successfully');
+            } else {
+              console.log('Service Worker unregistration failed');
+            }
+          });
+        }
+      })
+      .catch(error => {
+        console.error('Error getting Service Worker registrations:', error);
+      });
+  } else {
+    console.log('Service Workers are not supported in this browser');
   }
 }