mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-16 09:41:13 +10:00
feat: partial user platform support + statusMessage -> message
This commit is contained in:
@ -180,7 +180,7 @@ if (route.query.payload) {
|
||||
} catch {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Failed to parse the token create payload.",
|
||||
message: "Failed to parse the token create payload.",
|
||||
fatal: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -727,7 +727,7 @@ function startImport_wrapper() {
|
||||
importLoading.value = true;
|
||||
startImport()
|
||||
.catch((error) => {
|
||||
importError.value = error.statusMessage ?? t("errors.unknown");
|
||||
importError.value = error.message ?? t("errors.unknown");
|
||||
})
|
||||
.finally(() => {
|
||||
importLoading.value = false;
|
||||
|
||||
@ -202,7 +202,7 @@
|
||||
:game-name="games.unimportedGames[currentlySelectedGame].game"
|
||||
:loading="importLoading"
|
||||
:error="importError"
|
||||
@import="(v: unknown) => importModes[currentImportMode].import(v)"
|
||||
@import="(...v: unknown[]) => importModes[currentImportMode].import(...v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@ -233,7 +233,7 @@ const importModes = shallowRef<{
|
||||
description: string;
|
||||
icon: Component;
|
||||
component: Component;
|
||||
import: (v: unknown) => void;
|
||||
import: (...v: unknown[]) => void;
|
||||
};
|
||||
}>({
|
||||
Game: {
|
||||
@ -249,7 +249,7 @@ const importModes = shallowRef<{
|
||||
"Redistributables are packaged dependencies for games, that are installed alongside and required to play certain games.",
|
||||
icon: ArchiveBoxIcon,
|
||||
component: ImportRedist,
|
||||
import: importRedist as (v: unknown) => void,
|
||||
import: importRedist as (v: unknown, k: unknown) => void,
|
||||
},
|
||||
});
|
||||
|
||||
@ -303,12 +303,12 @@ async function importGame_wrapper(
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
importError.value =
|
||||
(error as FetchError)?.statusMessage || t("errors.unknown");
|
||||
(error as FetchError)?.message || t("errors.unknown");
|
||||
}
|
||||
importLoading.value = false;
|
||||
}
|
||||
|
||||
async function importRedist(data: object) {
|
||||
async function importRedist(data: object, platform: object | undefined) {
|
||||
importLoading.value = true;
|
||||
importError.value = undefined;
|
||||
try {
|
||||
@ -316,7 +316,19 @@ async function importRedist(data: object) {
|
||||
|
||||
const formData = new FormData();
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
formData.append(key, value);
|
||||
formData.append(
|
||||
key,
|
||||
typeof value === "object" ? JSON.stringify(value) : value,
|
||||
);
|
||||
}
|
||||
|
||||
if (platform) {
|
||||
for (const [key, value] of Object.entries(platform)) {
|
||||
formData.append(
|
||||
`platform.${key}`,
|
||||
typeof value === "object" ? JSON.stringify(value) : value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
formData.append("library", option.library.id);
|
||||
@ -335,7 +347,7 @@ async function importRedist(data: object) {
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
importError.value =
|
||||
(error as FetchError)?.statusMessage || t("errors.unknown");
|
||||
(error as FetchError)?.message || t("errors.unknown");
|
||||
}
|
||||
importLoading.value = false;
|
||||
}
|
||||
|
||||
@ -412,7 +412,7 @@ function performActionSource_wrapper() {
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e instanceof FetchError) {
|
||||
modalError.value = e.statusMessage ?? e.message;
|
||||
modalError.value = e.message ?? e.message;
|
||||
} else {
|
||||
modalError.value = e as string;
|
||||
}
|
||||
@ -449,8 +449,8 @@ async function deleteSource(index: number) {
|
||||
{
|
||||
title: t("errors.library.source.delete.title"),
|
||||
description: t("errors.library.source.delete.desc", [
|
||||
// @ts-expect-error attempt to display statusMessage on error
|
||||
e?.statusMessage ?? t("errors.unknown"),
|
||||
// @ts-expect-error attempt to display message on error
|
||||
e?.message ?? t("errors.unknown"),
|
||||
]),
|
||||
},
|
||||
(_, c) => c(),
|
||||
|
||||
@ -96,7 +96,7 @@ async function saveSettings() {
|
||||
title: `Failed to save settings.`,
|
||||
description:
|
||||
e instanceof FetchError
|
||||
? (e.statusMessage ?? e.message)
|
||||
? (e.message)
|
||||
: (e as string).toString(),
|
||||
},
|
||||
(_, c) => c(),
|
||||
|
||||
@ -184,7 +184,7 @@ if (route.query.payload) {
|
||||
} catch {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Failed to parse the token create payload.",
|
||||
message: "Failed to parse the token create payload.",
|
||||
fatal: true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -502,7 +502,7 @@ function invite_wrapper() {
|
||||
invitations.value.push(invitation);
|
||||
})
|
||||
.catch((response) => {
|
||||
const message = response.statusMessage || t("errors.unknown");
|
||||
const message = response.message || t("errors.unknown");
|
||||
error.value = message;
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@ -203,7 +203,7 @@ const invitationId = route.query.id?.toString();
|
||||
if (!invitationId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: t("errors.inviteRequired"),
|
||||
message: t("errors.inviteRequired"),
|
||||
});
|
||||
|
||||
const invitation = await $dropFetch(
|
||||
@ -271,7 +271,7 @@ function register_wrapper() {
|
||||
router.push("/auth/signin");
|
||||
})
|
||||
.catch((response) => {
|
||||
const message = response.statusMessage || t("errors.unknown");
|
||||
const message = response.message || t("errors.unknown");
|
||||
error.value = message;
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@ -192,7 +192,7 @@ async function authorize() {
|
||||
}
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: "Unknown client auth mode: " + clientData.mode,
|
||||
message: "Unknown client auth mode: " + clientData.mode,
|
||||
fatal: true,
|
||||
});
|
||||
}
|
||||
@ -202,7 +202,7 @@ async function authorize_wrapper() {
|
||||
await authorize();
|
||||
} catch (e) {
|
||||
const errorMessage =
|
||||
(e as FetchError)?.statusMessage || "An unknown error occurred.";
|
||||
(e as FetchError)?.message || "An unknown error occurred.";
|
||||
error.value = errorMessage;
|
||||
} finally {
|
||||
completed.value = true;
|
||||
|
||||
@ -125,7 +125,7 @@ async function complete(code: string) {
|
||||
} catch (e) {
|
||||
if (e instanceof FetchError) {
|
||||
error.value =
|
||||
e.statusMessage ?? e.message ?? "An unknown error occurred.";
|
||||
e.message ?? "An unknown error occurred.";
|
||||
} else {
|
||||
error.value = (e as string)?.toString();
|
||||
}
|
||||
|
||||
@ -44,7 +44,8 @@ const collection = computed(() =>
|
||||
if (collection.value === undefined) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: t("library.collection.notFound"),
|
||||
message: t("library.collection.notFound"),
|
||||
fatal: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ const article = computed(() =>
|
||||
if (!article.value)
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: t("news.notFound"),
|
||||
message: t("news.notFound"),
|
||||
fatal: true,
|
||||
});
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ const token = route.query.token;
|
||||
if (!token)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No token.",
|
||||
message: "No token.",
|
||||
fatal: true,
|
||||
});
|
||||
const bearerToken = `Bearer ${token}`;
|
||||
@ -170,7 +170,7 @@ const allowed = await $dropFetch("/api/v1/admin", {
|
||||
if (!allowed)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid setup token. Please check the URL you opened.",
|
||||
message: "Invalid setup token. Please check the URL you opened.",
|
||||
fatal: true,
|
||||
});
|
||||
|
||||
|
||||
@ -73,15 +73,21 @@
|
||||
<td
|
||||
class="whitespace-nowrap inline-flex gap-x-4 px-3 py-4 text-sm text-zinc-400"
|
||||
>
|
||||
<component
|
||||
:is="PLATFORM_ICONS[platform]"
|
||||
<div
|
||||
v-for="platform in platforms"
|
||||
:key="platform"
|
||||
class="text-blue-600 w-6 h-6"
|
||||
/>
|
||||
:key="typeof platform === 'string' ? platform : platform.id"
|
||||
>
|
||||
<component
|
||||
:is="PLATFORM_ICONS[platform]"
|
||||
v-if="typeof platform === 'string'"
|
||||
class="text-blue-600 w-6 h-6"
|
||||
/>
|
||||
<div v-else class="text-blue-600 w-6 h-6" v-html="platform.iconSvg" />
|
||||
</div>
|
||||
|
||||
<span
|
||||
v-if="platforms.length == 0"
|
||||
class="font-semibold text-blue-600"
|
||||
class="font-display uppercase font-bold text-zinc-700"
|
||||
>{{ $t("store.commingSoon") }}</span
|
||||
>
|
||||
</td>
|
||||
@ -278,8 +284,9 @@ const descriptionHTML = micromark(game.mDescription);
|
||||
|
||||
const showReadMore = previewHTML != descriptionHTML;
|
||||
const platforms = game.versions
|
||||
.map((e) => e.platform)
|
||||
.map((e) => e.platform ?? e.userPlatform)
|
||||
.flat()
|
||||
.filter((e) => e !== null)
|
||||
.filter((e, i, u) => u.indexOf(e) === i);
|
||||
|
||||
// const rating = Math.round(game.mReviewRating * 5);
|
||||
|
||||
Reference in New Issue
Block a user