From 608d67c7fd67560c808938bffabe86471d8a19a5 Mon Sep 17 00:00:00 2001 From: tech Date: Wed, 4 Mar 2026 02:11:04 +0800 Subject: [PATCH] feat: add ApkList component --- app/download/ApkList.tsx | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/download/ApkList.tsx diff --git a/app/download/ApkList.tsx b/app/download/ApkList.tsx new file mode 100644 index 0000000..475b527 --- /dev/null +++ b/app/download/ApkList.tsx @@ -0,0 +1,66 @@ +// app/download/ApkList.tsx +import useSWR from 'swr'; +import ApkCard from './ApkCard'; + +const fetcher = (url: string) => fetch(url).then((res) => res.json()); + +interface ApkListProps { + project: string; + version: string; + commitId: string; +} + +interface Apk { + name: string; + commit: string | null; + size: number; + modifiedAt: string; + downloadUrl: string; +} + +export default function ApkList({ project, version, commitId }: ApkListProps) { + const { data: apks, isLoading, error } = useSWR( + `/api/apks?project=${project}&version=${version}&commit=${commitId}`, + fetcher + ); + + if (isLoading) { + return ( +
+ 加载中... +
+ ); + } + + if (error) { + return ( +
+ 加载失败,请重试 +
+ ); + } + + if (!apks || apks.length === 0) { + return ( +
+ 未找到匹配的 APK 文件 +
+ ); + } + + return ( +
+ {apks.map((apk) => ( + + ))} +
+ ); +}