fix(web): resolve chat image freeze and dynamic import failures

- attachment-block: use loading=eager with explicit dimensions to prevent Chromium lazy-load intervention from freezing the page
- router: add error handler for chunk load failures to auto-reload
- vite: pre-bundle route page dependencies to improve initial load speed
This commit is contained in:
Acbox
2026-03-10 00:19:14 +08:00
parent a5c364911e
commit ef7ed961a9
3 changed files with 22 additions and 1 deletions
@@ -16,7 +16,9 @@
:src="getUrl(att)"
:alt="String(att.name ?? 'image')"
class="w-full h-full object-contain pointer-events-none"
loading="lazy"
loading="eager"
width="192"
height="192"
>
<video
v-else
+15
View File
@@ -133,6 +133,21 @@ const router = createRouter({
history: createWebHistory(),
routes,
})
// Handle chunk load errors (e.g. user aborted refresh, network failure, new deployment)
router.onError((error) => {
const isChunkLoadError =
error.message.includes('Failed to fetch dynamically imported module') ||
error.message.includes('Importing a module script failed') ||
error.message.includes('error loading dynamically imported module')
if (isChunkLoadError) {
console.warn('[Router] Chunk load failed, reloading...', error.message)
window.location.reload()
return
}
throw error
})
router.beforeEach((to) => {
const token = localStorage.getItem('token')