fix file size limit

This commit is contained in:
lendry
2026-07-07 17:36:01 +03:00
parent b90017aad0
commit f36a8d7456
12 changed files with 482 additions and 159 deletions

View File

@@ -11,6 +11,7 @@ import {
buildAppReleaseDownloadUrl,
fetchPublicAppReleases
} from '@/lib/api';
import { formatReleaseVariantLabel, groupReleasesByVersion } from '@/lib/app-release-variants';
function formatBytes(value: string) {
const size = Number(value);
@@ -49,15 +50,15 @@ export default function DownloadsPage() {
})();
}, []);
const latestRelease = useMemo(
() => releases.find((item) => item.platform === 'ANDROID') ?? null,
const groupedReleases = useMemo(
() => groupReleasesByVersion(releases.filter((item) => item.platform === 'ANDROID')),
[releases]
);
const androidHistory = useMemo(
() => releases.filter((item) => item.platform === 'ANDROID'),
[releases]
);
const latestGroup = groupedReleases[0] ?? null;
const latestVariants = latestGroup?.variants ?? [];
const preferredLatest =
latestVariants.find((item) => item.variant === 'universal') ?? latestVariants[0] ?? null;
return (
<main className="min-h-screen bg-[linear-gradient(180deg,#f7f9fc_0%,#ffffff_42%,#f4f7fb_100%)]">
@@ -81,8 +82,8 @@ export default function DownloadsPage() {
Скачайте приложение
</h1>
<p className="mt-4 max-w-2xl text-base leading-relaxed text-[#667085] sm:text-lg">
Актуальная версия для Android. Каждый релиз подписан SHA-256 мобильное приложение может
автоматически проверять обновления по коду версии.
Актуальная версия для Android. Доступны разные сборки: universal, arm64-v8a и другие.
Каждый файл подписан SHA-256.
</p>
</div>
</section>
@@ -96,7 +97,7 @@ export default function DownloadsPage() {
</div>
<div>
<h2 className="text-2xl font-semibold">Android</h2>
<p className="mt-1 text-sm text-white/85">Скачайте APK для телефона или планшета</p>
<p className="mt-1 text-sm text-white/85">Выберите подходящую сборку APK</p>
</div>
</div>
</div>
@@ -104,37 +105,64 @@ export default function DownloadsPage() {
<div className="space-y-5 px-6 py-6">
{loading ? (
<p className="text-sm text-[#667085]">Проверяем доступные версии...</p>
) : latestRelease ? (
) : latestGroup && preferredLatest ? (
<>
<div>
<p className="text-sm text-[#667085]">Последняя версия</p>
<div className="mt-2 flex flex-wrap items-center gap-2">
<span className="text-2xl font-semibold text-[#1f2430]">v{latestRelease.version}</span>
<span className="text-2xl font-semibold text-[#1f2430]">v{latestGroup.version}</span>
<span className="rounded-full bg-[#eef4ff] px-2.5 py-1 text-xs font-medium text-[#3390ec]">
build {latestRelease.versionCode}
build {latestGroup.versionCode}
</span>
{latestVariants.length > 1 ? (
<span className="rounded-full bg-[#f4f5f8] px-2.5 py-1 text-xs font-medium text-[#667085]">
{latestVariants.length} сборки
</span>
) : null}
</div>
<p className="mt-2 text-sm text-[#667085]">
{formatBytes(latestRelease.fileSize)} · {formatDate(latestRelease.createdAt)}
{formatDate(preferredLatest.createdAt)}
</p>
</div>
{latestRelease.releaseNotes ? (
{preferredLatest.releaseNotes ? (
<p className="rounded-2xl bg-[#f8f9fb] px-4 py-3 text-sm leading-relaxed text-[#1f2430]">
{latestRelease.releaseNotes}
{preferredLatest.releaseNotes}
</p>
) : null}
<div className="grid gap-3 sm:grid-cols-2">
{latestVariants.map((release) => (
<div
key={release.id}
className="flex flex-col justify-between rounded-2xl border border-[#eceef4] bg-[#f8f9fb] p-4"
>
<div>
<p className="font-medium text-[#1f2430]">{formatReleaseVariantLabel(release.variant)}</p>
<p className="mt-1 text-xs text-[#667085]">
{formatBytes(release.fileSize)} · {release.fileName}
</p>
</div>
<Button className="mt-4 rounded-xl" asChild>
<a href={buildAppReleaseDownloadUrl('ANDROID', release.id)}>
<Download className="mr-2 h-4 w-4" />
Скачать
</a>
</Button>
</div>
))}
</div>
<div className="flex flex-col gap-3 sm:flex-row">
<Button className="flex-1 rounded-xl" asChild>
<a href="/downloads/android">
<a href={buildAppReleaseDownloadUrl('ANDROID', preferredLatest.id)}>
<Download className="mr-2 h-4 w-4" />
Скачать последнюю
Скачать рекомендуемую
</a>
</Button>
<Button variant="outline" className="flex-1 rounded-xl" asChild>
<a href={buildAppReleaseDownloadUrl('ANDROID', latestRelease.id)}>
Прямая ссылка
<a href={buildAppReleaseDownloadUrl('ANDROID', undefined, 'universal')}>
Universal по ссылке
<ArrowRight className="ml-2 h-4 w-4" />
</a>
</Button>
@@ -149,32 +177,38 @@ export default function DownloadsPage() {
<section className="mt-10 rounded-[24px] border border-[#eceef4] bg-white p-6 shadow-sm">
<h3 className="text-xl font-semibold">История версий</h3>
<div className="mt-4 space-y-3">
<div className="mt-4 space-y-4">
{loading ? (
<p className="text-sm text-[#667085]">Загружаем список версий...</p>
) : androidHistory.length ? (
androidHistory.map((release, index) => (
<div
key={release.id}
className="flex flex-wrap items-center justify-between gap-3 rounded-2xl bg-[#f8f9fb] px-4 py-3"
>
<div>
<div className="flex items-center gap-2">
<span className="font-medium text-[#1f2430]">v{release.version}</span>
<span className="text-xs text-[#667085]">build {release.versionCode}</span>
{index === 0 ? (
<span className="rounded-full bg-[#e8f8ee] px-2 py-0.5 text-[11px] font-medium text-[#1a7f37]">
Актуальная
</span>
) : null}
</div>
<p className="mt-1 text-xs text-[#667085]">
{formatDate(release.createdAt)} · {formatBytes(release.fileSize)}
</p>
) : groupedReleases.length ? (
groupedReleases.map((group, groupIndex) => (
<div key={group.key} className="rounded-2xl bg-[#f8f9fb] px-4 py-4">
<div className="mb-3 flex flex-wrap items-center gap-2">
<span className="font-medium text-[#1f2430]">v{group.version}</span>
<span className="text-xs text-[#667085]">build {group.versionCode}</span>
{groupIndex === 0 ? (
<span className="rounded-full bg-[#e8f8ee] px-2 py-0.5 text-[11px] font-medium text-[#1a7f37]">
Актуальная
</span>
) : null}
</div>
<div className="space-y-2">
{group.variants.map((release) => (
<div key={release.id} className="flex flex-wrap items-center justify-between gap-3 rounded-xl bg-white px-3 py-2">
<div>
<p className="text-sm font-medium text-[#1f2430]">
{formatReleaseVariantLabel(release.variant)}
</p>
<p className="text-xs text-[#667085]">
{formatDate(release.createdAt)} · {formatBytes(release.fileSize)}
</p>
</div>
<Button variant="outline" size="sm" className="rounded-xl" asChild>
<a href={buildAppReleaseDownloadUrl('ANDROID', release.id)}>Скачать</a>
</Button>
</div>
))}
</div>
<Button variant="outline" size="sm" className="rounded-xl" asChild>
<a href={buildAppReleaseDownloadUrl('ANDROID', release.id)}>Скачать</a>
</Button>
</div>
))
) : (
@@ -193,8 +227,9 @@ export default function DownloadsPage() {
<p className="mt-2 text-sm leading-relaxed text-[#667085]">
Мобильный клиент может запрашивать{' '}
<code className="rounded bg-[#f4f5f8] px-1.5 py-0.5">GET /idp-api/releases/check?platform=ANDROID&amp;versionCode=...</code>{' '}
и сравнивать SHA-256 перед установкой. Постоянная ссылка на последнюю версию:
<span className="mt-2 block font-medium text-[#1f2430]">/downloads/android</span>
и получать список всех сборок последней версии в поле <code className="rounded bg-[#f4f5f8] px-1.5 py-0.5">variants</code>.
Для конкретной архитектуры используйте{' '}
<code className="rounded bg-[#f4f5f8] px-1.5 py-0.5">/downloads/android?variant=arm64-v8a</code>.
</p>
</div>
</div>