feat(pwa):
This commit is contained in:
parent
00c40f2569
commit
c21d21015f
|
@ -69,6 +69,7 @@ if (IS_SW) {
|
|||
})
|
||||
|
||||
self.addEventListener('push', (event) => {
|
||||
console.log('push')
|
||||
const { title, options } = (event.data?.json() ?? {}) as {
|
||||
title?: string
|
||||
options?: Partial<NotificationOptions>
|
||||
|
@ -140,9 +141,14 @@ async function fetchHandler(event: FetchEvent) {
|
|||
async function updateCache() {
|
||||
const serverVersion = await getServerCacheVersion()
|
||||
const clientVersion = await swStorage.getItem<string>('$sw.cache.version')
|
||||
if (clientVersion === null) return
|
||||
if (serverVersion === undefined) return
|
||||
if (clientVersion === serverVersion) return
|
||||
openCache()
|
||||
|
||||
// Open new pre-cache
|
||||
await openCache()
|
||||
// Delete old pre-cache
|
||||
caches.delete(clientVersion)
|
||||
}
|
||||
|
||||
async function getServerCacheVersion() {
|
||||
|
|
Loading…
Reference in a new issue