Use nuxtaptparty insstead of openfetch

This commit is contained in:
2025-09-28 19:33:55 +02:00
parent a7d281e300
commit 93c9b0b365
20 changed files with 176 additions and 112 deletions

View File

@@ -15,23 +15,20 @@
</template>
<script setup lang="ts">
import type { components } from '#open-fetch-schemas/api';
import type { ApiModel } from '#nuxt-api-party';
const name = ref('');
const path = ref('');
const model = computed((): components['schemas']['CreateLibraryRecord'] => {
const model = computed((): ApiModel<'CreateLibraryRecord'> => {
return { basePath: path.value, libraryName: name.value };
});
const config = useRuntimeConfig();
const busy = ref(false);
const onAddClick = () => {
const onAddClick = async () => {
busy.value = true;
$fetch(new Request(`${config.public.openFetch.api.baseURL}v2/FileLibrary`), { method: 'PUT', body: model.value })
.then(() => emit('change'))
await $api('/v2/FileLibrary', { method: 'PUT', body: model.value })
.then(() => refreshNuxtData(Keys.FileLibraries))
.finally(() => (busy.value = false));
};
const emit = defineEmits(['change']);
</script>

View File

@@ -31,12 +31,11 @@
</template>
<script setup lang="ts">
import { id } from '#ui/locale';
export interface ChaptersListProps {
mangaId: string;
}
const props = defineProps<ChaptersListProps>();
const { data: chapters } = useApi('/v2/Manga/{MangaId}/Chapters', { path: { MangaId: props.mangaId } });
const { data: chapters } = await useApiData('/v2/Manga/{MangaId}/Chapters', { path: { MangaId: props.mangaId }, key: FetchKeys.Chapters.All });
</script>

View File

@@ -1,8 +1,8 @@
<template>
<UPageList divide>
<UPageList class="gap-2">
<UPageCard
v-for="l in fileLibraries"
variant="ghost"
variant="soft"
icon="i-lucide-library-big"
:title="l.libraryName"
:description="l.basePath"
@@ -13,19 +13,15 @@
</template>
<script setup lang="ts">
import type { components } from '#open-fetch-schemas/api';
type FileLibrary = components['schemas']['FileLibrary'];
const { data: fileLibraries, refresh } = useApi('/v2/FileLibrary');
import type { ApiModel } from '#nuxt-api-party'
type FileLibrary = ApiModel<"FileLibrary">;
const { data: fileLibraries } = await useApiData('/v2/FileLibrary', { key: FetchKeys.FileLibraries });
const config = useRuntimeConfig();
const busy = ref(false);
const deleteLibrary = (l: FileLibrary) => {
const deleteLibrary = async (l: FileLibrary) => {
busy.value = true;
$fetch(new Request(`${config.public.openFetch.api.baseURL}v2/FileLibrary/${l.key}`), { method: 'DELETE' }).finally(
() => {
refresh();
busy.value = false;
}
);
await $api('/v2/FileLibrary/{FileLibraryId}', { path: { FileLibraryId: l.key }, method: 'DELETE' })
.then(() => refreshNuxtData(FetchKeys.FileLibraries))
.finally(() => busy.value = false)
};
</script>

View File

@@ -33,10 +33,10 @@
</template>
<script setup lang="ts">
import type { components } from '#open-fetch-schemas/api';
import type { ApiModel } from '#nuxt-api-party'
import type { PageCardProps } from '#ui/components/PageCard.vue';
type Manga = components['schemas']['Manga'];
type MinimalManga = components['schemas']['MinimalManga'];
type Manga = ApiModel<'Manga'>;
type MinimalManga = ApiModel<'MinimalManga'>;
defineProps<MangaCardProps>();
defineEmits(['click']);

View File

@@ -12,14 +12,14 @@
<p class="p-3 text-xl font-semibold max-h-full overflow-clip">{{ manga?.name }}</p>
</div>
<LazyNuxtImg
:src="`${$config.public.openFetch.api.baseURL}v2/Manga/${manga.key}/Cover/Medium`"
:src="`${$config.public.apiParty.endpoints.Api!.url}v2/Manga/${manga.key}/Cover/Medium`"
class="w-full h-full object-cover" />
</div>
</template>
<script setup lang="ts">
import type { components } from '#open-fetch-schemas/api';
type MinimalManga = components['schemas']['MinimalManga'];
type Manga = components['schemas']['Manga'];
import type { ApiModel } from '#nuxt-api-party'
type MinimalManga = ApiModel<'MinimalManga'>;
type Manga = ApiModel<'Manga'>;
defineProps<{ manga: Manga | MinimalManga; blur?: boolean }>();
</script>

View File

@@ -40,8 +40,8 @@
</template>
<script setup lang="ts">
import type { components } from '#open-fetch-schemas/api';
type Manga = components['schemas']['Manga'];
import type { ApiModel } from '#nuxt-api-party'
type Manga = ApiModel<'Manga'>;
export interface MangaDetailPageProps {
manga?: Manga;

View File

@@ -14,12 +14,12 @@
</template>
<script setup lang="ts">
import type { components } from '#open-fetch-schemas/api';
type MangaConnectorId = components['schemas']['MangaConnectorId'];
import type { ApiModel } from '#nuxt-api-party'
type MangaConnectorId = /* @vue-ignore */ ApiModel<'MangaConnectorId'>;
const props = defineProps<MangaConnectorId>();
const { data: mangaConnector } = useApi('/v2/MangaConnector/{MangaConnectorName}', {
path: { MangaConnectorName: props.mangaConnectorName },
const { data: mangaConnector } = await useApiData('/v2/MangaConnector/{MangaConnectorName}', {
path: { MangaConnectorName: props.mangaConnectorName }, key: FetchKeys.MangaConnector.Id(props.mangaConnectorName),
});
</script>