// 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) => ( ))}
); }