import { Empty, Modal, Spin } from 'antd'; import React, { PropsWithChildren, useState } from 'react'; import styles from './index.less'; import Truly from '../../../../components/Truly'; import { useRequest } from 'ahooks'; import { getFileList } from '../service'; import classNames from 'classnames'; import Icon, { IconImg } from '../../../../components/Icon'; interface ImageListProps { picType: '1' | '2' | '9'; onSelect: (value?: string) => void; } const ImageList: React.FC> = (props) => { const { children, picType, onSelect } = props; const [open, setOpen] = useState(false); const { data: fileList, loading: getFileListLoading, run: getFileListRun, } = useRequest( async (picType) => { return getFileList({ type: '0', picType }); }, { manual: true, }, ); return ( <> {React.cloneElement(children as JSX.Element, { onClick: () => { setOpen(true); getFileListRun(picType); }, })} { setOpen(false); }} >
{(fileList || []).length > 0 ? (
{(fileList || []).map((item) => { return (
{ const file = item.isSvg === '1' ? item.fileContent : item.filePath; onSelect(file); setOpen(false); }} > } > svg
); })}
) : (
)}
); }; export default ImageList;