Fix LibrarySelect

Move recursive routing to trangapage
This commit is contained in:
2025-10-16 21:35:12 +02:00
parent 732e1a7b1f
commit 2b6818b09e
13 changed files with 72 additions and 58 deletions

View File

@@ -26,7 +26,7 @@
<template #right> <template #right>
<UButton icon="i-lucide-plus" to="/search" color="primary">Manga</UButton> <UButton icon="i-lucide-plus" to="/search" color="primary">Manga</UButton>
<UColorModeButton color="secondary" /> <UColorModeButton color="secondary" />
<UButton icon="i-lucide-settings" variant="ghost" to="/settings" color="secondary" /> <UButton icon="i-lucide-settings" variant="ghost" :to="`/settings?return=${$route.fullPath}`" color="secondary" />
</template> </template>
</UHeader> </UHeader>
<UMain> <UMain>

View File

@@ -1,11 +1,13 @@
<template> <template>
<USkeleton v-if="libraryId === undefined" class="w-full h-8" />
<USelect <USelect
v-else
v-model="library" v-model="library"
placeholder="Library" placeholder="Library"
icon="i-lucide-library-big" icon="i-lucide-library-big"
color="secondary" color="secondary"
:items="libraries?.map((l) => l.key)" :items="libraries?.map((l) => l.key)"
class="w-xs" :class="[libraryId ? '' : 'ring-warning animate-[pulse_1s]']"
:loading="loading" :loading="loading"
@change="onLibrarySelectChange"> @change="onLibrarySelectChange">
<template #default="{ modelValue }"> <template #default="{ modelValue }">
@@ -28,7 +30,7 @@ const { $api } = useNuxtApp();
export interface LibrarySelectProps { export interface LibrarySelectProps {
mangaId: string; mangaId: string;
libraryId?: string; libraryId?: string | null;
} }
const props = defineProps<LibrarySelectProps>(); const props = defineProps<LibrarySelectProps>();
@@ -49,7 +51,5 @@ const onLibrarySelectChange = async () => {
emit('libraryChanged', library.value); emit('libraryChanged', library.value);
}; };
const emit = defineEmits<{ const emit = defineEmits<{ (e: 'libraryChanged', id?: string): void }>();
(e: 'libraryChanged', id?: string): void;
}>();
</script> </script>

View File

@@ -1,5 +1,5 @@
<template> <template>
<TrangaPage v-bind="$props" :back="backUrl ? { href: backUrl, icon: 'i-lucide-arrow-left', text: 'Back' } : undefined"> <TrangaPage v-bind="$props">
<template #left> <template #left>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<MangaCover v-if="manga" :manga="manga" class="self-center" /> <MangaCover v-if="manga" :manga="manga" class="self-center" />
@@ -8,13 +8,13 @@
{{ manga.name }} {{ manga.name }}
<MangaconnectorIcon v-for="m in manga.mangaConnectorIds" v-bind="m" :key="m.key" /> <MangaconnectorIcon v-for="m in manga.mangaConnectorIds" v-bind="m" :key="m.key" />
</p> </p>
<USkeleton v-else class="text-xl h-20 w-full" /> <USkeleton v-else as="p" class="h-20 w-full" />
<div v-if="manga" class="flex flex-row gap-1 flex-wrap"> <div v-if="manga" class="flex flex-row gap-1 flex-wrap">
<UBadge v-for="author in manga.authors" :key="author.key" variant="outline" color="neutral" <UBadge v-for="author in manga.authors" :key="author.key" variant="outline" color="neutral"
><NuxtLink :to="`/manga/author/${author.key}?return=${path}`">{{ author.name }}</NuxtLink></UBadge ><NuxtLink :to="`/manga/author/${author.key}?return=${$route.fullPath}`">{{ author.name }}</NuxtLink></UBadge
> >
<UBadge v-for="tag in manga.tags" :key="tag" variant="outline" color="primary" <UBadge v-for="tag in manga.tags" :key="tag" variant="outline" color="primary"
><NuxtLink :to="`/manga/tag/${tag}?return=${path}`">{{ tag }}</NuxtLink></UBadge ><NuxtLink :to="`/manga/tag/${tag}?return=${$route.fullPath}`">{{ tag }}</NuxtLink></UBadge
> >
<NuxtLink v-for="link in manga.links" :key="link.key" :to="link.url" external no-prefetch> <NuxtLink v-for="link in manga.links" :key="link.key" :to="link.url" external no-prefetch>
<UBadge variant="outline" color="secondary">{{ link.provider }}</UBadge> <UBadge variant="outline" color="secondary">{{ link.provider }}</UBadge>
@@ -36,11 +36,9 @@
import type { components } from '#open-fetch-schemas/api'; import type { components } from '#open-fetch-schemas/api';
import TrangaPage, { type PageProps } from '~/components/TrangaPage.vue'; import TrangaPage, { type PageProps } from '~/components/TrangaPage.vue';
type Manga = components['schemas']['Manga']; type Manga = components['schemas']['Manga'];
const path = useRoute().fullPath;
export interface MangaDetailPageProps extends PageProps { export interface MangaDetailPageProps extends PageProps {
manga?: Manga; manga?: Manga;
backUrl?: string;
} }
defineProps<MangaDetailPageProps>(); defineProps<MangaDetailPageProps>();

