Skip to content

Commit

Permalink
fix: 🐛 【Default Theme】已经没有数据了,不应该继续请求接口
Browse files Browse the repository at this point in the history
Closes: #94
  • Loading branch information
meetqy committed Mar 6, 2023
1 parent 8560c09 commit dbdd523
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/JustifyLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const JustifyLayout = ({ infiniteScroll, header }: Props) => {
const { token } = theme.useToken();
const activeImage = useMemo(() => rightBasic.image, [rightBasic]);
const { data, loadMore, loadingMore, noMore } = infiniteScroll;
const images = useMemo(() => data.list, [data.list]);
const images = useMemo(() => data.list, [data]);
const size = useSize(() => document.body);
const [open, setOpen] = useState(false);

Expand All @@ -65,6 +65,7 @@ const JustifyLayout = ({ infiniteScroll, header }: Props) => {
useEffect(() => {
if (!size || !size.width) return;
const clientWidth = size.width;
console.log(images);
setLayoutPos(
justifyLayout([...images], {
containerWidth:
Expand Down
5 changes: 3 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function getLoadMoreList(params: Params): Promise<Result> {
where: {
AND: [
handleSize({ size: body.size }),
body.tags
!_.isEmpty(body.tags)
? { tags: { some: { id: { in: body.tags } } } }
: undefined,
// 注释
Expand Down Expand Up @@ -85,6 +85,7 @@ const Page = () => {
{
target: LayoutContentRef.current,
threshold: 300,
manual: false,
isNoMore: (data) => {
if (!data) return false;
const { params, count } = data;
Expand All @@ -107,7 +108,7 @@ const Page = () => {
if (_.isEqual(params.body, searchParams)) return;

params.body = searchParams;
infiniteScroll.reload();
setTimeout(() => infiniteScroll.reload());
}, [searchParams, params, infiniteScroll]);

if (!infiniteScroll.data) return null;
Expand Down

0 comments on commit dbdd523

Please sign in to comment.