Fix useFetch misuse (use $fetch instead)

This commit is contained in:
2025-10-14 14:21:20 +02:00
parent 6a5bf947a1
commit a01dc430e6
8 changed files with 31 additions and 14 deletions

View File

@@ -17,6 +17,7 @@
<script setup lang="ts">
import type { components } from '#open-fetch-schemas/api';
type CreateLibraryRecord = components['schemas']['CreateLibraryRecord'];
const { $api } = useNuxtApp();
const name = ref('');
const path = ref('');
@@ -29,8 +30,8 @@ const busy = ref(false);
const onAddClick = async () => {
if (!model.value) return;
busy.value = true;
await useApi('/v2/FileLibrary', { method: 'PUT', body: model.value })
.then(() => refreshNuxtData(FetchKeys.FileLibraries))
.finally(() => (busy.value = false));
await $api('/v2/FileLibrary', { method: 'PUT', body: model.value });
await refreshNuxtData(FetchKeys.FileLibraries);
busy.value = false;
};
</script>

View File

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

View File

@@ -24,6 +24,8 @@
</template>
<script setup lang="ts">
const { $api } = useNuxtApp();
export interface LibrarySelectProps {
mangaId: string;
libraryId?: string;
@@ -38,7 +40,7 @@ const loading = ref(false);
const onLibrarySelectChange = async () => {
if (!library.value) return;
loading.value = true;
await useApi('/v2/Manga/{MangaId}/ChangeLibrary/{LibraryId}', {
await $api('/v2/Manga/{MangaId}/ChangeLibrary/{LibraryId}', {
method: 'POST',
path: { MangaId: props.mangaId, LibraryId: library.value },
});