Files
ftdl/app/download/ApkList.tsx
tech 993ce520f0 fix: add 'use client' directive and fix prop mismatch
- Add 'use client' directive at top of ApkList.tsx to support useSWR hook
- Remove highlightCommit prop from ApkCard component call as it's not accepted by ApkCard interface

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 02:12:39 +08:00

68 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
// 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}
/>
))}
</div>
);
}