From 3d7b49d991822b69e7131cb927968f9fabf0058f Mon Sep 17 00:00:00 2001 From: Ou Date: Mon, 25 Nov 2024 00:24:20 +0800 Subject: [PATCH] fix: udpate pwa site when needRefresh(sw.js updated), for cloudflare static cache --- src/hooks/usePWA.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/usePWA.ts b/src/hooks/usePWA.ts index 947264e..9dcef8a 100644 --- a/src/hooks/usePWA.ts +++ b/src/hooks/usePWA.ts @@ -4,7 +4,7 @@ import { useToast } from "./useToast" export function usePWA() { const toaster = useToast() - const { updateServiceWorker } = useRegisterSW() + const { updateServiceWorker, needRefresh: [needRefresh] } = useRegisterSW() useMount(async () => { const update = () => { @@ -21,7 +21,7 @@ export function usePWA() { }, }, }) - } else { + } else if (needRefresh) { if (!navigator) return if ("connection" in navigator && !navigator.onLine) return