From 73cc567e1fa4b0904a8b209cec0020c9926faa8f Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Sun, 2 Aug 2026 18:45:08 +0200 Subject: [PATCH] binary assets for frontend --- apps/frontend/package-lock.json | 30 ------------ apps/frontend/src/i18n/locales/en.ts | 10 ++++ apps/frontend/src/i18n/locales/hu.ts | 10 ++++ .../src/lib/interfaces/software.interface.ts | 6 +++ .../src/page/catalog/CatalogShowPage.vue | 49 +++++++++++++++++++ 5 files changed, 75 insertions(+), 30 deletions(-) diff --git a/apps/frontend/package-lock.json b/apps/frontend/package-lock.json index db97213..e9ca5cb 100644 --- a/apps/frontend/package-lock.json +++ b/apps/frontend/package-lock.json @@ -891,9 +891,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -911,9 +908,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -931,9 +925,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -951,9 +942,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -971,9 +959,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -991,9 +976,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3810,9 +3792,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -3834,9 +3813,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -3858,9 +3834,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -3882,9 +3855,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ diff --git a/apps/frontend/src/i18n/locales/en.ts b/apps/frontend/src/i18n/locales/en.ts index 948eb3f..d68ec08 100644 --- a/apps/frontend/src/i18n/locales/en.ts +++ b/apps/frontend/src/i18n/locales/en.ts @@ -146,6 +146,16 @@ export default { play: '▶ Play', downloads: 'downloads', links: 'Links', + binariesTitle: 'Download for desktop', + binary: { + win_x86: 'Windows (32-bit)', + win_x64: 'Windows (64-bit)', + linux_x86: 'Linux (32-bit)', + linux_x64: 'Linux (64-bit)', + mac_x64: 'macOS (Intel)', + mac_arm64: 'macOS (Apple Silicon)', + mac_universal: 'macOS', + }, }, team: { title: 'Our Team', diff --git a/apps/frontend/src/i18n/locales/hu.ts b/apps/frontend/src/i18n/locales/hu.ts index 146098a..0e88e6b 100644 --- a/apps/frontend/src/i18n/locales/hu.ts +++ b/apps/frontend/src/i18n/locales/hu.ts @@ -146,6 +146,16 @@ export default { play: '▶ Játék', downloads: 'letöltés', links: 'Linkek', + binariesTitle: 'Letöltés asztali gépre', + binary: { + win_x86: 'Windows (32 bit)', + win_x64: 'Windows (64 bit)', + linux_x86: 'Linux (32 bit)', + linux_x64: 'Linux (64 bit)', + mac_x64: 'macOS (Intel)', + mac_arm64: 'macOS (Apple Silicon)', + mac_universal: 'macOS', + }, }, team: { title: 'Csapatunk', diff --git a/apps/frontend/src/lib/interfaces/software.interface.ts b/apps/frontend/src/lib/interfaces/software.interface.ts index aea65b7..0a2e4c5 100644 --- a/apps/frontend/src/lib/interfaces/software.interface.ts +++ b/apps/frontend/src/lib/interfaces/software.interface.ts @@ -1,9 +1,15 @@ +export interface ReleaseAsset { + kind: string + path: string +} + export interface Release { version: string htmlFolderPath?: string cartridgePath?: string sourcePath?: string docsFolderPath?: string + assets?: ReleaseAsset[] downloadCount?: number UpdatedAt: string } diff --git a/apps/frontend/src/page/catalog/CatalogShowPage.vue b/apps/frontend/src/page/catalog/CatalogShowPage.vue index eadcfae..34fa7d7 100644 --- a/apps/frontend/src/page/catalog/CatalogShowPage.vue +++ b/apps/frontend/src/page/catalog/CatalogShowPage.vue @@ -99,6 +99,21 @@ {{ t('catalogShow.docs') }} + +
+
{{ t('catalogShow.binariesTitle') }}
+ +
@@ -127,6 +142,7 @@ {{ t('catalogShow.download') }} {{ t('catalogShow.source') }} {{ t('catalogShow.docs') }} + 💾 {{ t('catalogShow.binary.' + asset.kind) }}
{{ formatDateTime(release.UpdatedAt) }} @@ -142,6 +158,7 @@
{{ t('catalogShow.play') }} {{ t('catalogShow.download') }} + 💾 {{ t('catalogShow.binary.' + asset.kind) }}
{{ formatDateTime(release.UpdatedAt) }} @@ -169,6 +186,7 @@ {{ t('catalogShow.download') }} {{ t('catalogShow.source') }} {{ t('catalogShow.docs') }} + 💾 {{ t('catalogShow.binary.' + asset.kind) }} @@ -247,6 +265,37 @@ const latestStable = computed(() => stableReleases.value[0] ?? null) const downloadUrl = (path: string) => `/api/download?path=${encodeURIComponent(path.replace('/file/', ''))}` +const BINARY_KINDS = ['win_x64', 'win_x86', 'linux_x64', 'linux_x86', 'mac_universal', 'mac_arm64', 'mac_x64'] + +// a látogató OS-éhez illő targetek, preferencia-sorrendben +function osPreferredKinds(): string[] { + const ua = navigator.userAgent + if (/Windows/i.test(ua)) { + return /WOW64|Win64|x64|amd64/i.test(ua) ? ['win_x64', 'win_x86'] : ['win_x86', 'win_x64'] + } + if (/Macintosh|Mac OS X/i.test(ua)) return ['mac_universal', 'mac_arm64', 'mac_x64'] + if (/Linux/i.test(ua)) return ['linux_x64', 'linux_x86'] + return [] +} + +const preferredKinds = osPreferredKinds() + +const kindRank = (kind: string) => { + const preferred = preferredKinds.indexOf(kind) + return preferred >= 0 ? preferred : preferredKinds.length + BINARY_KINDS.indexOf(kind) +} + +const binaryAssets = (release: Release) => + (release.assets ?? []) + .filter(a => BINARY_KINDS.includes(a.kind)) + .sort((a, b) => kindRank(a.kind) - kindRank(b.kind)) + +// a kiemelt gomb: a látogató OS-éhez legjobban illő elérhető bináris +const primaryBinaryKind = (release: Release) => { + const first = binaryAssets(release)[0] + return first && preferredKinds.includes(first.kind) ? first.kind : null +} + onMounted(async () => { try { await store.fetchAll()