View File

@@ -7,9 +7,13 @@
<div :class="['flex flex-col gap-2 w-full py-4 relative max-md:px-2', $slots.left ? '' : 'pl-4']"> <div :class="['flex flex-col gap-2 w-full py-4 relative max-md:px-2', $slots.left ? '' : 'pl-4']">
<div class="w-full flex flex-row justify-between mb-4"> <div class="w-full flex flex-row justify-between mb-4">
<div class="flex flex-row gap-6"> <div class="flex flex-row gap-6">
<UButton variant="outline" color="neutral" :to="back?.href ?? '/'" :icon="back?.icon ?? 'i-lucide-home'">{{ <UButton
back?.text ?? 'Home' variant="outline"
}}</UButton> color="neutral"
:to="backUrl ?? '/'"
:icon="backUrl ? 'i-lucide-arrow-left' : 'i-lucide-home'"
>{{ backUrl ? 'Back' : 'Home' }}</UButton
>
<slot name="title"> <slot name="title">
<p v-if="title" class="text-2xl text-primary font-semibold">{{ title }}</p> <p v-if="title" class="text-2xl text-primary font-semibold">{{ title }}</p>
</slot> </slot>
@@ -27,9 +31,11 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PageBodyProps } from '#ui/components/PageBody.vue'; import type { PageBodyProps } from '#ui/components/PageBody.vue';
const route = useRoute();
const backUrl = route.query.return as string | undefined;
export interface PageProps extends PageBodyProps { export interface PageProps extends PageBodyProps {
title?: string; title?: string;
back?: { href?: string; text?: string; icon?: string };
} }
defineProps<PageProps>(); defineProps<PageProps>();

View File

@@ -0,0 +1,5 @@
<template>
<TrangaPage />
</template>
<script setup lang="ts"></script>

View File

