Browse Source

修改配置

lex 10 months ago
parent
commit
cf1124349f
3 changed files with 13 additions and 4 deletions
  1. 2 2
      dev-dist/sw.js
  2. 1 1
      src/App.tsx
  3. 10 1
      vite.config.ts

+ 2 - 2
dev-dist/sw.js

@@ -67,7 +67,7 @@ if (!self.define) {
     });
   };
 }
-define(['./workbox-5357ef54'], (function (workbox) { 'use strict';
+define(['./workbox-5199072c'], (function (workbox) { 'use strict';
 
   self.skipWaiting();
   workbox.clientsClaim();
@@ -82,7 +82,7 @@ define(['./workbox-5357ef54'], (function (workbox) { 'use strict';
     "revision": "3ca0b8505b4bec776b69afdba2768812"
   }, {
     "url": "index.html",
-    "revision": "0.tepotf17th8"
+    "revision": "0.uure8gg14q"
   }], {});
   workbox.cleanupOutdatedCaches();
   workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

+ 1 - 1
src/App.tsx

@@ -192,7 +192,7 @@ export default defineComponent({
 
       // const intervalMS = 60 * 60 * 1000;
 
-      console.log(useRegisterSW, '1');
+      // console.log(useRegisterSW, '1');
       const updateServiceWorker = useRegisterSW({
         onRegistered(r: any) {
           console.log(r, 'registered');

+ 10 - 1
vite.config.ts

@@ -69,7 +69,16 @@ export default defineConfig(() => {
         workbox: {
           skipWaiting: true,
           clientsClaim: true,
-          runtimeCaching: []
+          runtimeCaching: [
+            {
+              urlPattern: ({ url }) =>
+                url.origin === 'https://dev.kt.colexiu.com',
+              handler: 'NetworkFirst',
+              options: {
+                cacheName: 'api-cache'
+              }
+            }
+          ]
           // runtimeCaching: [
           //   {
           //     urlPattern: /(.*?)\.(js|css|ts|tsx|html)/, // js /css /ts静态资源缓存