mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-10-15 09:50:48 +02:00
Fix useFetch misuse (use $fetch instead)
This commit is contained in:
@@ -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>
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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 },
|
||||
});
|
||||
|
Reference in New Issue
Block a user