Use nuxtopenfetch

This commit is contained in:
2025-10-10 20:13:29 +02:00
parent 1bce60af7d
commit 48d355d657
19 changed files with 2039 additions and 1660 deletions

View File

@@ -15,20 +15,22 @@
</template>
<script setup lang="ts">
import type { ApiModel } from '#nuxt-api-party';
import type { components } from '#open-fetch-schemas/api';
type CreateLibraryRecord = components['schemas']['CreateLibraryRecord'];
const name = ref('');
const path = ref('');
const model = computed((): ApiModel<'CreateLibraryRecord'> => {
const model: ComputedRef = computed((): CreateLibraryRecord => {
return { basePath: path.value, libraryName: name.value };
});
const busy = ref(false);
const onAddClick = async () => {
if (!model.value) return;
busy.value = true;
await $api('/v2/FileLibrary', { method: 'PUT', body: model.value })
.then(() => refreshNuxtData(Keys.FileLibraries))
await useApi('/v2/FileLibrary', { method: 'PUT', body: model.value })
.then(() => refreshNuxtData(FetchKeys.FileLibraries))
.finally(() => (busy.value = false));
};
</script>

View File

@@ -36,7 +36,7 @@ export interface ChaptersListProps {
}
const props = defineProps<ChaptersListProps>();
const { data: chapters } = await useApiData('/v2/Manga/{MangaId}/Chapters', {
const { data: chapters } = await useApi('/v2/Manga/{MangaId}/Chapters', {
path: { MangaId: props.mangaId },
key: FetchKeys.Chapters.All,
});

View File

@@ -13,14 +13,14 @@
</template>
<script setup lang="ts">
import type { ApiModel } from '#nuxt-api-party';
type FileLibrary = ApiModel<'FileLibrary'>;
const { data: fileLibraries } = await useApiData('/v2/FileLibrary', { key: FetchKeys.FileLibraries });
import type { components } from '#open-fetch-schemas/api';
type FileLibrary = components['schemas']['FileLibrary'];
const { data: fileLibraries } = await useApi('/v2/FileLibrary', { key: FetchKeys.FileLibraries });
const busy = ref(false);
const deleteLibrary = async (l: FileLibrary) => {
const deleteLibrary = async (library: FileLibrary) => {
busy.value = true;
await $api('/v2/FileLibrary/{FileLibraryId}', { path: { FileLibraryId: l.key }, method: 'DELETE' })
await useApi('/v2/FileLibrary/{FileLibraryId}', { path: { FileLibraryId: library.key }, method: 'DELETE' })
.then(() => refreshNuxtData(FetchKeys.FileLibraries))
.finally(() => (busy.value = false));
};

View File

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

View File

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

View File

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

View File

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