fix file size limit
This commit is contained in:
@@ -1734,6 +1734,7 @@ export interface AppRelease {
|
||||
platform: AppReleasePlatform;
|
||||
version: string;
|
||||
versionCode: number;
|
||||
variant: string;
|
||||
fileName: string;
|
||||
storageKey: string;
|
||||
fileSize: string;
|
||||
@@ -1747,6 +1748,7 @@ export interface AppRelease {
|
||||
export interface AppUpdateCheckResponse {
|
||||
updateAvailable: boolean;
|
||||
latest?: AppRelease;
|
||||
variants?: AppRelease[];
|
||||
}
|
||||
|
||||
export async function fetchPublicAppReleases(platform?: AppReleasePlatform) {
|
||||
@@ -1768,9 +1770,11 @@ export async function checkAppUpdate(platform: AppReleasePlatform, versionCode:
|
||||
);
|
||||
}
|
||||
|
||||
export function buildAppReleaseDownloadUrl(platform: AppReleasePlatform, releaseId?: string) {
|
||||
export function buildAppReleaseDownloadUrl(platform: AppReleasePlatform, releaseId?: string, variant?: string) {
|
||||
const slug = platform.toLowerCase();
|
||||
return releaseId ? `/downloads/${slug}/${releaseId}` : `/downloads/${slug}`;
|
||||
if (releaseId) return `/downloads/${slug}/${releaseId}`;
|
||||
if (variant) return `/downloads/${slug}?variant=${encodeURIComponent(variant)}`;
|
||||
return `/downloads/${slug}`;
|
||||
}
|
||||
|
||||
export async function fetchAdminAppReleases(token: string, platform?: AppReleasePlatform) {
|
||||
@@ -1784,6 +1788,7 @@ export async function uploadAdminAppRelease(
|
||||
platform: AppReleasePlatform;
|
||||
version: string;
|
||||
versionCode: number;
|
||||
variant?: string;
|
||||
releaseNotes?: string;
|
||||
file: File;
|
||||
},
|
||||
@@ -1793,6 +1798,9 @@ export async function uploadAdminAppRelease(
|
||||
formData.append('platform', payload.platform);
|
||||
formData.append('version', payload.version.trim());
|
||||
formData.append('versionCode', String(payload.versionCode));
|
||||
if (payload.variant?.trim()) {
|
||||
formData.append('variant', payload.variant.trim());
|
||||
}
|
||||
if (payload.releaseNotes?.trim()) {
|
||||
formData.append('releaseNotes', payload.releaseNotes.trim());
|
||||
}
|
||||
|
||||
56
apps/frontend/lib/app-release-variants.ts
Normal file
56
apps/frontend/lib/app-release-variants.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
const FILENAME_VARIANT_RULES: Array<{ pattern: RegExp; variant: string }> = [
|
||||
{ pattern: /arm64[-_]?v8a/i, variant: 'arm64-v8a' },
|
||||
{ pattern: /armeabi[-_]?v7a/i, variant: 'armeabi-v7a' },
|
||||
{ pattern: /x86[-_]?64/i, variant: 'x86_64' },
|
||||
{ pattern: /(?<![a-z0-9])x86(?![a-z0-9])/i, variant: 'x86' },
|
||||
{ pattern: /universal/i, variant: 'universal' }
|
||||
];
|
||||
|
||||
const VARIANT_LABELS: Record<string, string> = {
|
||||
universal: 'Universal',
|
||||
'arm64-v8a': 'ARM64 (arm64-v8a)',
|
||||
'armeabi-v7a': 'ARMv7 (armeabi-v7a)',
|
||||
x86_64: 'x86_64',
|
||||
x86: 'x86'
|
||||
};
|
||||
|
||||
export function detectVariantFromFileName(fileName: string) {
|
||||
const baseName = fileName.trim().replace(/\.apk$/i, '');
|
||||
for (const rule of FILENAME_VARIANT_RULES) {
|
||||
if (rule.pattern.test(baseName)) {
|
||||
return rule.variant;
|
||||
}
|
||||
}
|
||||
const normalized = baseName
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '')
|
||||
.slice(0, 64);
|
||||
return normalized || 'universal';
|
||||
}
|
||||
|
||||
export function formatReleaseVariantLabel(variant: string) {
|
||||
return VARIANT_LABELS[variant] ?? variant;
|
||||
}
|
||||
|
||||
export function groupReleasesByVersion<T extends { version: string; versionCode: number }>(releases: T[]) {
|
||||
const groups = new Map<string, T[]>();
|
||||
for (const release of releases) {
|
||||
const key = `${release.versionCode}:${release.version}`;
|
||||
const list = groups.get(key) ?? [];
|
||||
list.push(release);
|
||||
groups.set(key, list);
|
||||
}
|
||||
return [...groups.entries()]
|
||||
.sort((left, right) => Number(right[0].split(':')[0]) - Number(left[0].split(':')[0]))
|
||||
.map(([key, items]) => ({
|
||||
key,
|
||||
version: items[0]?.version ?? '',
|
||||
versionCode: items[0]?.versionCode ?? 0,
|
||||
variants: [...items].sort((a, b) => {
|
||||
const left = 'variant' in a ? String((a as { variant?: string }).variant ?? '') : '';
|
||||
const right = 'variant' in b ? String((b as { variant?: string }).variant ?? '') : '';
|
||||
return left.localeCompare(right, 'ru');
|
||||
})
|
||||
}));
|
||||
}
|
||||
@@ -12,6 +12,7 @@ const PASSTHROUGH_HEADERS = [
|
||||
'content-disposition',
|
||||
'x-release-version',
|
||||
'x-release-version-code',
|
||||
'x-release-variant',
|
||||
'x-release-sha256',
|
||||
'cache-control'
|
||||
] as const;
|
||||
@@ -22,9 +23,10 @@ export async function proxyReleaseDownload(
|
||||
releaseId?: string
|
||||
) {
|
||||
const apiBase = resolveServerApiBase(request);
|
||||
const variant = request.nextUrl.searchParams.get('variant');
|
||||
const path = releaseId
|
||||
? `/releases/download/${platform}/${releaseId}`
|
||||
: `/releases/download/${platform}`;
|
||||
: `/releases/download/${platform}${variant ? `?variant=${encodeURIComponent(variant)}` : ''}`;
|
||||
|
||||
const upstream = await fetch(`${apiBase}${path}`, {
|
||||
method: 'GET',
|
||||
|
||||
Reference in New Issue
Block a user