import KFIcon from '@/components/KFIcon'; import { ResourceData, ResourceFileData, ResourceType, resourceConfig, } from '@/pages/Dataset/config'; import { downLoadZip } from '@/utils/downloadfile'; import tableCellRender, { TableCellValueType } from '@/utils/table'; import { Button, Flex, Table, TableProps } from 'antd'; import styles from './index.less'; type ResourceVersionProps = { resourceType: ResourceType; info: ResourceData; }; function ResourceVersion({ resourceType, info }: ResourceVersionProps) { const config = resourceConfig[resourceType]; const filePropKey = config.filePropKey as keyof ResourceData; const fileList = (info[filePropKey] ?? []) as ResourceFileData[]; fileList.forEach((item) => (item.update_time = info.update_time)); // 全部导出 const handleExport = async () => { const url = config.downloadAllAction; downLoadZip(url, { name: info.name, id: info.id, version: info.version, identifier: info.identifier, }); }; // 单个导出 const downloadAlone = async (record: ResourceFileData) => { const url = config.downloadSingleAction; downLoadZip(url, { url: record.url }); }; const columns: TableProps['columns'] = [ { title: '序号', dataIndex: 'index', key: 'index', width: 80, render: tableCellRender(false, TableCellValueType.Index), }, { title: '文件名称', dataIndex: 'file_name', key: 'file_name', render: tableCellRender(false, TableCellValueType.Link, { onClick: downloadAlone, }), }, { title: '文件大小', dataIndex: 'file_size', key: 'file_size', render: tableCellRender(), }, { title: '更新时间', dataIndex: 'update_time', key: 'update_time', render: tableCellRender(false, TableCellValueType.Date), }, { title: '操作', dataIndex: 'option', width: 160, key: 'option', render: (_: any, record: ResourceFileData) => [ , ], }, ]; return (
); } export default ResourceVersion;