fix(admin-web): auto-reload on stale dynamic-import chunks after deploy
Listen for vite:preloadError and router onError, force a one-shot reload (10s cooldown via sessionStorage) when a hashed lazy-loaded module 404s because a new deploy replaced it. Eliminates the user-visible "Failed to fetch dynamically imported module" error on login and route navigation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
import { isChunkLoadError, reloadForStaleChunk } from '@/lib/chunk-reload'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { pinia } from '@/stores/pinia'
|
||||
|
||||
@@ -282,4 +283,10 @@ router.beforeEach(async (to) => {
|
||||
return true
|
||||
})
|
||||
|
||||
router.onError((err) => {
|
||||
if (isChunkLoadError(err)) {
|
||||
reloadForStaleChunk()
|
||||
}
|
||||
})
|
||||
|
||||
export { router }
|
||||
|
||||
Reference in New Issue
Block a user