fix and update

This commit is contained in:
lendry
2026-07-07 11:06:14 +03:00
parent f1821c2edc
commit 911e76f232
4 changed files with 131 additions and 221 deletions

View File

@@ -1,7 +1,7 @@
'use client'; 'use client';
import { useCallback, useEffect, useMemo, useState } from 'react'; import { useCallback, useEffect, useMemo, useState } from 'react';
import { Download, Loader2, Monitor, Smartphone, Trash2, Upload } from 'lucide-react'; import { Download, Loader2, Smartphone, Trash2, Upload } from 'lucide-react';
import { useAuth } from '@/components/id/auth-provider'; import { useAuth } from '@/components/id/auth-provider';
import { AdminShell } from '@/components/id/admin-shell'; import { AdminShell } from '@/components/id/admin-shell';
import { useToast } from '@/components/id/toast-provider'; import { useToast } from '@/components/id/toast-provider';
@@ -9,14 +9,15 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { import {
AppRelease, AppRelease,
AppReleasePlatform,
deleteAdminAppRelease, deleteAdminAppRelease,
fetchAdminAppReleases, fetchAdminAppReleases,
getApiErrorMessage, getApiErrorMessage,
updateAdminAppRelease, updateAdminAppRelease,
uploadAdminAppRelease uploadAdminAppRelease
} from '@/lib/api'; } from '@/lib/api';
import { cn } from '@/lib/utils';
const ANDROID_PLATFORM = 'ANDROID' as const;
const APK_ACCEPT = '.apk,application/vnd.android.package-archive';
function formatBytes(value: string) { function formatBytes(value: string) {
const size = Number(value); const size = Number(value);
@@ -41,18 +42,12 @@ function formatDate(value: string) {
}).format(new Date(value)); }).format(new Date(value));
} }
const platformMeta: Record<AppReleasePlatform, { label: string; icon: typeof Smartphone; accept: string }> = {
ANDROID: { label: 'Android', icon: Smartphone, accept: '.apk,application/vnd.android.package-archive' },
WINDOWS: { label: 'Windows', icon: Monitor, accept: '.exe,application/vnd.microsoft.portable-executable' }
};
export default function AdminReleasesPage() { export default function AdminReleasesPage() {
const { token, user } = useAuth(); const { token, user } = useAuth();
const { showToast } = useToast(); const { showToast } = useToast();
const [releases, setReleases] = useState<AppRelease[]>([]); const [releases, setReleases] = useState<AppRelease[]>([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [uploading, setUploading] = useState(false); const [uploading, setUploading] = useState(false);
const [platform, setPlatform] = useState<AppReleasePlatform>('ANDROID');
const [version, setVersion] = useState(''); const [version, setVersion] = useState('');
const [versionCode, setVersionCode] = useState(''); const [versionCode, setVersionCode] = useState('');
const [releaseNotes, setReleaseNotes] = useState(''); const [releaseNotes, setReleaseNotes] = useState('');
@@ -64,7 +59,7 @@ export default function AdminReleasesPage() {
if (!token || !canManage) return; if (!token || !canManage) return;
setLoading(true); setLoading(true);
try { try {
const response = await fetchAdminAppReleases(token); const response = await fetchAdminAppReleases(token, ANDROID_PLATFORM);
setReleases(response.releases ?? []); setReleases(response.releases ?? []);
} catch (error) { } catch (error) {
showToast(getApiErrorMessage(error, 'Не удалось загрузить релизы') ?? 'Ошибка'); showToast(getApiErrorMessage(error, 'Не удалось загрузить релизы') ?? 'Ошибка');
@@ -77,11 +72,10 @@ export default function AdminReleasesPage() {
void loadReleases(); void loadReleases();
}, [loadReleases]); }, [loadReleases]);
const grouped = useMemo(() => { const androidReleases = useMemo(
const android = releases.filter((item) => item.platform === 'ANDROID'); () => releases.filter((item) => item.platform === ANDROID_PLATFORM),
const windows = releases.filter((item) => item.platform === 'WINDOWS'); [releases]
return { android, windows }; );
}, [releases]);
async function handleUpload(event: React.FormEvent<HTMLFormElement>) { async function handleUpload(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault(); event.preventDefault();
@@ -98,7 +92,7 @@ export default function AdminReleasesPage() {
setUploading(true); setUploading(true);
try { try {
const created = await uploadAdminAppRelease(token, { const created = await uploadAdminAppRelease(token, {
platform, platform: ANDROID_PLATFORM,
version: version.trim(), version: version.trim(),
versionCode: parsedVersionCode, versionCode: parsedVersionCode,
releaseNotes: releaseNotes.trim() || undefined, releaseNotes: releaseNotes.trim() || undefined,
@@ -130,7 +124,7 @@ export default function AdminReleasesPage() {
async function removeRelease(release: AppRelease) { async function removeRelease(release: AppRelease) {
if (!token) return; if (!token) return;
if (!window.confirm(`Удалить версию ${release.version} (${platformMeta[release.platform].label})?`)) return; if (!window.confirm(`Удалить версию ${release.version} (Android)?`)) return;
try { try {
await deleteAdminAppRelease(token, release.id); await deleteAdminAppRelease(token, release.id);
setReleases((current) => current.filter((item) => item.id !== release.id)); setReleases((current) => current.filter((item) => item.id !== release.id));
@@ -151,14 +145,13 @@ export default function AdminReleasesPage() {
return ( return (
<div className="space-y-3"> <div className="space-y-3">
{items.map((release, index) => { {items.map((release, index) => {
const Icon = platformMeta[release.platform].icon;
const isLatest = index === 0 && release.isPublished; const isLatest = index === 0 && release.isPublished;
return ( return (
<div key={release.id} className="rounded-[20px] border border-[#eceef4] bg-white p-4 shadow-sm"> <div key={release.id} className="rounded-[20px] border border-[#eceef4] bg-white p-4 shadow-sm">
<div className="flex flex-wrap items-start justify-between gap-3"> <div className="flex flex-wrap items-start justify-between gap-3">
<div className="flex min-w-0 items-start gap-3"> <div className="flex min-w-0 items-start gap-3">
<div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[#f4f5f8]"> <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[#f4f5f8]">
<Icon className="h-5 w-5 text-[#3390ec]" /> <Smartphone className="h-5 w-5 text-[#3390ec]" />
</div> </div>
<div className="min-w-0"> <div className="min-w-0">
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
@@ -188,7 +181,7 @@ export default function AdminReleasesPage() {
</div> </div>
<div className="flex shrink-0 flex-wrap gap-2"> <div className="flex shrink-0 flex-wrap gap-2">
<Button variant="outline" size="sm" className="rounded-xl" asChild> <Button variant="outline" size="sm" className="rounded-xl" asChild>
<a href={`/downloads/${release.platform === 'ANDROID' ? 'android' : 'windows'}`} target="_blank" rel="noreferrer"> <a href="/downloads/android" target="_blank" rel="noreferrer">
<Download className="mr-2 h-4 w-4" /> <Download className="mr-2 h-4 w-4" />
Скачать Скачать
</a> </a>
@@ -221,8 +214,6 @@ export default function AdminReleasesPage() {
); );
} }
const PlatformIcon = platformMeta[platform].icon;
return ( return (
<AdminShell active="/admin/releases"> <AdminShell active="/admin/releases">
<div className="grid gap-8 xl:grid-cols-[380px_minmax(0,1fr)]"> <div className="grid gap-8 xl:grid-cols-[380px_minmax(0,1fr)]">
@@ -232,35 +223,12 @@ export default function AdminReleasesPage() {
<Upload className="h-6 w-6" /> <Upload className="h-6 w-6" />
</div> </div>
<div> <div>
<h2 className="text-xl font-semibold">Новая версия</h2> <h2 className="text-xl font-semibold">Новая версия Android</h2>
<p className="text-sm text-[#667085]">Загрузите APK или EXE с подписью SHA-256</p> <p className="text-sm text-[#667085]">Загрузите APK с подписью SHA-256</p>
</div> </div>
</div> </div>
<form className="space-y-4" onSubmit={(event) => void handleUpload(event)}> <form className="space-y-4" onSubmit={(event) => void handleUpload(event)}>
<div className="grid grid-cols-2 gap-2">
{(['ANDROID', 'WINDOWS'] as AppReleasePlatform[]).map((item) => {
const meta = platformMeta[item];
const Icon = meta.icon;
return (
<button
key={item}
type="button"
className={cn(
'flex items-center justify-center gap-2 rounded-2xl border px-3 py-3 text-sm font-medium transition',
platform === item
? 'border-[#3390ec] bg-[#eef4ff] text-[#1f2430]'
: 'border-[#eceef4] bg-[#f8f9fb] text-[#667085] hover:bg-[#f1f2f6]'
)}
onClick={() => setPlatform(item)}
>
<Icon className="h-4 w-4" />
{meta.label}
</button>
);
})}
</div>
<Input <Input
placeholder="Версия, например 1.2.0" placeholder="Версия, например 1.2.0"
value={version} value={version}
@@ -283,15 +251,13 @@ export default function AdminReleasesPage() {
/> />
<label className="flex cursor-pointer flex-col items-center justify-center rounded-[20px] border border-dashed border-[#c7d2fe] bg-[#f8faff] px-4 py-8 text-center transition hover:bg-[#eef4ff]"> <label className="flex cursor-pointer flex-col items-center justify-center rounded-[20px] border border-dashed border-[#c7d2fe] bg-[#f8faff] px-4 py-8 text-center transition hover:bg-[#eef4ff]">
<PlatformIcon className="mb-3 h-8 w-8 text-[#3390ec]" /> <Smartphone className="mb-3 h-8 w-8 text-[#3390ec]" />
<span className="text-sm font-medium text-[#1f2430]"> <span className="text-sm font-medium text-[#1f2430]">{file ? file.name : 'Выберите файл .apk'}</span>
{file ? file.name : `Выберите файл ${platform === 'ANDROID' ? '.apk' : '.exe'}`}
</span>
<span className="mt-1 text-xs text-[#667085]">До 350 МБ</span> <span className="mt-1 text-xs text-[#667085]">До 350 МБ</span>
<input <input
type="file" type="file"
className="hidden" className="hidden"
accept={platformMeta[platform].accept} accept={APK_ACCEPT}
onChange={(event) => setFile(event.target.files?.[0] ?? null)} onChange={(event) => setFile(event.target.files?.[0] ?? null)}
/> />
</label> </label>
@@ -303,16 +269,10 @@ export default function AdminReleasesPage() {
</form> </form>
</section> </section>
<div className="space-y-8">
<section> <section>
<h2 className="mb-4 text-xl font-semibold">Android</h2> <h2 className="mb-4 text-xl font-semibold">Версии Android</h2>
{renderReleaseList(grouped.android, 'Релизы Android пока не загружены')} {renderReleaseList(androidReleases, 'Релизы Android пока не загружены')}
</section> </section>
<section>
<h2 className="mb-4 text-xl font-semibold">Windows</h2>
{renderReleaseList(grouped.windows, 'Релизы Windows пока не загружены')}
</section>
</div>
</div> </div>
</AdminShell> </AdminShell>
); );

View File

@@ -2,13 +2,12 @@
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import Link from 'next/link'; import Link from 'next/link';
import { ArrowRight, Download, Monitor, ShieldCheck, Smartphone, Sparkles } from 'lucide-react'; import { ArrowRight, Download, ShieldCheck, Smartphone, Sparkles } from 'lucide-react';
import { BrandLogo } from '@/components/id/brand-logo'; import { BrandLogo } from '@/components/id/brand-logo';
import { usePublicSettings } from '@/components/id/public-settings-provider'; import { usePublicSettings } from '@/components/id/public-settings-provider';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { import {
AppRelease, AppRelease,
AppReleasePlatform,
buildAppReleaseDownloadUrl, buildAppReleaseDownloadUrl,
fetchPublicAppReleases fetchPublicAppReleases
} from '@/lib/api'; } from '@/lib/api';
@@ -34,32 +33,6 @@ function formatDate(value: string) {
}).format(new Date(value)); }).format(new Date(value));
} }
const platformCards: Array<{
platform: AppReleasePlatform;
slug: 'android' | 'windows';
title: string;
subtitle: string;
icon: typeof Smartphone;
gradient: string;
}> = [
{
platform: 'ANDROID',
slug: 'android',
title: 'Android',
subtitle: 'Скачайте APK для телефона или планшета',
icon: Smartphone,
gradient: 'from-[#34c759] to-[#0f9d58]'
},
{
platform: 'WINDOWS',
slug: 'windows',
title: 'Windows',
subtitle: 'Установщик для компьютера',
icon: Monitor,
gradient: 'from-[#3390ec] to-[#1d4ed8]'
}
];
export default function DownloadsPage() { export default function DownloadsPage() {
const { projectName } = usePublicSettings(); const { projectName } = usePublicSettings();
const [releases, setReleases] = useState<AppRelease[]>([]); const [releases, setReleases] = useState<AppRelease[]>([]);
@@ -68,7 +41,7 @@ export default function DownloadsPage() {
useEffect(() => { useEffect(() => {
void (async () => { void (async () => {
try { try {
const response = await fetchPublicAppReleases(); const response = await fetchPublicAppReleases('ANDROID');
setReleases(response.releases ?? []); setReleases(response.releases ?? []);
} finally { } finally {
setLoading(false); setLoading(false);
@@ -76,24 +49,19 @@ export default function DownloadsPage() {
})(); })();
}, []); }, []);
const latestByPlatform = useMemo(() => { const latestRelease = useMemo(
const map = new Map<AppReleasePlatform, AppRelease>(); () => releases.find((item) => item.platform === 'ANDROID') ?? null,
for (const release of releases) { [releases]
if (!map.has(release.platform)) { );
map.set(release.platform, release);
}
}
return map;
}, [releases]);
const historyByPlatform = useMemo(() => ({ const androidHistory = useMemo(
ANDROID: releases.filter((item) => item.platform === 'ANDROID'), () => releases.filter((item) => item.platform === 'ANDROID'),
WINDOWS: releases.filter((item) => item.platform === 'WINDOWS') [releases]
}), [releases]); );
return ( return (
<main className="min-h-screen bg-[linear-gradient(180deg,#f7f9fc_0%,#ffffff_42%,#f4f7fb_100%)]"> <main className="min-h-screen bg-[linear-gradient(180deg,#f7f9fc_0%,#ffffff_42%,#f4f7fb_100%)]">
<div className="mx-auto max-w-6xl px-4 py-10 sm:px-6 lg:py-14"> <div className="mx-auto max-w-4xl px-4 py-10 sm:px-6 lg:py-14">
<div className="mb-10 flex flex-wrap items-center justify-between gap-4"> <div className="mb-10 flex flex-wrap items-center justify-between gap-4">
<BrandLogo /> <BrandLogo />
<Button variant="outline" className="rounded-full" asChild> <Button variant="outline" className="rounded-full" asChild>
@@ -107,35 +75,28 @@ export default function DownloadsPage() {
<div className="relative max-w-3xl"> <div className="relative max-w-3xl">
<div className="mb-4 inline-flex items-center gap-2 rounded-full bg-[#eef4ff] px-3 py-1 text-sm font-medium text-[#3390ec]"> <div className="mb-4 inline-flex items-center gap-2 rounded-full bg-[#eef4ff] px-3 py-1 text-sm font-medium text-[#3390ec]">
<Sparkles className="h-4 w-4" /> <Sparkles className="h-4 w-4" />
Официальные сборки {projectName} Официальная сборка {projectName}
</div> </div>
<h1 className="text-4xl font-semibold tracking-tight text-[#1f2430] sm:text-5xl"> <h1 className="text-4xl font-semibold tracking-tight text-[#1f2430] sm:text-5xl">
Скачайте приложение Скачайте приложение
</h1> </h1>
<p className="mt-4 max-w-2xl text-base leading-relaxed text-[#667085] sm:text-lg"> <p className="mt-4 max-w-2xl text-base leading-relaxed text-[#667085] sm:text-lg">
Актуальные версии для Android и Windows. Каждый релиз подписан SHA-256 мобильное приложение может Актуальная версия для Android. Каждый релиз подписан SHA-256 мобильное приложение может
автоматически проверять обновления по коду версии. автоматически проверять обновления по коду версии.
</p> </p>
</div> </div>
</section> </section>
<section className="mt-8 grid gap-5 lg:grid-cols-2"> <section className="mt-8">
{platformCards.map((card) => { <div className="overflow-hidden rounded-[28px] border border-[#eceef4] bg-white shadow-[0_18px_50px_rgba(31,36,48,0.06)]">
const latest = latestByPlatform.get(card.platform); <div className="bg-gradient-to-br from-[#34c759] to-[#0f9d58] px-6 py-8 text-white">
const Icon = card.icon;
return (
<div
key={card.platform}
className="overflow-hidden rounded-[28px] border border-[#eceef4] bg-white shadow-[0_18px_50px_rgba(31,36,48,0.06)]"
>
<div className={`bg-gradient-to-br ${card.gradient} px-6 py-8 text-white`}>
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<div className="flex h-14 w-14 items-center justify-center rounded-2xl bg-white/15 backdrop-blur"> <div className="flex h-14 w-14 items-center justify-center rounded-2xl bg-white/15 backdrop-blur">
<Icon className="h-7 w-7" /> <Smartphone className="h-7 w-7" />
</div> </div>
<div> <div>
<h2 className="text-2xl font-semibold">{card.title}</h2> <h2 className="text-2xl font-semibold">Android</h2>
<p className="mt-1 text-sm text-white/85">{card.subtitle}</p> <p className="mt-1 text-sm text-white/85">Скачайте APK для телефона или планшета</p>
</div> </div>
</div> </div>
</div> </div>
@@ -143,36 +104,36 @@ export default function DownloadsPage() {
<div className="space-y-5 px-6 py-6"> <div className="space-y-5 px-6 py-6">
{loading ? ( {loading ? (
<p className="text-sm text-[#667085]">Проверяем доступные версии...</p> <p className="text-sm text-[#667085]">Проверяем доступные версии...</p>
) : latest ? ( ) : latestRelease ? (
<> <>
<div> <div>
<p className="text-sm text-[#667085]">Последняя версия</p> <p className="text-sm text-[#667085]">Последняя версия</p>
<div className="mt-2 flex flex-wrap items-center gap-2"> <div className="mt-2 flex flex-wrap items-center gap-2">
<span className="text-2xl font-semibold text-[#1f2430]">v{latest.version}</span> <span className="text-2xl font-semibold text-[#1f2430]">v{latestRelease.version}</span>
<span className="rounded-full bg-[#eef4ff] px-2.5 py-1 text-xs font-medium text-[#3390ec]"> <span className="rounded-full bg-[#eef4ff] px-2.5 py-1 text-xs font-medium text-[#3390ec]">
build {latest.versionCode} build {latestRelease.versionCode}
</span> </span>
</div> </div>
<p className="mt-2 text-sm text-[#667085]"> <p className="mt-2 text-sm text-[#667085]">
{formatBytes(latest.fileSize)} · {formatDate(latest.createdAt)} {formatBytes(latestRelease.fileSize)} · {formatDate(latestRelease.createdAt)}
</p> </p>
</div> </div>
{latest.releaseNotes ? ( {latestRelease.releaseNotes ? (
<p className="rounded-2xl bg-[#f8f9fb] px-4 py-3 text-sm leading-relaxed text-[#1f2430]"> <p className="rounded-2xl bg-[#f8f9fb] px-4 py-3 text-sm leading-relaxed text-[#1f2430]">
{latest.releaseNotes} {latestRelease.releaseNotes}
</p> </p>
) : null} ) : null}
<div className="flex flex-col gap-3 sm:flex-row"> <div className="flex flex-col gap-3 sm:flex-row">
<Button className="flex-1 rounded-xl" asChild> <Button className="flex-1 rounded-xl" asChild>
<a href={`/downloads/${card.slug}`}> <a href="/downloads/android">
<Download className="mr-2 h-4 w-4" /> <Download className="mr-2 h-4 w-4" />
Скачать последнюю Скачать последнюю
</a> </a>
</Button> </Button>
<Button variant="outline" className="flex-1 rounded-xl" asChild> <Button variant="outline" className="flex-1 rounded-xl" asChild>
<a href={buildAppReleaseDownloadUrl(card.platform, latest.id)}> <a href={buildAppReleaseDownloadUrl('ANDROID', latestRelease.id)}>
Прямая ссылка Прямая ссылка
<ArrowRight className="ml-2 h-4 w-4" /> <ArrowRight className="ml-2 h-4 w-4" />
</a> </a>
@@ -180,25 +141,19 @@ export default function DownloadsPage() {
</div> </div>
</> </>
) : ( ) : (
<p className="text-sm text-[#667085]">Сборка для этой платформы пока не опубликована.</p> <p className="text-sm text-[#667085]">Сборка для Android пока не опубликована.</p>
)} )}
</div> </div>
</div> </div>
);
})}
</section> </section>
<section className="mt-10 grid gap-6 lg:grid-cols-2"> <section className="mt-10 rounded-[24px] border border-[#eceef4] bg-white p-6 shadow-sm">
{platformCards.map((card) => { <h3 className="text-xl font-semibold">История версий</h3>
const history = historyByPlatform[card.platform];
return (
<div key={`history-${card.platform}`} className="rounded-[24px] border border-[#eceef4] bg-white p-6 shadow-sm">
<h3 className="text-xl font-semibold">История версий · {card.title}</h3>
<div className="mt-4 space-y-3"> <div className="mt-4 space-y-3">
{loading ? ( {loading ? (
<p className="text-sm text-[#667085]">Загружаем список версий...</p> <p className="text-sm text-[#667085]">Загружаем список версий...</p>
) : history.length ? ( ) : androidHistory.length ? (
history.map((release, index) => ( androidHistory.map((release, index) => (
<div <div
key={release.id} key={release.id}
className="flex flex-wrap items-center justify-between gap-3 rounded-2xl bg-[#f8f9fb] px-4 py-3" className="flex flex-wrap items-center justify-between gap-3 rounded-2xl bg-[#f8f9fb] px-4 py-3"
@@ -218,7 +173,7 @@ export default function DownloadsPage() {
</p> </p>
</div> </div>
<Button variant="outline" size="sm" className="rounded-xl" asChild> <Button variant="outline" size="sm" className="rounded-xl" asChild>
<a href={buildAppReleaseDownloadUrl(card.platform, release.id)}>Скачать</a> <a href={buildAppReleaseDownloadUrl('ANDROID', release.id)}>Скачать</a>
</Button> </Button>
</div> </div>
)) ))
@@ -226,9 +181,6 @@ export default function DownloadsPage() {
<p className="text-sm text-[#667085]">Версии пока не опубликованы.</p> <p className="text-sm text-[#667085]">Версии пока не опубликованы.</p>
)} )}
</div> </div>
</div>
);
})}
</section> </section>
<section className="mt-10 rounded-[24px] border border-[#eceef4] bg-white p-6 shadow-sm"> <section className="mt-10 rounded-[24px] border border-[#eceef4] bg-white p-6 shadow-sm">
@@ -241,9 +193,8 @@ export default function DownloadsPage() {
<p className="mt-2 text-sm leading-relaxed text-[#667085]"> <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>{' '} <code className="rounded bg-[#f4f5f8] px-1.5 py-0.5">GET /idp-api/releases/check?platform=ANDROID&amp;versionCode=...</code>{' '}
и сравнивать SHA-256 перед установкой. Постоянные ссылки на последнюю версию: и сравнивать SHA-256 перед установкой. Постоянная ссылка на последнюю версию:
<span className="mt-2 block font-medium text-[#1f2430]">/downloads/android</span> <span className="mt-2 block font-medium text-[#1f2430]">/downloads/android</span>
<span className="block font-medium text-[#1f2430]">/downloads/windows</span>
</p> </p>
</div> </div>
</div> </div>

View File

@@ -1,9 +1,8 @@
import type { NextRequest } from 'next/server'; import { NextRequest, NextResponse } from 'next/server';
import { proxyReleaseDownload } from '@/lib/proxy-release-download';
export const runtime = 'nodejs'; export const runtime = 'nodejs';
export async function GET(request: NextRequest, context: { params: Promise<{ releaseId: string }> }) { export async function GET(request: NextRequest) {
const { releaseId } = await context.params; const target = new URL('/downloads', request.nextUrl.origin);
return proxyReleaseDownload(request, 'windows', releaseId); return NextResponse.redirect(target, 302);
} }

View File

@@ -1,8 +1,8 @@
import type { NextRequest } from 'next/server'; import { NextRequest, NextResponse } from 'next/server';
import { proxyReleaseDownload } from '@/lib/proxy-release-download';
export const runtime = 'nodejs'; export const runtime = 'nodejs';
export async function GET(request: NextRequest) { export async function GET(request: NextRequest) {
return proxyReleaseDownload(request, 'windows'); const target = new URL('/downloads', request.nextUrl.origin);
return NextResponse.redirect(target, 302);
} }