fix(pwa): completely destroy service worker cache and fix chunk load errors to stop freezing
This commit is contained in:
@ -181,4 +181,11 @@ router.beforeEach(async (to, _from, next) => {
|
|||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.onError((error, to) => {
|
||||||
|
// Si falla la carga de un chunk (al actualizar la app), recarga la página para obtener la última versión
|
||||||
|
if (error.message.includes('Failed to fetch dynamically imported module') || error.message.includes('Importing a module script failed')) {
|
||||||
|
window.location.href = to.fullPath
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
@ -45,15 +45,10 @@ onMounted(async () => {
|
|||||||
loadingVisible.value = true
|
loadingVisible.value = true
|
||||||
|
|
||||||
// Timeout logic
|
// Timeout logic
|
||||||
const initTimeout = setTimeout(async () => {
|
const initTimeout = setTimeout(() => {
|
||||||
console.warn('Initialization taking too long, forcing navigation...')
|
console.warn('Initialization taking too long, forcing navigation...')
|
||||||
statusMessage.value = 'Iniciando de todas formas...'
|
statusMessage.value = 'Iniciando modo sin conexión...'
|
||||||
try {
|
router.replace('/map')
|
||||||
const resp = await supabase.auth.getSession()
|
|
||||||
navigate(resp.data.session)
|
|
||||||
} catch {
|
|
||||||
navigate()
|
|
||||||
}
|
|
||||||
}, 4000)
|
}, 4000)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export default defineConfig(() => {
|
|||||||
vue(),
|
vue(),
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
|
selfDestroying: true,
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
includeAssets: ['icon-192.png', 'icon-512.png', 'icon-1024.png', 'favicon.ico'],
|
includeAssets: ['icon-192.png', 'icon-512.png', 'icon-1024.png', 'favicon.ico'],
|
||||||
manifest: {
|
manifest: {
|
||||||
|
|||||||
Reference in New Issue
Block a user