boluo-app-main/src/components/list-placeholder/index.tsx
2025-03-31 22:34:22 +08:00

34 lines
831 B
TypeScript

import { List, Loading } from '@taroify/core';
import { ReactNode } from 'react';
import './index.less';
interface IPlaceholderProps {
hasMore: boolean;
loadingMore: boolean;
loadMoreError: boolean;
noMoreText: ReactNode;
loadMoreErrorText: ReactNode;
}
function ListPlaceholder(props: Partial<IPlaceholderProps>) {
const { hasMore, loadingMore, loadMoreError, noMoreText, loadMoreErrorText } = props;
let content: ReactNode = '';
if (loadingMore) {
content = <Loading>...</Loading>;
} else if (loadMoreError) {
content = loadMoreErrorText ?? '加载失败,请下拉刷新重试';
} else if (!hasMore) {
content = noMoreText ?? '没有更多了';
}
if (!content) {
return null;
}
return <List.Placeholder>{content}</List.Placeholder>;
}
export default ListPlaceholder;