Yeni versiyon güncelleme uyarısı çıkacak
This commit is contained in:
parent
c5f3a65304
commit
51208b8693
3 changed files with 9 additions and 5 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { ROUTES_ENUM } from '@/routes/route.constant'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { HiOutlineRefresh, HiX } from 'react-icons/hi'
|
||||
import { useStoreActions } from '@/store'
|
||||
|
|
@ -50,10 +49,16 @@ const UpdateNotifier = () => {
|
|||
reg.waiting.postMessage({ type: 'SKIP_WAITING' })
|
||||
reg.waiting.addEventListener('statechange', (e: any) => {
|
||||
if (e.target.state === 'activated') {
|
||||
if (newVersion) {
|
||||
setUiVersion(newVersion) // ✅ Store’daki versiyonu güncelle
|
||||
}
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (newVersion) {
|
||||
setUiVersion(newVersion) // ✅ Direkt güncelle
|
||||
}
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { registerSW } from 'virtual:pwa-register'
|
|||
|
||||
export const registerServiceWorker = () => {
|
||||
registerSW({
|
||||
immediate: true, // Yeni SW hemen yüklensin
|
||||
onNeedRefresh() {
|
||||
const event = new CustomEvent('sw-update-available')
|
||||
window.dispatchEvent(event)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default defineConfig(async ({ mode }) => {
|
|||
mode === 'production'
|
||||
? VitePWA({
|
||||
// Deploy'dan sonra otomatik güncelle
|
||||
registerType: 'autoUpdate',
|
||||
registerType: 'prompt',
|
||||
// Kayıt kodunu otomatik enjekte et (virtual:pwa-register yazmadan da çalışır)
|
||||
injectRegister: 'auto',
|
||||
// Dev ortamında SW'yi aç, prod'da kapalı tut (build edilmiş SW prod'da zaten aktif olur)
|
||||
|
|
@ -37,10 +37,10 @@ export default defineConfig(async ({ mode }) => {
|
|||
|
||||
// EN KRİTİK: yeni SW beklemeden kontrolü alsın
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
skipWaiting: false,
|
||||
|
||||
// Eski workbox cache'lerini temizle
|
||||
cleanupOutdatedCaches: mode === 'production',
|
||||
cleanupOutdatedCaches: true,
|
||||
|
||||
// SPA fallback'i API çağrılarına uygulama
|
||||
navigateFallbackDenylist: [/^\/api\//],
|
||||
|
|
|
|||
Loading…
Reference in a new issue