From 38866690c21bdb9d10138ed0f6e62b9404fda58d Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 15 Apr 2024 15:04:36 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E2=9D=93service=20worker=20=E6=80=BB?= =?UTF-8?q?=E6=98=AFnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ClearCache.jsx | 2 +- vite.config.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/views/ClearCache.jsx b/src/views/ClearCache.jsx index 1cfc4ff..2ee7a7f 100644 --- a/src/views/ClearCache.jsx +++ b/src/views/ClearCache.jsx @@ -26,7 +26,7 @@ const ClearCache = (props) => { const clearAllCaches = async () => { try { // 1. Clear the service worker cache - if (navigator.serviceWorker.controller) { + if (navigator.serviceWorker) { const cacheNames = await caches.keys(); await Promise.all(cacheNames.map((name) => caches.delete(name))); } diff --git a/vite.config.js b/vite.config.js index 796a3b8..d34fe93 100644 --- a/vite.config.js +++ b/vite.config.js @@ -24,6 +24,8 @@ const manifestForPlugIn = { workbox: { globPatterns: ['**/*.{json,css,js,html,ico,png,svg,woff2}'], maximumFileSizeToCacheInBytes: 3000000, + clientsClaim: true, + skipWaiting: true, runtimeCaching: [ { urlPattern: /^https:\/\/haina-sale-system\.oss-cn-shenzhen\.aliyuncs\.com\/.*/i,