fix: smooth book navigation by preventing view remount on bookId change

This commit is contained in:
neon
2026-03-10 04:14:33 -06:00
parent 0a533ed2e1
commit c882b8f2fe
2 changed files with 4 additions and 2 deletions
+4 -1
View File
@@ -10,6 +10,9 @@ const route = useRoute()
const themeStore = useThemeStore()
const backgroundClass = computed(() => BACKGROUND_OPTIONS.find((b) => b.id === themeStore.background)?.cssClass ?? '')
const BOOK_ROUTE_NAMES = new Set(['book-detail', 'book-edit', 'book-files'])
const viewKey = computed(() => (BOOK_ROUTE_NAMES.has(String(route.name)) ? String(route.name) : route.path))
</script>
<template>
@@ -21,7 +24,7 @@ const backgroundClass = computed(() => BACKGROUND_OPTIONS.find((b) => b.id === t
<!-- 2. Independent View Area: Everything below the header scrolls here -->
<div class="px-4 pt-2 flex-1 overflow-y-auto overflow-x-hidden relative scroll-smooth bg-transparent">
<router-view :key="route.path" />
<router-view :key="viewKey" />
<!-- Bottom gutter matching the top floating margin -->
<div class="h-6 w-full" />
</div>
@@ -10,7 +10,6 @@ export function useBookDetail() {
async function fetch(bookId: number) {
loading.value = true
error.value = null
detail.value = null
try {
const res = await api(`/api/v1/books/${bookId}`)
if (!res.ok) throw new Error(`HTTP ${res.status}`)