import { View } from '@tarojs/components'; import { ReactNode } from 'react'; import EmptyState from '../../EmptyState'; import ErrorState from '../../ErrorState'; import LoadingCard from '../../ui/LoadingCard'; import './index.scss'; interface CardListProps { items: T[]; renderItem: (item: T, index: number) => ReactNode; keyExtractor: (item: T) => string; loading?: boolean; error?: string | null; emptyText?: string; emptyAction?: { text: string; onPress: () => void }; gap?: 'sm' | 'md'; } function CardList({ items, renderItem, keyExtractor, loading = false, error = null, emptyText = '暂无数据', emptyAction, gap = 'md', }: CardListProps) { if (loading) { return ; } if (error) { return ( ); } if (items.length === 0) { return ( ); } return ( {items.map((item, index) => ( {renderItem(item, index)} ))} ); } export default CardList;