mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
fix: udpate pwa site when needRefresh(sw.js updated), for cloudflare static cache
This commit is contained in:
parent
ea04c255c3
commit
3d7b49d991
@ -4,7 +4,7 @@ import { useToast } from "./useToast"
|
|||||||
|
|
||||||
export function usePWA() {
|
export function usePWA() {
|
||||||
const toaster = useToast()
|
const toaster = useToast()
|
||||||
const { updateServiceWorker } = useRegisterSW()
|
const { updateServiceWorker, needRefresh: [needRefresh] } = useRegisterSW()
|
||||||
|
|
||||||
useMount(async () => {
|
useMount(async () => {
|
||||||
const update = () => {
|
const update = () => {
|
||||||
@ -21,7 +21,7 @@ export function usePWA() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else if (needRefresh) {
|
||||||
if (!navigator) return
|
if (!navigator) return
|
||||||
|
|
||||||
if ("connection" in navigator && !navigator.onLine) return
|
if ("connection" in navigator && !navigator.onLine) return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user