feat: add ApkList component

This commit is contained in:
2026-03-04 02:11:04 +08:00
parent 36b60687f0
commit 608d67c7fd

66
app/download/ApkList.tsx Normal file
View File

@@ -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<Apk[]>(
`/api/apks?project=${project}&version=${version}&commit=${commitId}`,
fetcher
);
if (isLoading) {
return (
<div className="text-center py-8 text-gray-500">
...
</div>
);
}
if (error) {
return (
<div className="text-center py-8 text-red-600">
</div>
);
}
if (!apks || apks.length === 0) {
return (
<div className="text-center py-8 text-gray-500">
APK
</div>
);
}
return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{apks.map((apk) => (
<ApkCard
key={apk.name}
name={apk.name}
commit={apk.commit}
size={apk.size}
modifiedAt={apk.modifiedAt}
downloadUrl={apk.downloadUrl}
highlightCommit={commitId}
/>
))}
</div>
);
}