/** @format */ import { FunctionComponent, useEffect, useState } from "react"; import { CheckCard, ProCard } from "@ant-design/pro-components"; import styles from "./index.module.less"; import { Avatar, Button, Card, Divider, Dropdown, Flex, FloatButton, Input, message, Modal, Select, Tooltip, } from "antd"; import ali from "@/assets/icons/aliyun.svg"; import bucket from "@/assets/icons/bucket.svg"; import tencent from "@/assets/icons/tencent.svg"; import { CloudUploadOutlined, CopyOutlined, DeleteOutlined, DownloadOutlined, EllipsisOutlined, EyeOutlined, LeftOutlined, QrcodeOutlined, RedoOutlined, ScissorOutlined, SearchOutlined, SnippetsOutlined, } from "@ant-design/icons"; import standard_dir from "@/assets/icons/standard_directory.svg"; import useStore from "@/utils/store/useStore.tsx"; import { observer } from "mobx-react"; import FileIcon from "@/constant/file-icon.ts"; import file_icon from "@/assets/icons/files/file.svg"; import FileUpload from "@/components/Main/File/components/FileUpload.tsx"; const dataList: any = [ { name: "demo01.java", isDir: false, path: "demo0.java", length: "346", createTime: "2024-06-26T08:22:13.244Z", }, { name: "测试.pdf", isDir: false, path: "测试.pdf", length: "346", createTime: "2024-06-26T08:22:13.244Z", }, { name: "test.jpg", isDir: false, path: "test.jpg", length: "2057535", createTime: "2024-06-27T02:27:05.472Z", }, { name: "test1.png", isDir: false, path: "test1.png", length: "1766511", createTime: "2024-06-29T10:28:03.224Z", }, { name: "schisandra", isDir: true, path: "schisandra/", }, { name: "测试文件夹", isDir: true, path: "测试文件夹/", }, ]; const fileList: any = [ { name: "test1.png", isDir: false, path: "test1.png", length: "1766511", createTime: "2024-06-29T10:28:03.224Z", }, { name: "schisandra", isDir: true, path: "schisandra/", }, ]; const File: FunctionComponent = () => { const store = useStore("file"); const [files, setFiles] = useState([]); const [loading, setLoading] = useState(true); const [open, setOpen] = useState(false); async function getFile() { setFiles(dataList); } function getFileExtension(filename: any): string { const dotIndex = filename.lastIndexOf("."); return dotIndex !== -1 ? filename.slice(dotIndex + 1) : ""; } useEffect(() => { getFile().then(); setTimeout(() => { setLoading(false); }, 2000); }, []); return ( <>
{ domEvent.stopPropagation(); message.info("menu click"); }, items: [ { label: "删除", key: "1", }, { label: "编辑", key: "2", }, ], }}> e.stopPropagation()} /> } /> { domEvent.stopPropagation(); message.info("menu click"); }, items: [ { label: "删除", key: "1", }, { label: "编辑", key: "2", }, ], }}> e.stopPropagation()} /> } />
{files.map((file: any, index: any) => { if (file.isDir) { return (
{ store.setFilePath(file.name); setFiles(fileList); }}> {file.name}
} className={styles.file_card} style={{ width: 100, height: 100, display: "flex", alignItems: "center", justifyContent: "center", }} />
); } else { return (
{file.name}
} className={styles.file_card} style={{ width: 100, height: 100, display: "flex", alignItems: "center", justifyContent: "center", }} />
); } })}
} onClick={() => setOpen(true)} /> 文件上传

} loading={loading} footer={false} open={open} width={"50%"} onCancel={() => setOpen(false)}>
); }; export default observer(File);