Merge pull request #313 from mt21625457/main

fix(ci): 修复各类bug
This commit is contained in:
Wesley Liddick
2026-01-16 19:30:07 +08:00
committed by GitHub
12 changed files with 1371 additions and 15 deletions

View File

@@ -400,9 +400,33 @@ router.beforeEach((to, _from, next) => {
/**
* Navigation guard: Error handling
* Handles dynamic import failures caused by deployment updates
*/
router.onError((error) => {
console.error('Router error:', error)
// Check if this is a dynamic import failure (chunk loading error)
const isChunkLoadError =
error.message?.includes('Failed to fetch dynamically imported module') ||
error.message?.includes('Loading chunk') ||
error.message?.includes('Loading CSS chunk') ||
error.name === 'ChunkLoadError'
if (isChunkLoadError) {
// Avoid infinite reload loop by checking sessionStorage
const reloadKey = 'chunk_reload_attempted'
const lastReload = sessionStorage.getItem(reloadKey)
const now = Date.now()
// Allow reload if never attempted or more than 10 seconds ago
if (!lastReload || now - parseInt(lastReload) > 10000) {
sessionStorage.setItem(reloadKey, now.toString())
console.warn('Chunk load error detected, reloading page to fetch latest version...')
window.location.reload()
} else {
console.error('Chunk load error persists after reload. Please clear browser cache.')
}
}
})
export default router