UNPKG

1.11 kBJavaScriptView Raw
1import React from "react";
2import { Popover, Button } from "antd";
3import Download from "ynw/antd/Download";
4import { FilePptOutlined } from "@ant-design/icons";
5/**
6 * ----------------------------------------
7 * 显示多个文件下载
8 * @param {Array} - files - 文件路径列表
9 * @param {Boolean} - [showCount] - 是否显示数量
10 * ----------------------------------------
11 */
12export default function ShowMulFile({ files, showCount = false }) {
13 const values = files || [];
14 const len = values.length;
15
16 if (len < 1) return "--";
17
18 const Content = () => {
19 return (
20 <div>
21 {values.map(path => (
22 <div key={path}>
23 <Download src={path}>{path.replace(/^.+\//g, "")}</Download>
24 </div>
25 ))}
26 </div>
27 );
28 };
29 return (
30 <Popover title="文件下载" content={Content} trigger="click">
31 <Button type="link">
32 <FilePptOutlined style={{ fontSize: "16px" }} />
33 {showCount ? (
34 <span style={{ marginLeft: "5px" }}>{values.length}</span>
35 ) : (
36 ""
37 )}
38 </Button>
39 </Popover>
40 );
41}