fix: remove platform

This commit is contained in:
DecDuck
2025-09-06 19:23:02 +10:00
parent bfd5c8e761
commit d84c70a05f
8 changed files with 42 additions and 35 deletions

View File

@ -1,15 +1,15 @@
<!-- eslint-disable vue/no-v-html -->
<template>
<component
:is="platformIcons[props.platform as Platform]"
v-if="platformIcons[props.platform as Platform]"
:is="platformIcons[props.platform as HardwarePlatform]"
v-if="platformIcons[props.platform as HardwarePlatform]"
/>
<div v-else-if="props.fallback" v-html="props.fallback" />
<DropLogo v-else />
</template>
<script setup lang="ts">
import { Platform } from "~/prisma/client/enums";
import { HardwarePlatform } from "~/prisma/client/enums";
import type { Component } from "vue";
import LinuxLogo from "./LinuxLogo.vue";
import WindowsLogo from "./WindowsLogo.vue";
@ -18,9 +18,9 @@ import DropLogo from "../DropLogo.vue";
const props = defineProps<{ platform: string; fallback?: string }>();
const platformIcons: { [key in Platform]: Component } = {
[Platform.Linux]: LinuxLogo,
[Platform.Windows]: WindowsLogo,
[Platform.macOS]: MacLogo,
const platformIcons: { [key in HardwarePlatform]: Component } = {
[HardwarePlatform.Linux]: LinuxLogo,
[HardwarePlatform.Windows]: WindowsLogo,
[HardwarePlatform.macOS]: MacLogo,
};
</script>

View File

@ -1,8 +0,0 @@
import { IconsLinuxLogo, IconsWindowsLogo, IconsMacLogo } from "#components";
import { Platform } from "~/prisma/client/enums";
export const PLATFORM_ICONS = {
[Platform.Linux]: IconsLinuxLogo,
[Platform.Windows]: IconsWindowsLogo,
[Platform.macOS]: IconsMacLogo,
};

View File

@ -1,4 +1,4 @@
import { Platform } from "~/prisma/client/enums";
import { HardwarePlatform } from "~/prisma/client/enums";
export type PlatformRenderable = {
name: string;
@ -10,7 +10,7 @@ export function renderPlatforms(
userPlatforms: { platformName: string; id: string; iconSvg: string }[],
): PlatformRenderable[] {
return [
...Object.values(Platform).map((e) => ({
...Object.values(HardwarePlatform).map((e) => ({
name: e,
param: e,
platformIcon: { key: e },

View File

@ -167,9 +167,10 @@
]"
>
{{ guess.filename }}
<component
:is="PLATFORM_ICONS[guess.platform as Platform]"
class="size-5"
<IconsPlatform
:platform="guess.platform.platformIcon.key"
:fallback="guess.platform.platformIcon.fallback"
class="size-5 flex-shrink-0 text-blue-600"
/>
</span>
@ -339,9 +340,10 @@
]"
>
{{ guess.filename }}
<component
:is="PLATFORM_ICONS[guess.platform as Platform]"
class="size-5"
<IconsPlatform
:platform="guess.platform.platformIcon.key"
:fallback="guess.platform.platformIcon.fallback"
class="size-5 flex-shrink-0 text-blue-600"
/>
</span>
@ -626,7 +628,6 @@ import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
import { PlusIcon, TrashIcon } from "@heroicons/vue/24/outline";
import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/vue/24/solid";
import type { SerializeObject } from "nitropack";
import type { Platform } from "~/prisma/client/enums";
import type { ImportVersion } from "~/server/api/v1/admin/import/version/index.post";
definePageMeta({
@ -651,7 +652,9 @@ const versionSettings = ref<Partial<typeof ImportVersion.infer>>({
});
const versionGuesses =
ref<Array<SerializeObject<{ platform: string; filename: string }>>>();
ref<
Array<SerializeObject<{ platform: PlatformRenderable; filename: string }>>
>();
const launchProcessQuery = ref("");
const setupProcessQuery = ref("");
@ -684,7 +687,8 @@ function autosetPlatform(value: string) {
(e) => e.filename === value,
);
if (guessIndex == -1) return;
versionSettings.value.platform = versionGuesses.value[guessIndex].platform;
versionSettings.value.platform =
versionGuesses.value[guessIndex].platform.param;
}
const umuIdEnabled = ref(false);
@ -712,7 +716,10 @@ async function updateCurrentlySelectedVersion(value: number) {
gameId,
)}&version=${encodeURIComponent(version)}`,
);
versionGuesses.value = options;
versionGuesses.value = options.map((e) => ({
...e,
platform: allPlatforms.find((v) => v.param === e.platform)!,
}));
versionSettings.value.name = version;
}

View File

@ -0,0 +1,8 @@
-- DropIndex
DROP INDEX "public"."GameTag_name_idx";
-- DropEnum
DROP TYPE "public"."Platform";
-- CreateIndex
CREATE INDEX "GameTag_name_idx" ON "public"."GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));

View File

@ -1,6 +1,6 @@
import { randomUUID } from "node:crypto";
import prisma from "../db/database";
import type { Platform } from "~/prisma/client/enums";
import type { HardwarePlatform } from "~/prisma/client/enums";
import { useCertificateAuthority } from "~/server/plugins/ca";
import type {
CapabilityConfiguration,
@ -16,7 +16,7 @@ export enum AuthMode {
export interface ClientMetadata {
name: string;
platform: Platform;
platform: HardwarePlatform;
capabilities: Partial<CapabilityConfiguration>;
mode: AuthMode;
}

View File

@ -1,4 +1,4 @@
import { Platform, type HardwarePlatform } from "~/prisma/client/enums";
import { HardwarePlatform } from "~/prisma/client/enums";
import prisma from "../db/database";
import type { PlatformLink } from "~/prisma/client/client";
@ -26,7 +26,7 @@ export async function convertIDToLink(
});
if (link) return link;
if (Platform[id as Platform]) {
if (HardwarePlatform[id as HardwarePlatform]) {
return await prisma.platformLink.create({
data: {
id,

View File

@ -1,14 +1,14 @@
import { Platform } from "~/prisma/client/enums";
import { HardwarePlatform } from "~/prisma/client/enums";
export function parsePlatform(platform: string) {
switch (platform.toLowerCase()) {
case "linux":
return Platform.Linux;
return HardwarePlatform.Linux;
case "windows":
return Platform.Windows;
return HardwarePlatform.Windows;
case "mac":
case "macos":
return Platform.macOS;
return HardwarePlatform.macOS;
}
return undefined;