Files
mini-programs/src/container/listContainer/index.tsx
juguohong d92419f3c5 列表
2025-08-30 18:20:50 +08:00

53 lines
1.2 KiB
TypeScript

import { View } from "@tarojs/components";
import ListCard from "@/components/ListCard";
import ListLoadError from "@/components/ListLoadError";
import ListCardSkeleton from "@/components/ListCardSkeleton";
// import { useGlobalState } from "@/store/global";
const ListContainer = (props) => {
const { loading, data = [], error, reload } = props;
// const { statusNavbarHeightInfo } = useGlobalState() || {};
// const { totalHeight } = statusNavbarHeightInfo;
const renderList = () => {
if (loading && data.length > 0) {
return (
<>
{new Array(10).fill(0).map(() => {
return <ListCardSkeleton />;
})}
</>
);
}
if (error) {
return <ListLoadError reload={reload} />;
}
if (loading && data.length === 0) {
return null;
}
return (
<>
{data.map((match, index) => (
<ListCard key={match.id || index} {...match} />
))}
</>
);
};
return (
<View
className="listContentWrapper"
// style={{
// minHeight: `calc(100vh - ${totalHeight}px)`,
// }}
>
{renderList()}
</View>
);
};
export default ListContainer;