import CatalogSkelton from '@/components/templates/card-skelton'; import breakpoints from '@/config/breakpoints'; import InfiniteScroller from '@/pages/_components/infinite-scroller'; import { useScrollerContext } from '@/pages/_components/infinite-scroller/use-scroller-context'; import { useIntl } from '@umijs/max'; import { Col, FloatButton, Row, Spin } from 'antd'; import _ from 'lodash'; import ResizeObserver from 'rc-resize-observer'; import React, { useCallback } from 'react'; import styled from 'styled-components'; import { CatalogItem as CatalogItemType } from '../config/types'; import CatalogItem from './catalog-item'; const SpinWrapper = styled.div` width: 100%; position: absolute; display: flex; align-items: center; justify-content: center; top: 0; left: 0; max-height: 400px; right: 0; `; interface CatalogListProps { dataList: any[]; loading: boolean; activeId: number; isFirst: boolean; onDeploy: (data: any) => void; } const ListSkeleton: React.FC<{ span: number; loading: boolean; isFirst: boolean; }> = ({ span, loading, isFirst }) => { return (
{loading && ( {isFirst && } )}
); }; const CatalogList: React.FC = (props) => { const intl = useIntl(); const { dataList, loading, activeId, isFirst, onDeploy } = props; const { total, current, loading: contextLoading, refresh, throttleDelay } = useScrollerContext(); const [span, setSpan] = React.useState(8); const getSpanByWidth = (width: number) => { if (width < breakpoints.md) return 24; if (width < breakpoints.lg) return 12; return 8; }; const handleResize = useCallback( _.throttle((size: { width: number; height: number }) => { setSpan(getSpanByWidth(size.width)); }, 100), [] ); return (
{dataList.map((item: CatalogItemType, index) => { return ( ); })}
); }; export default CatalogList;