feat: 🎸 优化了滚动加载
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Empty } from "@arco-design/web-react";
|
||||
import { Empty, Spin } from "@arco-design/web-react";
|
||||
import "./index.css";
|
||||
|
||||
const InfiniteScroll = ({
|
||||
loadMore,
|
||||
@@ -7,6 +8,7 @@ const InfiniteScroll = ({
|
||||
children,
|
||||
threshold = 50,
|
||||
className = "",
|
||||
empty = false,
|
||||
}) => {
|
||||
const containerRef = useRef(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -46,7 +48,17 @@ const InfiniteScroll = ({
|
||||
className={`infinite-scroll-container ${className}`}
|
||||
>
|
||||
{children}
|
||||
{!hasMore && !loading && <Empty description="没有更多了" />}
|
||||
|
||||
{!hasMore && empty && (
|
||||
<Empty description="暂无数据" className="empty-data" />
|
||||
)}
|
||||
{/* 滚动加载指示器 */}
|
||||
{loading && hasMore && (
|
||||
<div className="loading-container">
|
||||
<Spin size="small" />
|
||||
<span className="loading-text">加载中...</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user