global fix and add tauri app
This commit is contained in:
@@ -8,7 +8,7 @@ import { FormEvent, useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
import { ChevronLeft, KeyRound, Mail, Network, Phone, QrCode, ShieldCheck, ShieldQuestion, UserRound } from 'lucide-react';
|
||||
import { ChevronLeft, Download, KeyRound, Mail, Network, Phone, QrCode, ShieldCheck, ShieldQuestion, UserRound } from 'lucide-react';
|
||||
|
||||
import { QRCodeSVG } from 'qrcode.react';
|
||||
|
||||
@@ -1270,6 +1270,15 @@ export default function LoginPage() {
|
||||
|
||||
<ProjectTagline className="mt-9 text-center text-sm font-semibold" />
|
||||
|
||||
<a
|
||||
href="/download/android"
|
||||
download
|
||||
className="mx-auto mt-3 flex w-fit items-center gap-1 rounded-full px-3 py-1.5 text-xs font-medium text-[#b9bdc9] transition hover:bg-white/10 hover:text-white"
|
||||
>
|
||||
<Download className="h-3.5 w-3.5" />
|
||||
Скачать приложение
|
||||
</a>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
44
apps/frontend/app/download/android/route.ts
Normal file
44
apps/frontend/app/download/android/route.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { createReadStream, existsSync, statSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { Readable } from 'node:stream';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
const APK_CANDIDATES = [
|
||||
process.env.TAURI_ANDROID_APK_PATH,
|
||||
path.resolve(process.cwd(), 'public/downloads/lendry-id.apk'),
|
||||
path.resolve(process.cwd(), '../../tauri_app/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk'),
|
||||
path.resolve(process.cwd(), '../../tauri_app/src-tauri/gen/android/app/build/outputs/apk/universal/debug/app-universal-debug.apk'),
|
||||
path.resolve(process.cwd(), '../../tauri_app/src-tauri/gen/android/app/build/outputs/apk/arm64/release/app-arm64-release.apk'),
|
||||
path.resolve(process.cwd(), '../../tauri_app/src-tauri/gen/android/app/build/outputs/apk/arm64/debug/app-arm64-debug.apk')
|
||||
].filter((candidate): candidate is string => Boolean(candidate));
|
||||
|
||||
function resolveApkPath() {
|
||||
return APK_CANDIDATES.find((candidate) => existsSync(candidate) && statSync(candidate).isFile());
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
const apkPath = resolveApkPath();
|
||||
if (!apkPath) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
message:
|
||||
'APK ещё не собран. Соберите tauri_app для Android или укажите TAURI_ANDROID_APK_PATH/public/downloads/lendry-id.apk.'
|
||||
},
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
const stat = statSync(apkPath);
|
||||
const stream = Readable.toWeb(createReadStream(apkPath)) as ReadableStream;
|
||||
|
||||
return new Response(stream, {
|
||||
headers: {
|
||||
'Content-Type': 'application/vnd.android.package-archive',
|
||||
'Content-Length': String(stat.size),
|
||||
'Content-Disposition': 'attachment; filename="lendry-id.apk"',
|
||||
'Cache-Control': 'no-store'
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user