mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
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:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ export default defineConfig(({ command }) => {
|
||||
|
||||
return {
|
||||
plugins: [vue(), tailwindcss()],
|
||||
optimizeDeps: {
|
||||
// Pre-bundle deps for route pages to avoid slow first load / navigation
|
||||
entries: ['src/main.ts', 'src/pages/**/*.vue'],
|
||||
},
|
||||
server: {
|
||||
port,
|
||||
host,
|
||||
|
||||
Reference in New Issue
Block a user