feat: import of custom platforms & file extensions

This commit is contained in:
DecDuck
2025-09-06 18:29:04 +10:00
parent 7266d0485b
commit fcfc30e5df
36 changed files with 13182 additions and 271 deletions

View File

@ -438,7 +438,11 @@
/>
</div>
<PlatformSelector v-model="versionSettings.platform" class="max-w-lg">
<PlatformSelector
v-model="versionSettings.platform"
class="max-w-lg"
:platforms="allPlatforms"
>
{{ $t("library.admin.import.version.platform") }}
</PlatformSelector>
<SwitchGroup as="div" class="flex items-center justify-between max-w-lg">
@ -636,6 +640,10 @@ const gameId = route.params.id.toString();
const versions = await $dropFetch(
`/api/v1/admin/import/version?id=${encodeURIComponent(gameId)}`,
);
const userPlatforms = await $dropFetch(
"/api/v1/admin/import/version/platforms",
);
const allPlatforms = renderPlatforms(userPlatforms);
const currentlySelectedVersion = ref(-1);
const versionSettings = ref<Partial<typeof ImportVersion.infer>>({
id: gameId,
@ -643,7 +651,8 @@ const versionSettings = ref<Partial<typeof ImportVersion.infer>>({
});
const versionGuesses =
ref<Array<SerializeObject<{ platform: Platform; filename: string }>>>();
ref<Array<SerializeObject<{ platform: string; filename: string }>>>();
const launchProcessQuery = ref("");
const setupProcessQuery = ref("");
@ -698,15 +707,12 @@ async function updateCurrentlySelectedVersion(value: number) {
if (currentlySelectedVersion.value == value) return;
currentlySelectedVersion.value = value;
const version = versions[currentlySelectedVersion.value];
const results = await $dropFetch(
const options = await $dropFetch(
`/api/v1/admin/import/version/preload?id=${encodeURIComponent(
gameId,
)}&version=${encodeURIComponent(version)}`,
);
versionGuesses.value = results.map((e) => ({
...e,
platform: e.platform as Platform,
}));
versionGuesses.value = options;
versionSettings.value.name = version;
}

View File

@ -198,8 +198,8 @@
>{{ metadata.title }}
<span class="ml-2 font-mono text-zinc-500 text-xs">{{
source
}}</span></RadioGroupLabel
>
}}</span>
</RadioGroupLabel>
<RadioGroupDescription
as="span"
class="text-zinc-400 text-xs"
@ -405,18 +405,21 @@ function performActionSource_wrapper() {
modalError.value = undefined;
modalLoading.value = true;
performActionSource()
.then(() => {
actionSourceOpen.value = false;
sourceConfig.value = {};
sourceName.value = "";
})
.catch((e) => {
if (e instanceof FetchError) {
modalError.value = e.message ?? e.message;
} else {
modalError.value = e as string;
}
})
.then(
() => {
actionSourceOpen.value = false;
sourceConfig.value = {};
sourceName.value = "";
},
(e) => {
if (e instanceof FetchError) {
console.log(e.data.message);
modalError.value = e.message;
} else {
modalError.value = e as string;
}
},
)
.finally(() => {
modalLoading.value = false;
});

View File

@ -84,6 +84,7 @@
? undefined
: platform.iconSvg
"
class="size-8 text-blue-600"
/>
<span
v-if="platforms.length == 0"
@ -257,7 +258,7 @@ const gameId = route.params.id.toString();
const user = useUser();
const { game, rating } = await $dropFetch(`/api/v1/games/${gameId}`);
const { game, rating, platforms } = await $dropFetch(`/api/v1/games/${gameId}`);
// Preview description (first 30 lines)
const showPreview = ref(true);
@ -283,11 +284,6 @@ const previewHTML = micromark(previewDescription);
const descriptionHTML = micromark(game.mDescription);
const showReadMore = previewHTML != descriptionHTML;
const platforms = game.versions
.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);
const averageRating = Math.round((rating._avg.mReviewRating ?? 0) * 5);