lex-xin 5 meses atrás
pai
commit
9b9a38a764
2 arquivos alterados com 10 adições e 10 exclusões
  1. 8 8
      src/router/router-guards.ts
  2. 2 2
      vite.config.ts

+ 8 - 8
src/router/router-guards.ts

@@ -39,14 +39,14 @@ export function createRouterGuards(router: Router) {
         : ('音乐数字课堂' as string);
     }
 
-    // if ('serviceWorker' in navigator) {
-    //   console.log(caches.keys(), 'caches.keys()');
-    //   caches.keys().then(function (cacheNames) {
-    //     cacheNames.forEach(function (cacheName) {
-    //       caches.delete(cacheName);
-    //     });
-    //   });
-    // }
+    if ('serviceWorker' in navigator) {
+      // console.log(caches.keys(), 'caches.keys()');
+      caches.keys().then(function (cacheNames) {
+        cacheNames.forEach(function (cacheName) {
+          caches.delete(cacheName);
+        });
+      });
+    }
     if (!isChrome()) {
       return;
     }

+ 2 - 2
vite.config.ts

@@ -67,8 +67,8 @@ export default defineConfig(() => {
         registerType: 'prompt',
         includeAssets: ['./logo.png'],
         workbox: {
-          skipWaiting: true, // 强制跳过等待
-          clientsClaim: false
+          skipWaiting: false, // 强制跳过等待
+          clientsClaim: false // 让新的 Service Worker 立即控制所有页面
         },
         manifest: {
           name: '酷乐秀-音乐数字课堂',