mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-10-11 21:29:50 +02:00
Use nuxtaptparty insstead of openfetch
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import MangaDetailPage from '~/components/MangaDetailPage.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const mangaId = route.params.MangaId as string;
|
||||
|
||||
const { data: manga } = useApi('/v2/Manga/{MangaId}', { path: { MangaId: route.params.mangaId as string } });
|
||||
const { data: manga } = await useApiData('/v2/Manga/{MangaId}', { path: { MangaId: mangaId }, key: FetchKeys.Manga.Id(mangaId) });
|
||||
</script>
|
||||
|
@@ -13,7 +13,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { data: manga } = useApi('/v2/Manga');
|
||||
const { data: manga } = await useApiData('/v2/Manga', { key: FetchKeys.Manga.All });
|
||||
const expanded = ref(-1);
|
||||
</script>
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
import MangaDetailPage from '~/components/MangaDetailPage.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const mangaId = route.params.MangaId as string;
|
||||
|
||||
const { data: manga } = useApi('/v2/Manga/{MangaId}', { path: { MangaId: route.params.mangaId as string } });
|
||||
const { data: manga } = await useApiData('/v2/Manga/{MangaId}', { path: { MangaId: mangaId }, key: FetchKeys.Manga.Id(mangaId) });
|
||||
</script>
|
||||
|
@@ -24,6 +24,6 @@ const route = useRoute();
|
||||
const targetId = route.params.targetId as string;
|
||||
const mangaId = route.params.mangaId as string;
|
||||
|
||||
const { data: target } = useApi('/v2/Manga/{MangaId}', { path: { MangaId: targetId } });
|
||||
const { data: manga } = useApi('/v2/Manga/{MangaId}', { path: { MangaId: mangaId } });
|
||||
const { data: target } = await useApiData('/v2/Manga/{MangaId}', { path: { MangaId: targetId }, key: FetchKeys.Manga.Id(targetId) });
|
||||
const { data: manga } = await useApiData('/v2/Manga/{MangaId}', { path: { MangaId: mangaId }, key: FetchKeys.Manga.Id(mangaId) });
|
||||
</script>
|
||||
|
@@ -10,6 +10,6 @@
|
||||
<script setup lang="ts">
|
||||
const route = useRoute();
|
||||
|
||||
const { data: manga } = useApi('/v2/Manga/{MangaId}', { path: { MangaId: route.params.mangaId as string } });
|
||||
const { data: mangas } = useApi('/v2/Manga');
|
||||
const { data: manga } = await useApiData('/v2/Manga/{MangaId}', { path: { MangaId: route.params.mangaId as string }, key: FetchKeys.Manga.Id(mangaId) });
|
||||
const { data: mangas } = await useApiData('/v2/Manga', { key: FetchKeys.Manga.All });
|
||||
</script>
|
||||
|
@@ -46,12 +46,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { components } from '#open-fetch-schemas/api';
|
||||
import {$api, type ApiModel} from '#nuxt-api-party'
|
||||
import type { StepperItem } from '@nuxt/ui';
|
||||
type MangaConnector = components['schemas']['MangaConnector'];
|
||||
type MinimalManga = components['schemas']['MinimalManga'];
|
||||
type MangaConnector = ApiModel<"MangaConnector">;
|
||||
type MinimalManga = ApiModel<'MinimalManga'>;
|
||||
|
||||
const { data: connectors } = useApi('/v2/MangaConnector');
|
||||
const { data: connectors } = await useApiData('/v2/MangaConnector', { FetchKeys: FetchKeys.MangaConnector.All });
|
||||
|
||||
const query = ref<string>();
|
||||
const connector = useState<MangaConnector>();
|
||||
@@ -95,14 +95,10 @@ const config = useRuntimeConfig();
|
||||
|
||||
const search = async (query: string): Promise<MinimalManga[]> => {
|
||||
if (isUrl(query)) {
|
||||
return await $fetch<MinimalManga>(new Request(`${config.public.openFetch.api.baseURL}v2/Search/Url`), {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(query),
|
||||
}).then((x) => [x]);
|
||||
return await $api<'/v2/Search/Url', MinimalManga>('/v2/Search/Url', { body: JSON.stringify(query), method: "POST" })
|
||||
.then((x) => [x]);
|
||||
} else if (connector.value) {
|
||||
return await $fetch<MinimalManga[]>(
|
||||
new Request(`${config.public.openFetch.api.baseURL}v2/Search/${connector.value.name}/${query}`)
|
||||
);
|
||||
return await $api('/v2/Search/{MangaConnectorName}/{Query}', { path: { MangaConnectorName: connector.value.name, query: query }, method: "POST" });
|
||||
}
|
||||
return Promise.reject();
|
||||
};
|
||||
|
@@ -1,8 +1,10 @@
|
||||
<template>
|
||||
<UPageSection title="Settings"/>
|
||||
<UPageSection title="Settings" />
|
||||
<UPageSection title="Libraries" orientation="horizontal">
|
||||
<template #footer>
|
||||
<UButton icon="i-lucide-plus" class="w-fit" @click="() => addLibraryModal.open()">Add</UButton>
|
||||
</template>
|
||||
<FileLibraries />
|
||||
<UButton icon="i-lucide-plus" class="w-fit" @click="() => addLibraryModal.open()">Add</UButton>
|
||||
</UPageSection>
|
||||
<UPageSection title="Maintenance" orientation="horizontal">
|
||||
<div class="flex flex-col gap-1 items-end basis-1">
|
||||
@@ -17,16 +19,17 @@
|
||||
import { LazyAddLibraryModal } from '#components';
|
||||
|
||||
import FileLibraries from '~/components/FileLibraries.vue';
|
||||
import {refreshNuxtData} from "#app";
|
||||
const overlay = useOverlay();
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
const addLibraryModal = overlay.create(LazyAddLibraryModal);
|
||||
|
||||
const cleanUpDatabaseBusy = ref(false);
|
||||
const cleanUpDatabase = () => {
|
||||
const cleanUpDatabase = async () => {
|
||||
cleanUpDatabaseBusy.value = true;
|
||||
$fetch(`${config.public.openFetch.api.baseURL}v2/Maintenance/CleanupNoDownloadManga`).finally(
|
||||
() => (cleanUpDatabaseBusy.value = false)
|
||||
);
|
||||
await $api('/v2/Maintenance/CleanupNoDownloadManga', { method: 'POST' })
|
||||
.then(() => refreshNuxtData(Keys.Manga.All))
|
||||
.finally(() => cleanUpDatabaseBusy.value = false);
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user