feat: refactor news and migrate rest of useFetch to $dropFetch

This commit is contained in:
DecDuck
2025-03-14 13:12:04 +11:00
parent bd1cb67cd0
commit 1de9ebdfa5
23 changed files with 299 additions and 297 deletions

View File

@ -176,6 +176,5 @@ useHead({
title: "Home",
});
const headers = useRequestHeaders(["cookie"]);
const libraryState = await $dropFetch("/api/v1/admin/library", { headers });
const libraryState = await $dropFetch("/api/v1/admin/library");
</script>

View File

@ -551,13 +551,9 @@ definePageMeta({
const router = useRouter();
const route = useRoute();
const headers = useRequestHeaders(["cookie"]);
const gameId = route.params.id.toString();
const versions = await $dropFetch(
`/api/v1/admin/import/version?id=${encodeURIComponent(gameId)}`,
{
headers,
}
`/api/v1/admin/import/version?id=${encodeURIComponent(gameId)}`
);
const currentlySelectedVersion = ref(-1);
const versionSettings = ref<{

View File

@ -321,7 +321,10 @@
{{ item.delta ? "Upgrade mode" : "" }}
</div>
<div class="inline-flex items-center gap-x-2">
<component :is="PLATFORM_ICONS[item.platform]" class="size-6 text-blue-600" />
<component
:is="PLATFORM_ICONS[item.platform]"
class="size-6 text-blue-600"
/>
<Bars3Icon class="cursor-move w-6 h-6 text-zinc-400 handle" />
<button @click="() => deleteVersion(item.versionName)">
<TrashIcon class="w-5 h-5 text-red-600" />
@ -345,7 +348,7 @@
:options="{ id: game.id }"
accept="image/*"
endpoint="/api/v1/admin/game/image"
@upload="(result) => uploadAfterImageUpload(result)"
@upload="(result: Game) => uploadAfterImageUpload(result)"
/>
<ModalTemplate v-model="showAddCarouselModal">
<template #default>
@ -529,12 +532,8 @@ const mobileShowFinalDescription = ref(true);
const route = useRoute();
const gameId = route.params.id.toString();
const headers = useRequestHeaders(["cookie"]);
const { game: rawGame, unimportedVersions } = await $dropFetch(
`/api/v1/admin/game?id=${encodeURIComponent(gameId)}`,
{
headers,
}
`/api/v1/admin/game?id=${encodeURIComponent(gameId)}`
);
const game = ref(rawGame);

View File

@ -157,8 +157,7 @@ definePageMeta({
layout: "admin",
});
const headers = useRequestHeaders(["cookie"]);
const games = await $dropFetch("/api/v1/admin/import/game", { headers });
const games = await $dropFetch("/api/v1/admin/import/game");
const currentlySelectedGame = ref(-1);
const gameSearchResultsLoading = ref(false);

View File

@ -179,8 +179,7 @@ useHead({
const searchQuery = ref("");
const headers = useRequestHeaders(["cookie"]);
const libraryState = await $dropFetch("/api/v1/admin/library", { headers });
const libraryState = await $dropFetch("/api/v1/admin/library");
const libraryGames = ref(
libraryState.games.map((e) => {
const noVersions = e.status.noVersions;

View File

@ -110,10 +110,7 @@ definePageMeta({
layout: "admin",
});
const headers = useRequestHeaders(["cookie"]);
const enabledMechanisms = await $dropFetch("/api/v1/admin/auth", {
headers,
});
const enabledMechanisms = await $dropFetch("/api/v1/admin/auth");
const authenticationMechanisms: Array<{
name: string;

View File

@ -391,12 +391,10 @@ useHead({
title: "Simple authentication",
});
const headers = useRequestHeaders(["cookie"]);
const { data } = await useFetch<Array<SerializeObject<Invitation>>>(
"/api/v1/admin/auth/invitation",
{ headers }
const data = await $dropFetch<Array<SerializeObject<Invitation>>>(
"/api/v1/admin/auth/invitation"
);
const invitations = ref(data.value ?? []);
const invitations = ref(data ?? []);
const generateInvitationUrl = (id: string) =>
`${window.location.protocol}//${window.location.host}/register?id=${id}`;

View File

@ -106,6 +106,5 @@ definePageMeta({
layout: "admin",
});
const headers = useRequestHeaders(["cookie"]);
const { data: users } = await useFetch("/api/v1/admin/users", { headers });
const users = await $dropFetch("/api/v1/admin/users");
</script>