fix: udpate pwa site when needRefresh(sw.js updated), for cloudflare static cache

This commit is contained in:
Ou 2024-11-25 00:24:20 +08:00
parent ea04c255c3
commit 3d7b49d991

View File

@ -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