mo 1 year ago
parent
commit
49a4f7cf51
3 changed files with 28 additions and 32 deletions
  1. 1 1
      dev-dist/sw.js
  2. 1 6
      index.html
  3. 26 25
      vite.config.ts

+ 1 - 1
dev-dist/sw.js

@@ -82,7 +82,7 @@ define(['./workbox-5357ef54'], (function (workbox) { 'use strict';
     "revision": "3ca0b8505b4bec776b69afdba2768812"
   }, {
     "url": "index.html",
-    "revision": "0.cr080vmbnv"
+    "revision": "0.75vo45gt8f8"
   }], {});
   workbox.cleanupOutdatedCaches();
   workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

+ 1 - 6
index.html

@@ -189,13 +189,8 @@
           }
         });
 
-        console.log(navigator.serviceWorker, '=====>')
         // 尝试监听install
-        self.addEventListener('install', event => {
-          console.log('install')
-          self.skipWaiting()
-          // 预缓存其他静态内容
-        })
+
 
       }
       let refreshing = false

+ 26 - 25
vite.config.ts

@@ -62,31 +62,32 @@ export default defineConfig({
     VitePWA({
       registerType: 'autoUpdate',
       includeAssets: ['./logo.png'],
-      // workbox: {
-      // runtimeCaching: [
-      //   {
-      //     urlPattern: /(.*?)\.(js|css|ts|tsx|html)/, // js /css /ts静态资源缓存
-      //     handler: 'NetworkOnly',
-      //     options: {
-      //       cacheName: 'js-css-cache'
-      //     }
-      //   },
-      //   {
-      //     urlPattern: /.*\.html.*/,
-      //     handler: 'NetworkOnly',
-      //     options: {
-      //       cacheName: 'wisbayar-html',
-      //       expiration: {
-      //         maxEntries: 20,
-      //         maxAgeSeconds: 30 * 24 * 60 * 60
-      //       },
-      //       cacheableResponse: {
-      //         statuses: [200]
-      //       }
-      //     }
-      //   }
-      // ]
-      // },
+      workbox: {
+        skipWaiting: true
+        // runtimeCaching: [
+        //   {
+        //     urlPattern: /(.*?)\.(js|css|ts|tsx|html)/, // js /css /ts静态资源缓存
+        //     handler: 'NetworkOnly',
+        //     options: {
+        //       cacheName: 'js-css-cache'
+        //     }
+        //   },
+        //   {
+        //     urlPattern: /.*\.html.*/,
+        //     handler: 'NetworkOnly',
+        //     options: {
+        //       cacheName: 'wisbayar-html',
+        //       expiration: {
+        //         maxEntries: 20,
+        //         maxAgeSeconds: 30 * 24 * 60 * 60
+        //       },
+        //       cacheableResponse: {
+        //         statuses: [200]
+        //       }
+        //     }
+        //   }
+        // ]
+      },
       manifest: {
         name: '酷乐秀-音乐数字课堂',
         short_name: '音乐数字课堂',