@@ -1,5 +1,5 @@
<template> <template>
<MangaDetailPage :manga="manga" :back-url="backUrl"> <MangaDetailPage :manga="manga">
<div class="grid gap-3 max-xl:grid-flow-row-dense min-2xl:grid-cols-[70%_auto] min-xl:grid-cols-[60%_auto]"> <div class="grid gap-3 max-xl:grid-flow-row-dense min-2xl:grid-cols-[70%_auto] min-xl:grid-cols-[60%_auto]">
<ChaptersList :manga-id="mangaId" /> <ChaptersList :manga-id="mangaId" />
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
@@ -7,7 +7,11 @@
<template #header> <template #header>
<h1 class="font-semibold">Download</h1> <h1 class="font-semibold">Download</h1>
</template> </template>
<LibrarySelect :manga-id="mangaId" :library-id="manga?.fileLibraryId" class="w-full" @library-changed="refreshNuxtData(FetchKeys.Manga.Id(mangaId))" /> <LibrarySelect
:manga-id="mangaId"
:library-id="manga?.fileLibraryId"
class="w-full"
@library-changed="refreshNuxtData(FetchKeys.Manga.Id(mangaId))" />
<div v-if="manga" class="flex flex-row gap-2 w-full flex-wrap my-2 justify-between"> <div v-if="manga" class="flex flex-row gap-2 w-full flex-wrap my-2 justify-between">
<div <div
v-for="mangaconnectorId in manga.mangaConnectorIds.sort((a, b) => v-for="mangaconnectorId in manga.mangaConnectorIds.sort((a, b) =>
@@ -41,28 +45,34 @@
{ header: '', id: 'link' }, { header: '', id: 'link' },
]"> ]">
<template #name-cell="{ row }"> <template #name-cell="{ row }">
<UTooltip :text="metadata.find((me) => me.metadataFetcherName == row.original)?.identifier ?? undefined">{{ <UTooltip :text="metadata.find((me) => me.metadataFetcherName == row.original)?.identifier ?? undefined">
row.original <p class="text-toned">{{ row.original }}</p></UTooltip
}}</UTooltip> >
</template> </template>
<template #link-cell="{ row }"> <template #link-cell="{ row }">
<UButton <UButton
v-if="metadata.find((me) => me.metadataFetcherName == row.original)" v-if="metadata.find((me) => me.metadataFetcherName == row.original)"
class="float-right px-4" class="float-right"
@click="unlinkMetadataFetcher(row.original)" icon="i-lucide-unlink"
>Unlink</UButton @click="unlinkMetadataFetcher(row.original)" />
> <UButton
<UButton v-else :to="`/manga/${mangaId}/linkMetadata/${row.original}?return=${path}`" class="float-right px-4" v-else
>Link</UButton :to="`/manga/${mangaId}/linkMetadata/${row.original}?return=${$route.fullPath}`"
> class="float-right"
icon="i-lucide-link" />
</template> </template>
</UTable> </UTable>
</UCard> </UCard>
</div> </div>
</div> </div>
<template #actions> <template #actions>
<UButton trailing-icon="i-lucide-merge" :to="`/manga/${manga?.key}/merge?return=${path}`" color="secondary">Merge</UButton> <UButton trailing-icon="i-lucide-merge" :to="`/manga/${manga?.key}/merge?return=${$route.fullPath}`" color="secondary"
>Merge</UButton
>
<UButton variant="soft" color="warning" icon="i-lucide-trash" @click="remove" /> <UButton variant="soft" color="warning" icon="i-lucide-trash" @click="remove" />
<UTooltip text="Reload" :kbds="['meta', 'R']">
<UButton variant="soft" color="secondary" icon="i-lucide-refresh-ccw" :loading="refreshingData" @click="refreshData" />
</UTooltip>
</template> </template>
</MangaDetailPage> </MangaDetailPage>
</template> </template>
@@ -72,8 +82,6 @@ import MangaDetailPage from '~/components/MangaDetailPage.vue';
const { $api } = useNuxtApp(); const { $api } = useNuxtApp();
const route = useRoute(); const route = useRoute();
const mangaId = route.params.mangaId as string; const mangaId = route.params.mangaId as string;
const backUrl = route.query.return as string | undefined;
const path = route.fullPath;
const flashDownloading = route.query.download; const flashDownloading = route.query.download;
@@ -116,6 +124,15 @@ const remove = async () => {
navigateTo('/'); navigateTo('/');
}; };
const refreshingData = ref(false);
const refreshData = async () => {
refreshingData.value = true;
await refreshNuxtData([FetchKeys.Manga.Id(mangaId), FetchKeys.Metadata.Manga(mangaId), FetchKeys.FileLibraries]);
refreshingData.value = false;
};
defineShortcuts({ meta_r: { usingInput: true, handler: refreshData } });
useHead({ title: 'Manga' }); useHead({ title: 'Manga' });
</script> </script>

View File

@@ -1,5 +1,5 @@
<template> <template>
<MangaDetailPage :manga="manga" :back-url="backUrl" :title="metadataFetcherName"> <MangaDetailPage :manga="manga" :title="metadataFetcherName">
<div class="flex flex-col flex-wrap gap-2"> <div class="flex flex-col flex-wrap gap-2">
<USkeleton v-if="status === 'pending'" class="w-full h-14" /> <USkeleton v-if="status === 'pending'" class="w-full h-14" />
<UCard v-for="data in searchData" v-else :key="data.identifier"> <UCard v-for="data in searchData" v-else :key="data.identifier">
@@ -23,7 +23,6 @@
const route = useRoute(); const route = useRoute();
const mangaId = route.params.mangaId as string; const mangaId = route.params.mangaId as string;
const metadataFetcherName = route.params.metadataFetcherName as string; const metadataFetcherName = route.params.metadataFetcherName as string;
const backUrl = route.query.return as string | undefined;
const { $api } = useNuxtApp(); const { $api } = useNuxtApp();
const { data: manga } = await useApi('/v2/Manga/{MangaId}', { const { data: manga } = await useApi('/v2/Manga/{MangaId}', {

View File

@@ -1,5 +1,5 @@
<template> <template>
<TrangaPage :back="{ href: backUrl ?? `/manga/${mangaId}/merge/`, text: 'Back', icon: 'i-lucide-arrow-left' }"> <TrangaPage>
<div class="flex flex-col items-center justify-center gap-10"> <div class="flex flex-col items-center justify-center gap-10">
<div class="flex flex-row max-sm:flex-col justify-evenly items-center"> <div class="flex flex-row max-sm:flex-col justify-evenly items-center">
<MangaCard v-if="manga" :manga="manga" :expanded="true" /> <MangaCard v-if="manga" :manga="manga" :expanded="true" />
@@ -28,8 +28,6 @@
const route = useRoute(); const route = useRoute();
const targetId = route.params.targetId as string; const targetId = route.params.targetId as string;
const mangaId = route.params.mangaId as string; const mangaId = route.params.mangaId as string;
const path = route.fullPath;
const backUrl = route.query.return as string | undefined;
const { $api } = useNuxtApp(); const { $api } = useNuxtApp();
const reverse = ref(false); const reverse = ref(false);

View File

@@ -1,15 +1,12 @@
<template> <template>
<MangaDetailPage :manga="manga" :back-url="backUrl" title="Merge with"> <MangaDetailPage :manga="manga" title="Merge with">
<USkeleton v-if="!mangas" class="w-full h-[350px]" /> <USkeleton v-if="!mangas" class="w-full h-[350px]" />
<MangaCardList :manga="mangas" @click="(m) => navigateTo(`/manga/${mangaId}/merge/${m.key}?return=${path}`)" /> <MangaCardList :manga="mangas" @click="(m) => navigateTo(`/manga/${mangaId}/merge/${m.key}?return=${$route.fullPath}`)" />
</MangaDetailPage> </MangaDetailPage>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const route = useRoute(); const mangaId = useRoute().params.mangaId as string;
const mangaId = route.params.mangaId as string;
const backUrl = route.query.return as string | undefined;
const path = route.fullPath;
const { data: manga } = await useApi('/v2/Manga/{MangaId}', { path: { MangaId: mangaId }, key: FetchKeys.Manga.Id(mangaId) }); const { data: manga } = await useApi('/v2/Manga/{MangaId}', { path: { MangaId: mangaId }, key: FetchKeys.Manga.Id(mangaId) });
const { data: mangas } = await useApi('/v2/Manga', { key: FetchKeys.Manga.All }); const { data: mangas } = await useApi('/v2/Manga', { key: FetchKeys.Manga.All });

View File

@@ -1,20 +1,18 @@
<template> <template>
<TrangaPage :back="backUrl ? { href: backUrl, icon: 'i-lucide-arrow-left', text: 'Back' } : undefined"> <TrangaPage>
<template #title> <template #title>
<h1 class="text-2xl"> <h1 class="text-2xl">
Manga with Author <UBadge variant="outline" color="neutral" class="font-semibold text-xl ml-1">{{ author?.name }}</UBadge> Manga with Author <UBadge variant="outline" color="neutral" class="font-semibold text-xl ml-1">{{ author?.name }}</UBadge>
</h1> </h1>
</template> </template>
<LoadingPage :loading="status === 'pending'"> <LoadingPage :loading="status === 'pending'">
<MangaCardList :manga="manga" @click="(m) => navigateTo(`/manga/${m.key}?return=${route.fullPath}`)" /> <MangaCardList :manga="manga" @click="(m) => navigateTo(`/manga/${m.key}?return=${$route.fullPath}`)" />
</LoadingPage> </LoadingPage>
</TrangaPage> </TrangaPage>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const route = useRoute(); const authorId = useRoute().params.authorId as string;
const authorId = route.params.authorId as string;
const backUrl = route.query.return as string | undefined;
const { data: author } = await useApi('/v2/Author/{AuthorId}', { path: { AuthorId: authorId } }); const { data: author } = await useApi('/v2/Author/{AuthorId}', { path: { AuthorId: authorId } });
const { data: manga, status } = await useApi('/v2/Manga/WithAuthorId/{AuthorId}', { path: { AuthorId: authorId }, lazy: true }); const { data: manga, status } = await useApi('/v2/Manga/WithAuthorId/{AuthorId}', { path: { AuthorId: authorId }, lazy: true });

View File

@@ -1,20 +1,18 @@
<template> <template>
<TrangaPage :back="backUrl ? { href: backUrl, icon: 'i-lucide-arrow-left', text: 'Back' } : undefined"> <TrangaPage>
<template #title> <template #title>
<h1 class="text-2xl"> <h1 class="text-2xl">
Manga with Tag <UBadge variant="outline" color="primary" class="font-semibold text-xl ml-1">{{ tag }}</UBadge> Manga with Tag <UBadge variant="outline" color="primary" class="font-semibold text-xl ml-1">{{ tag }}</UBadge>
</h1> </h1>
</template> </template>
<LoadingPage :loading="status === 'pending'"> <LoadingPage :loading="status === 'pending'">
<MangaCardList :manga="manga" @click="(m) => navigateTo(`/manga/${m.key}?return=${route.fullPath}`)" /> <MangaCardList :manga="manga" @click="(m) => navigateTo(`/manga/${m.key}?return=${$route.fullPath}`)" />
</LoadingPage> </LoadingPage>
</TrangaPage> </TrangaPage>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const route = useRoute(); const tag = useRoute().params.tag as string;
const tag = route.params.tag as string;
const backUrl = route.query.return as string | undefined;
const { data: manga, status } = await useApi('/v2/Manga/WithTag/{Tag}', { path: { Tag: tag }, lazy: true }); const { data: manga, status } = await useApi('/v2/Manga/WithTag/{Tag}', { path: { Tag: tag }, lazy: true });
useHead({ title: 'Tag search' }); useHead({ title: 'Tag search' });

View File

@@ -39,7 +39,7 @@
:key="m.key" :key="m.key"
:manga="m" :manga="m"
:expanded="i === expanded" :expanded="i === expanded"
@click="navigateTo(`/manga/${m.key}?download=true&return=${path}`)" /> @click="navigateTo(`/manga/${m.key}?download=true&return=${$route.fullPath}`)" />
</div> </div>
</template> </template>
</UPageSection> </UPageSection>
@@ -52,8 +52,6 @@ import type { StepperItem } from '@nuxt/ui';
type MangaConnector = components['schemas']['MangaConnector']; type MangaConnector = components['schemas']['MangaConnector'];
type MinimalManga = components['schemas']['MinimalManga']; type MinimalManga = components['schemas']['MinimalManga'];
const path = useRoute().fullPath;
const { data: connectors } = await useApi('/v2/MangaConnector', { key: FetchKeys.MangaConnector.All }); const { data: connectors } = await useApi('/v2/MangaConnector', { key: FetchKeys.MangaConnector.All });
const query = ref<string>(); const query = ref<string>();

View File

@@ -1,5 +1,5 @@
<template> <template>
<UPageBody> <TrangaPage>
<UPageSection title="Settings"> <UPageSection title="Settings">
<template #description> <template #description>
<div> <div>
@@ -43,7 +43,7 @@
> >
</UCard> </UCard>
</UPageSection> </UPageSection>
</UPageBody> </TrangaPage>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -95,7 +95,7 @@ const onKavitaClick = async () => {
} }
}; };
const { data: settings, status: settingsStatus } = useApi('/v2/Settings', { key: FetchKeys.Settings.All }); const { status: settingsStatus } = useApi('/v2/Settings', { key: FetchKeys.Settings.All });
useHead({ title: 'Settings' }); useHead({ title: 'Settings' });
</script> </script>