@jzwd/vnd-design 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +259 -2
- package/dist/file-center/api/endpoints.d.ts +42 -0
- package/dist/file-center/api/endpoints.js +45 -0
- package/dist/file-center/api/error.d.ts +6 -0
- package/dist/file-center/api/error.js +34 -0
- package/dist/file-center/api/index.d.ts +64 -0
- package/dist/file-center/api/index.js +238 -0
- package/dist/file-center/api/request.d.ts +28 -0
- package/dist/file-center/api/request.js +170 -0
- package/dist/file-center/api/token.d.ts +10 -0
- package/dist/file-center/api/token.js +122 -0
- package/dist/file-center/components/FcFileList/index.d.ts +39 -0
- package/dist/file-center/components/FcFileList/index.js +804 -0
- package/dist/file-center/components/FcFileList/style.css +106 -0
- package/dist/file-center/components/FcImage/index.d.ts +30 -0
- package/dist/file-center/components/FcImage/index.js +144 -0
- package/dist/file-center/components/FcImage/style.css +14 -0
- package/dist/file-center/components/FcUpload/index.d.ts +5 -0
- package/dist/file-center/components/FcUpload/index.js +642 -0
- package/dist/file-center/components/FcUpload/interface.d.ts +65 -0
- package/dist/file-center/components/FcUpload/interface.js +1 -0
- package/dist/file-center/components/FcUpload/style.css +279 -0
- package/dist/file-center/context.d.ts +22 -0
- package/dist/file-center/context.js +22 -0
- package/dist/file-center/index.d.ts +26 -0
- package/dist/file-center/index.js +21 -0
- package/dist/file-center/types.d.ts +144 -0
- package/dist/file-center/types.js +1 -0
- package/dist/file-center/upload.d.ts +35 -0
- package/dist/file-center/upload.js +295 -0
- package/dist/file-center/utils/common.d.ts +10 -0
- package/dist/file-center/utils/common.js +165 -0
- package/dist/file-center/utils/compress.d.ts +18 -0
- package/dist/file-center/utils/compress.js +108 -0
- package/dist/file-center/utils/md5.d.ts +5 -0
- package/dist/file-center/utils/md5.js +41 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +15 -0
- package/dist/mobile/FcImage/index.d.ts +26 -0
- package/dist/mobile/FcImage/index.js +114 -0
- package/dist/mobile/FcImage/style.css +11 -0
- package/dist/mobile/FcUpload/index.d.ts +74 -0
- package/dist/mobile/FcUpload/index.js +539 -0
- package/dist/mobile/FcUpload/style.css +233 -0
- package/dist/mobile/index.d.ts +13 -0
- package/dist/mobile/index.js +9 -0
- package/package.json +70 -4
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
17
|
+
import { Button, Card, Checkbox, DatePicker, Empty, Image, Input, Modal, Pagination, Segmented, Select, Space, Spin, Table, Tag, Tooltip, Typography, message } from 'antd';
|
|
18
|
+
import { AppstoreOutlined, BarsOutlined, DeleteOutlined, DownloadOutlined, EyeOutlined, LinkOutlined, PaperClipOutlined, ReloadOutlined } from '@ant-design/icons';
|
|
19
|
+
import dayjs from 'dayjs';
|
|
20
|
+
import { resolveFcContext } from "../../context";
|
|
21
|
+
import { deleteFile, fetchFileList, fetchReferences, refreshFileSign } from "../../api";
|
|
22
|
+
import { copyText, downloadFile, formatFileSize, getFileCategory } from "../../utils/common";
|
|
23
|
+
import "./style.css";
|
|
24
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
+
/** 引用记录列表(删除二次确认弹窗内展示) */
|
|
27
|
+
function ReferenceList(_ref) {
|
|
28
|
+
var references = _ref.references;
|
|
29
|
+
if (!references.length) return null;
|
|
30
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
31
|
+
className: "bc-fc-filelist-refs",
|
|
32
|
+
children: [/*#__PURE__*/_jsxs(Typography.Paragraph, {
|
|
33
|
+
type: "warning",
|
|
34
|
+
children: ["\u8BE5\u6587\u4EF6\u88AB\u4EE5\u4E0B ", references.length, " \u6761\u4E1A\u52A1\u8BB0\u5F55\u5F15\u7528\uFF0C\u5220\u9664\u540E\u5C06\u65E0\u6CD5\u8BBF\u95EE\uFF1A"]
|
|
35
|
+
}), /*#__PURE__*/_jsx("ul", {
|
|
36
|
+
children: references.map(function (ref) {
|
|
37
|
+
var _ref$projectName;
|
|
38
|
+
return /*#__PURE__*/_jsxs("li", {
|
|
39
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
40
|
+
className: "bc-fc-filelist-refs-project",
|
|
41
|
+
children: (_ref$projectName = ref.projectName) !== null && _ref$projectName !== void 0 ? _ref$projectName : ref.projectId
|
|
42
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
43
|
+
className: "bc-fc-filelist-refs-biz",
|
|
44
|
+
children: [ref.bizType, " / ", ref.bizId]
|
|
45
|
+
}), ref.bizUrl && /*#__PURE__*/_jsxs("a", {
|
|
46
|
+
href: ref.bizUrl,
|
|
47
|
+
target: "_blank",
|
|
48
|
+
rel: "noopener noreferrer",
|
|
49
|
+
children: [/*#__PURE__*/_jsx(LinkOutlined, {}), " \u67E5\u770B\u4E1A\u52A1\u9875\u9762"]
|
|
50
|
+
})]
|
|
51
|
+
}, ref.id);
|
|
52
|
+
})
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 内置预览弹窗:图片灯箱、视频播放、PDF 内嵌、其他类型新窗口打开 */
|
|
58
|
+
function usePreviewModal() {
|
|
59
|
+
var _useState = useState(null),
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
+
previewFile = _useState2[0],
|
|
62
|
+
setPreviewFile = _useState2[1];
|
|
63
|
+
var node = previewFile ? /*#__PURE__*/_jsx(Modal, {
|
|
64
|
+
open: true,
|
|
65
|
+
title: previewFile.name,
|
|
66
|
+
footer: null,
|
|
67
|
+
width: 720,
|
|
68
|
+
onCancel: function onCancel() {
|
|
69
|
+
return setPreviewFile(null);
|
|
70
|
+
},
|
|
71
|
+
destroyOnClose: true,
|
|
72
|
+
children: function () {
|
|
73
|
+
var category = getFileCategory(previewFile.mime, previewFile.ext);
|
|
74
|
+
if (category === 'image') {
|
|
75
|
+
return /*#__PURE__*/_jsx(Image, {
|
|
76
|
+
src: previewFile.url,
|
|
77
|
+
style: {
|
|
78
|
+
width: '100%'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (category === 'video') {
|
|
83
|
+
return /*#__PURE__*/_jsx("video", {
|
|
84
|
+
src: previewFile.url,
|
|
85
|
+
controls: true,
|
|
86
|
+
style: {
|
|
87
|
+
width: '100%'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (category === 'pdf') {
|
|
92
|
+
return /*#__PURE__*/_jsx("iframe", {
|
|
93
|
+
src: previewFile.url,
|
|
94
|
+
title: previewFile.name,
|
|
95
|
+
style: {
|
|
96
|
+
width: '100%',
|
|
97
|
+
height: 480,
|
|
98
|
+
border: 'none'
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return /*#__PURE__*/_jsxs(Space, {
|
|
103
|
+
direction: "vertical",
|
|
104
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
105
|
+
children: "\u8BE5\u6587\u4EF6\u7C7B\u578B\u6682\u4E0D\u652F\u6301\u5728\u7EBF\u9884\u89C8\uFF0C\u8BF7\u4E0B\u8F7D\u540E\u67E5\u770B\u3002"
|
|
106
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
107
|
+
type: "primary",
|
|
108
|
+
icon: /*#__PURE__*/_jsx(DownloadOutlined, {}),
|
|
109
|
+
onClick: function onClick() {
|
|
110
|
+
return downloadFile(previewFile.url, previewFile.name);
|
|
111
|
+
},
|
|
112
|
+
children: "\u4E0B\u8F7D\u6587\u4EF6"
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
}()
|
|
116
|
+
}) : null;
|
|
117
|
+
return {
|
|
118
|
+
openPreview: setPreviewFile,
|
|
119
|
+
previewNode: node
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 文件中心文件列表组件(对应需求 3.2.3 核心页面)
|
|
125
|
+
*
|
|
126
|
+
* - 查询本项目文件(OPEN-7),支持名称模糊、业务标签、类型、时间范围筛选;
|
|
127
|
+
* - 表格 / 图片宫格两种视图切换;
|
|
128
|
+
* - 行操作:复制 URL、预览、下载、刷新签名(私有文件)、删除;
|
|
129
|
+
* - 删除时展示全部业务引用(OPEN-14),勾选确认后才能删除(OPEN-10)。
|
|
130
|
+
*
|
|
131
|
+
* ```tsx
|
|
132
|
+
* <FcFileList bizTypes={[{ label: '商品图', value: 'goodsImage' }]} />
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export function FcFileList(props) {
|
|
136
|
+
var _props$defaultView = props.defaultView,
|
|
137
|
+
defaultView = _props$defaultView === void 0 ? 'table' : _props$defaultView,
|
|
138
|
+
_props$showViewSwitch = props.showViewSwitch,
|
|
139
|
+
showViewSwitch = _props$showViewSwitch === void 0 ? true : _props$showViewSwitch,
|
|
140
|
+
_props$defaultPageSiz = props.defaultPageSize,
|
|
141
|
+
defaultPageSize = _props$defaultPageSiz === void 0 ? 20 : _props$defaultPageSiz,
|
|
142
|
+
bizTypes = props.bizTypes,
|
|
143
|
+
_props$showFilters = props.showFilters,
|
|
144
|
+
showFilters = _props$showFilters === void 0 ? true : _props$showFilters,
|
|
145
|
+
onDeleted = props.onDeleted,
|
|
146
|
+
onPreview = props.onPreview,
|
|
147
|
+
className = props.className,
|
|
148
|
+
style = props.style;
|
|
149
|
+
var fcCtx = useMemo(function () {
|
|
150
|
+
return resolveFcContext(props);
|
|
151
|
+
}, [props.appKey, props.baseUrl, props.getToken]);
|
|
152
|
+
var _message$useMessage = message.useMessage(),
|
|
153
|
+
_message$useMessage2 = _slicedToArray(_message$useMessage, 2),
|
|
154
|
+
messageApi = _message$useMessage2[0],
|
|
155
|
+
messageHolder = _message$useMessage2[1];
|
|
156
|
+
var _usePreviewModal = usePreviewModal(),
|
|
157
|
+
openPreview = _usePreviewModal.openPreview,
|
|
158
|
+
previewNode = _usePreviewModal.previewNode;
|
|
159
|
+
|
|
160
|
+
/* ---- 查询状态 ---- */
|
|
161
|
+
var _useState3 = useState(defaultView),
|
|
162
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
163
|
+
view = _useState4[0],
|
|
164
|
+
setView = _useState4[1];
|
|
165
|
+
var _useState5 = useState([]),
|
|
166
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
167
|
+
list = _useState6[0],
|
|
168
|
+
setList = _useState6[1];
|
|
169
|
+
var _useState7 = useState(0),
|
|
170
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
171
|
+
total = _useState8[0],
|
|
172
|
+
setTotal = _useState8[1];
|
|
173
|
+
var _useState9 = useState(1),
|
|
174
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
175
|
+
page = _useState10[0],
|
|
176
|
+
setPage = _useState10[1];
|
|
177
|
+
var _useState11 = useState(defaultPageSize),
|
|
178
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
179
|
+
pageSize = _useState12[0],
|
|
180
|
+
setPageSize = _useState12[1];
|
|
181
|
+
var _useState13 = useState(false),
|
|
182
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
183
|
+
loading = _useState14[0],
|
|
184
|
+
setLoading = _useState14[1];
|
|
185
|
+
|
|
186
|
+
/* ---- 筛选条件 ---- */
|
|
187
|
+
var _useState15 = useState(''),
|
|
188
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
189
|
+
nameKeyword = _useState16[0],
|
|
190
|
+
setNameKeyword = _useState16[1];
|
|
191
|
+
var _useState17 = useState(),
|
|
192
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
193
|
+
bizType = _useState18[0],
|
|
194
|
+
setBizType = _useState18[1];
|
|
195
|
+
var _useState19 = useState(),
|
|
196
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
197
|
+
fileType = _useState20[0],
|
|
198
|
+
setFileType = _useState20[1];
|
|
199
|
+
var _useState21 = useState(null),
|
|
200
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
201
|
+
timeRange = _useState22[0],
|
|
202
|
+
setTimeRange = _useState22[1];
|
|
203
|
+
var loadList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
204
|
+
var targetPage,
|
|
205
|
+
targetPageSize,
|
|
206
|
+
_timeRange$,
|
|
207
|
+
_timeRange$2,
|
|
208
|
+
result,
|
|
209
|
+
_args = arguments;
|
|
210
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
211
|
+
while (1) switch (_context.prev = _context.next) {
|
|
212
|
+
case 0:
|
|
213
|
+
targetPage = _args.length > 0 && _args[0] !== undefined ? _args[0] : page;
|
|
214
|
+
targetPageSize = _args.length > 1 && _args[1] !== undefined ? _args[1] : pageSize;
|
|
215
|
+
setLoading(true);
|
|
216
|
+
_context.prev = 3;
|
|
217
|
+
_context.next = 6;
|
|
218
|
+
return fetchFileList(fcCtx, {
|
|
219
|
+
page: targetPage,
|
|
220
|
+
pageSize: targetPageSize,
|
|
221
|
+
name: nameKeyword || undefined,
|
|
222
|
+
bizType: bizType,
|
|
223
|
+
type: fileType,
|
|
224
|
+
startTime: timeRange === null || timeRange === void 0 || (_timeRange$ = timeRange[0]) === null || _timeRange$ === void 0 ? void 0 : _timeRange$.startOf('day').toISOString(),
|
|
225
|
+
endTime: timeRange === null || timeRange === void 0 || (_timeRange$2 = timeRange[1]) === null || _timeRange$2 === void 0 ? void 0 : _timeRange$2.endOf('day').toISOString()
|
|
226
|
+
});
|
|
227
|
+
case 6:
|
|
228
|
+
result = _context.sent;
|
|
229
|
+
setList(result.list);
|
|
230
|
+
setTotal(result.total);
|
|
231
|
+
_context.next = 16;
|
|
232
|
+
break;
|
|
233
|
+
case 11:
|
|
234
|
+
_context.prev = 11;
|
|
235
|
+
_context.t0 = _context["catch"](3);
|
|
236
|
+
messageApi.error(_context.t0 instanceof Error ? _context.t0.message : '文件列表加载失败');
|
|
237
|
+
setList([]);
|
|
238
|
+
setTotal(0);
|
|
239
|
+
case 16:
|
|
240
|
+
_context.prev = 16;
|
|
241
|
+
setLoading(false);
|
|
242
|
+
return _context.finish(16);
|
|
243
|
+
case 19:
|
|
244
|
+
case "end":
|
|
245
|
+
return _context.stop();
|
|
246
|
+
}
|
|
247
|
+
}, _callee, null, [[3, 11, 16, 19]]);
|
|
248
|
+
})),
|
|
249
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
250
|
+
[fcCtx.baseUrl, fcCtx.appKey, page, pageSize, nameKeyword, bizType, fileType, timeRange, messageApi]);
|
|
251
|
+
useEffect(function () {
|
|
252
|
+
loadList();
|
|
253
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
254
|
+
}, [page, pageSize, bizType, fileType, timeRange]);
|
|
255
|
+
|
|
256
|
+
/* ---- 行操作 ---- */
|
|
257
|
+
var handleCopyUrl = useCallback( /*#__PURE__*/function () {
|
|
258
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
|
|
259
|
+
var ok;
|
|
260
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
261
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
262
|
+
case 0:
|
|
263
|
+
_context2.next = 2;
|
|
264
|
+
return copyText(file.url);
|
|
265
|
+
case 2:
|
|
266
|
+
ok = _context2.sent;
|
|
267
|
+
if (ok) messageApi.success('链接已复制');else messageApi.error('复制失败,请手动复制');
|
|
268
|
+
case 4:
|
|
269
|
+
case "end":
|
|
270
|
+
return _context2.stop();
|
|
271
|
+
}
|
|
272
|
+
}, _callee2);
|
|
273
|
+
}));
|
|
274
|
+
return function (_x) {
|
|
275
|
+
return _ref3.apply(this, arguments);
|
|
276
|
+
};
|
|
277
|
+
}(), [messageApi]);
|
|
278
|
+
var handleRefreshSign = useCallback( /*#__PURE__*/function () {
|
|
279
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(file) {
|
|
280
|
+
var result;
|
|
281
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
282
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
283
|
+
case 0:
|
|
284
|
+
_context3.prev = 0;
|
|
285
|
+
_context3.next = 3;
|
|
286
|
+
return refreshFileSign(fcCtx, file.id);
|
|
287
|
+
case 3:
|
|
288
|
+
result = _context3.sent;
|
|
289
|
+
setList(function (prev) {
|
|
290
|
+
return prev.map(function (item) {
|
|
291
|
+
return item.id === file.id ? _objectSpread(_objectSpread({}, item), {}, {
|
|
292
|
+
url: result.url
|
|
293
|
+
}) : item;
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
messageApi.success('签名已刷新');
|
|
297
|
+
_context3.next = 11;
|
|
298
|
+
break;
|
|
299
|
+
case 8:
|
|
300
|
+
_context3.prev = 8;
|
|
301
|
+
_context3.t0 = _context3["catch"](0);
|
|
302
|
+
messageApi.error(_context3.t0 instanceof Error ? _context3.t0.message : '刷新签名失败');
|
|
303
|
+
case 11:
|
|
304
|
+
case "end":
|
|
305
|
+
return _context3.stop();
|
|
306
|
+
}
|
|
307
|
+
}, _callee3, null, [[0, 8]]);
|
|
308
|
+
}));
|
|
309
|
+
return function (_x2) {
|
|
310
|
+
return _ref4.apply(this, arguments);
|
|
311
|
+
};
|
|
312
|
+
}(), [fcCtx, messageApi]);
|
|
313
|
+
var handleDelete = useCallback(function (file) {
|
|
314
|
+
var acknowledged = false;
|
|
315
|
+
var doDelete = /*#__PURE__*/function () {
|
|
316
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
317
|
+
var _result$references;
|
|
318
|
+
var result, references;
|
|
319
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
320
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
321
|
+
case 0:
|
|
322
|
+
_context5.next = 2;
|
|
323
|
+
return deleteFile(fcCtx, file.id);
|
|
324
|
+
case 2:
|
|
325
|
+
result = _context5.sent;
|
|
326
|
+
if (!result.deleted) {
|
|
327
|
+
_context5.next = 8;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
messageApi.success('删除成功');
|
|
331
|
+
onDeleted === null || onDeleted === void 0 || onDeleted(file);
|
|
332
|
+
loadList();
|
|
333
|
+
return _context5.abrupt("return");
|
|
334
|
+
case 8:
|
|
335
|
+
if (!((_result$references = result.references) !== null && _result$references !== void 0)) {
|
|
336
|
+
_context5.next = 12;
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
_context5.t0 = _result$references;
|
|
340
|
+
_context5.next = 15;
|
|
341
|
+
break;
|
|
342
|
+
case 12:
|
|
343
|
+
_context5.next = 14;
|
|
344
|
+
return fetchReferences(fcCtx, file.id);
|
|
345
|
+
case 14:
|
|
346
|
+
_context5.t0 = _context5.sent;
|
|
347
|
+
case 15:
|
|
348
|
+
references = _context5.t0;
|
|
349
|
+
Modal.confirm({
|
|
350
|
+
title: '该文件存在业务引用,确认删除?',
|
|
351
|
+
width: 560,
|
|
352
|
+
icon: /*#__PURE__*/_jsx(DeleteOutlined, {}),
|
|
353
|
+
content: /*#__PURE__*/_jsxs("div", {
|
|
354
|
+
children: [/*#__PURE__*/_jsx(ReferenceList, {
|
|
355
|
+
references: references
|
|
356
|
+
}), /*#__PURE__*/_jsx(Checkbox, {
|
|
357
|
+
onChange: function onChange(e) {
|
|
358
|
+
acknowledged = e.target.checked;
|
|
359
|
+
},
|
|
360
|
+
children: "\u6211\u5DF2\u77E5\u6653\u5F71\u54CD\u8303\u56F4\uFF0C\u786E\u8BA4\u5220\u9664"
|
|
361
|
+
})]
|
|
362
|
+
}),
|
|
363
|
+
okText: '删除',
|
|
364
|
+
okButtonProps: {
|
|
365
|
+
danger: true
|
|
366
|
+
},
|
|
367
|
+
cancelText: '取消',
|
|
368
|
+
onOk: function () {
|
|
369
|
+
var _onOk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
370
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
371
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
372
|
+
case 0:
|
|
373
|
+
if (acknowledged) {
|
|
374
|
+
_context4.next = 3;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
messageApi.warning('请先勾选「我已知晓影响范围」');
|
|
378
|
+
return _context4.abrupt("return", Promise.reject());
|
|
379
|
+
case 3:
|
|
380
|
+
_context4.next = 5;
|
|
381
|
+
return deleteFile(fcCtx, file.id, {
|
|
382
|
+
force: true
|
|
383
|
+
});
|
|
384
|
+
case 5:
|
|
385
|
+
messageApi.success('删除成功');
|
|
386
|
+
onDeleted === null || onDeleted === void 0 || onDeleted(file);
|
|
387
|
+
loadList();
|
|
388
|
+
case 8:
|
|
389
|
+
case "end":
|
|
390
|
+
return _context4.stop();
|
|
391
|
+
}
|
|
392
|
+
}, _callee4);
|
|
393
|
+
}));
|
|
394
|
+
function onOk() {
|
|
395
|
+
return _onOk.apply(this, arguments);
|
|
396
|
+
}
|
|
397
|
+
return onOk;
|
|
398
|
+
}()
|
|
399
|
+
});
|
|
400
|
+
case 17:
|
|
401
|
+
case "end":
|
|
402
|
+
return _context5.stop();
|
|
403
|
+
}
|
|
404
|
+
}, _callee5);
|
|
405
|
+
}));
|
|
406
|
+
return function doDelete() {
|
|
407
|
+
return _ref5.apply(this, arguments);
|
|
408
|
+
};
|
|
409
|
+
}();
|
|
410
|
+
Modal.confirm({
|
|
411
|
+
title: "\u786E\u8BA4\u5220\u9664\u300A".concat(file.name, "\u300B\uFF1F"),
|
|
412
|
+
content: '删除后文件保留 30 天,期间可联系管理员恢复。',
|
|
413
|
+
okText: '删除',
|
|
414
|
+
okButtonProps: {
|
|
415
|
+
danger: true
|
|
416
|
+
},
|
|
417
|
+
cancelText: '取消',
|
|
418
|
+
onOk: function () {
|
|
419
|
+
var _onOk2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
420
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
421
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
422
|
+
case 0:
|
|
423
|
+
_context6.prev = 0;
|
|
424
|
+
_context6.next = 3;
|
|
425
|
+
return doDelete();
|
|
426
|
+
case 3:
|
|
427
|
+
_context6.next = 8;
|
|
428
|
+
break;
|
|
429
|
+
case 5:
|
|
430
|
+
_context6.prev = 5;
|
|
431
|
+
_context6.t0 = _context6["catch"](0);
|
|
432
|
+
messageApi.error(_context6.t0 instanceof Error ? _context6.t0.message : '删除失败');
|
|
433
|
+
case 8:
|
|
434
|
+
case "end":
|
|
435
|
+
return _context6.stop();
|
|
436
|
+
}
|
|
437
|
+
}, _callee6, null, [[0, 5]]);
|
|
438
|
+
}));
|
|
439
|
+
function onOk() {
|
|
440
|
+
return _onOk2.apply(this, arguments);
|
|
441
|
+
}
|
|
442
|
+
return onOk;
|
|
443
|
+
}()
|
|
444
|
+
});
|
|
445
|
+
}, [fcCtx, loadList, messageApi, onDeleted]);
|
|
446
|
+
var handlePreview = useCallback(function (file) {
|
|
447
|
+
if (onPreview) {
|
|
448
|
+
onPreview(file);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
openPreview(file);
|
|
452
|
+
}, [onPreview, openPreview]);
|
|
453
|
+
var renderActions = function renderActions(file) {
|
|
454
|
+
return /*#__PURE__*/_jsxs(Space, {
|
|
455
|
+
size: 4,
|
|
456
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
457
|
+
title: "\u9884\u89C8",
|
|
458
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
459
|
+
type: "text",
|
|
460
|
+
size: "small",
|
|
461
|
+
icon: /*#__PURE__*/_jsx(EyeOutlined, {}),
|
|
462
|
+
onClick: function onClick() {
|
|
463
|
+
return handlePreview(file);
|
|
464
|
+
}
|
|
465
|
+
})
|
|
466
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
467
|
+
title: "\u590D\u5236 URL",
|
|
468
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
469
|
+
type: "text",
|
|
470
|
+
size: "small",
|
|
471
|
+
icon: /*#__PURE__*/_jsx(LinkOutlined, {}),
|
|
472
|
+
onClick: function onClick() {
|
|
473
|
+
return handleCopyUrl(file);
|
|
474
|
+
}
|
|
475
|
+
})
|
|
476
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
477
|
+
title: "\u4E0B\u8F7D",
|
|
478
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
479
|
+
type: "text",
|
|
480
|
+
size: "small",
|
|
481
|
+
icon: /*#__PURE__*/_jsx(DownloadOutlined, {}),
|
|
482
|
+
onClick: function onClick() {
|
|
483
|
+
return downloadFile(file.url, file.name);
|
|
484
|
+
}
|
|
485
|
+
})
|
|
486
|
+
}), file.accessType === 'private' && /*#__PURE__*/_jsx(Tooltip, {
|
|
487
|
+
title: "\u5237\u65B0\u7B7E\u540D",
|
|
488
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
489
|
+
type: "text",
|
|
490
|
+
size: "small",
|
|
491
|
+
icon: /*#__PURE__*/_jsx(ReloadOutlined, {}),
|
|
492
|
+
onClick: function onClick() {
|
|
493
|
+
return handleRefreshSign(file);
|
|
494
|
+
}
|
|
495
|
+
})
|
|
496
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
497
|
+
title: "\u5220\u9664",
|
|
498
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
499
|
+
type: "text",
|
|
500
|
+
size: "small",
|
|
501
|
+
danger: true,
|
|
502
|
+
icon: /*#__PURE__*/_jsx(DeleteOutlined, {}),
|
|
503
|
+
onClick: function onClick() {
|
|
504
|
+
return handleDelete(file);
|
|
505
|
+
}
|
|
506
|
+
})
|
|
507
|
+
})]
|
|
508
|
+
});
|
|
509
|
+
};
|
|
510
|
+
var renderThumb = function renderThumb(file, size) {
|
|
511
|
+
if (getFileCategory(file.mime, file.ext) === 'image') {
|
|
512
|
+
return /*#__PURE__*/_jsx("img", {
|
|
513
|
+
className: "bc-fc-filelist-thumb",
|
|
514
|
+
style: {
|
|
515
|
+
width: size,
|
|
516
|
+
height: size
|
|
517
|
+
},
|
|
518
|
+
src: file.url,
|
|
519
|
+
alt: file.name
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return /*#__PURE__*/_jsx("span", {
|
|
523
|
+
className: "bc-fc-filelist-thumb bc-fc-filelist-thumb-icon",
|
|
524
|
+
style: {
|
|
525
|
+
width: size,
|
|
526
|
+
height: size
|
|
527
|
+
},
|
|
528
|
+
children: /*#__PURE__*/_jsx(PaperClipOutlined, {})
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
/* ---- 表格视图 ---- */
|
|
533
|
+
var columns = [{
|
|
534
|
+
title: '缩略图',
|
|
535
|
+
dataIndex: 'url',
|
|
536
|
+
width: 72,
|
|
537
|
+
render: function render(_, file) {
|
|
538
|
+
return renderThumb(file, 48);
|
|
539
|
+
}
|
|
540
|
+
}, {
|
|
541
|
+
title: '文件名',
|
|
542
|
+
dataIndex: 'name',
|
|
543
|
+
ellipsis: true,
|
|
544
|
+
render: function render(name, file) {
|
|
545
|
+
return /*#__PURE__*/_jsx("a", {
|
|
546
|
+
onClick: function onClick() {
|
|
547
|
+
return handlePreview(file);
|
|
548
|
+
},
|
|
549
|
+
children: name
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
}, {
|
|
553
|
+
title: '类型',
|
|
554
|
+
dataIndex: 'ext',
|
|
555
|
+
width: 90,
|
|
556
|
+
render: function render(ext) {
|
|
557
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
558
|
+
children: (ext || '未知').toUpperCase()
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}, {
|
|
562
|
+
title: '大小',
|
|
563
|
+
dataIndex: 'size',
|
|
564
|
+
width: 100,
|
|
565
|
+
render: function render(size) {
|
|
566
|
+
return formatFileSize(size);
|
|
567
|
+
}
|
|
568
|
+
}, {
|
|
569
|
+
title: '业务标签',
|
|
570
|
+
dataIndex: 'bizType',
|
|
571
|
+
width: 120,
|
|
572
|
+
render: function render(biz) {
|
|
573
|
+
return biz ? /*#__PURE__*/_jsx(Tag, {
|
|
574
|
+
color: "blue",
|
|
575
|
+
children: biz
|
|
576
|
+
}) : '-';
|
|
577
|
+
}
|
|
578
|
+
}, {
|
|
579
|
+
title: '访问',
|
|
580
|
+
dataIndex: 'accessType',
|
|
581
|
+
width: 80,
|
|
582
|
+
render: function render(accessType) {
|
|
583
|
+
return accessType === 'private' ? /*#__PURE__*/_jsx(Tag, {
|
|
584
|
+
color: "orange",
|
|
585
|
+
children: "\u79C1\u6709"
|
|
586
|
+
}) : /*#__PURE__*/_jsx(Tag, {
|
|
587
|
+
color: "green",
|
|
588
|
+
children: "\u516C\u5F00"
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
}, {
|
|
592
|
+
title: '上传时间',
|
|
593
|
+
dataIndex: 'createdAt',
|
|
594
|
+
width: 170,
|
|
595
|
+
render: function render(createdAt) {
|
|
596
|
+
return dayjs(createdAt).format('YYYY-MM-DD HH:mm');
|
|
597
|
+
}
|
|
598
|
+
}, {
|
|
599
|
+
title: '操作',
|
|
600
|
+
key: 'action',
|
|
601
|
+
width: 200,
|
|
602
|
+
render: function render(_, file) {
|
|
603
|
+
return renderActions(file);
|
|
604
|
+
}
|
|
605
|
+
}];
|
|
606
|
+
|
|
607
|
+
/* ---- 宫格视图 ---- */
|
|
608
|
+
var renderGrid = function renderGrid() {
|
|
609
|
+
if (!list.length) {
|
|
610
|
+
return /*#__PURE__*/_jsx(Empty, {
|
|
611
|
+
description: "\u6682\u65E0\u6587\u4EF6",
|
|
612
|
+
style: {
|
|
613
|
+
padding: '32px 0'
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
return /*#__PURE__*/_jsx("div", {
|
|
618
|
+
className: "bc-fc-filelist-grid",
|
|
619
|
+
children: list.map(function (file) {
|
|
620
|
+
return /*#__PURE__*/_jsx(Card, {
|
|
621
|
+
size: "small",
|
|
622
|
+
className: "bc-fc-filelist-grid-card",
|
|
623
|
+
cover: /*#__PURE__*/_jsxs("div", {
|
|
624
|
+
className: "bc-fc-filelist-grid-cover",
|
|
625
|
+
onClick: function onClick() {
|
|
626
|
+
return handlePreview(file);
|
|
627
|
+
},
|
|
628
|
+
children: [getFileCategory(file.mime, file.ext) === 'image' ? /*#__PURE__*/_jsx("img", {
|
|
629
|
+
src: file.url,
|
|
630
|
+
alt: file.name
|
|
631
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
632
|
+
className: "bc-fc-filelist-grid-icon",
|
|
633
|
+
children: /*#__PURE__*/_jsx(PaperClipOutlined, {})
|
|
634
|
+
}), file.accessType === 'private' && /*#__PURE__*/_jsx(Tag, {
|
|
635
|
+
color: "orange",
|
|
636
|
+
className: "bc-fc-filelist-grid-private",
|
|
637
|
+
children: "\u79C1\u6709"
|
|
638
|
+
})]
|
|
639
|
+
}),
|
|
640
|
+
actions: [/*#__PURE__*/_jsx(Tooltip, {
|
|
641
|
+
title: "\u590D\u5236 URL",
|
|
642
|
+
children: /*#__PURE__*/_jsx(LinkOutlined, {
|
|
643
|
+
onClick: function onClick() {
|
|
644
|
+
return handleCopyUrl(file);
|
|
645
|
+
}
|
|
646
|
+
})
|
|
647
|
+
}, "copy"), /*#__PURE__*/_jsx(Tooltip, {
|
|
648
|
+
title: "\u4E0B\u8F7D",
|
|
649
|
+
children: /*#__PURE__*/_jsx(DownloadOutlined, {
|
|
650
|
+
onClick: function onClick() {
|
|
651
|
+
return downloadFile(file.url, file.name);
|
|
652
|
+
}
|
|
653
|
+
})
|
|
654
|
+
}, "download"), file.accessType === 'private' ? /*#__PURE__*/_jsx(Tooltip, {
|
|
655
|
+
title: "\u5237\u65B0\u7B7E\u540D",
|
|
656
|
+
children: /*#__PURE__*/_jsx(ReloadOutlined, {
|
|
657
|
+
onClick: function onClick() {
|
|
658
|
+
return handleRefreshSign(file);
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
}, "refresh") : /*#__PURE__*/_jsx(Tooltip, {
|
|
662
|
+
title: "\u9884\u89C8",
|
|
663
|
+
children: /*#__PURE__*/_jsx(EyeOutlined, {
|
|
664
|
+
onClick: function onClick() {
|
|
665
|
+
return handlePreview(file);
|
|
666
|
+
}
|
|
667
|
+
})
|
|
668
|
+
}, "preview"), /*#__PURE__*/_jsx(Tooltip, {
|
|
669
|
+
title: "\u5220\u9664",
|
|
670
|
+
children: /*#__PURE__*/_jsx(DeleteOutlined, {
|
|
671
|
+
onClick: function onClick() {
|
|
672
|
+
return handleDelete(file);
|
|
673
|
+
}
|
|
674
|
+
})
|
|
675
|
+
}, "delete")],
|
|
676
|
+
children: /*#__PURE__*/_jsx(Card.Meta, {
|
|
677
|
+
title: /*#__PURE__*/_jsx(Tooltip, {
|
|
678
|
+
title: file.name,
|
|
679
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
680
|
+
className: "bc-fc-filelist-grid-name",
|
|
681
|
+
children: file.name
|
|
682
|
+
})
|
|
683
|
+
}),
|
|
684
|
+
description: "".concat(formatFileSize(file.size), " \xB7 ").concat(dayjs(file.createdAt).format('YYYY-MM-DD'))
|
|
685
|
+
})
|
|
686
|
+
}, file.id);
|
|
687
|
+
})
|
|
688
|
+
});
|
|
689
|
+
};
|
|
690
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
691
|
+
className: "bc-fc-filelist ".concat(className !== null && className !== void 0 ? className : ''),
|
|
692
|
+
style: style,
|
|
693
|
+
children: [showFilters && /*#__PURE__*/_jsxs("div", {
|
|
694
|
+
className: "bc-fc-filelist-toolbar",
|
|
695
|
+
children: [/*#__PURE__*/_jsxs(Space, {
|
|
696
|
+
wrap: true,
|
|
697
|
+
children: [/*#__PURE__*/_jsx(Input.Search, {
|
|
698
|
+
placeholder: "\u6309\u6587\u4EF6\u540D\u641C\u7D22",
|
|
699
|
+
allowClear: true,
|
|
700
|
+
style: {
|
|
701
|
+
width: 220
|
|
702
|
+
},
|
|
703
|
+
onSearch: function onSearch(keyword) {
|
|
704
|
+
setNameKeyword(keyword.trim());
|
|
705
|
+
setPage(1);
|
|
706
|
+
loadList(1, pageSize);
|
|
707
|
+
}
|
|
708
|
+
}), bizTypes !== null && bizTypes !== void 0 && bizTypes.length ? /*#__PURE__*/_jsx(Select, {
|
|
709
|
+
style: {
|
|
710
|
+
width: 150
|
|
711
|
+
},
|
|
712
|
+
placeholder: "\u5168\u90E8\u4E1A\u52A1\u6807\u7B7E",
|
|
713
|
+
allowClear: true,
|
|
714
|
+
value: bizType,
|
|
715
|
+
onChange: function onChange(value) {
|
|
716
|
+
setBizType(value || undefined);
|
|
717
|
+
setPage(1);
|
|
718
|
+
},
|
|
719
|
+
options: bizTypes
|
|
720
|
+
}) : null, /*#__PURE__*/_jsx(Select, {
|
|
721
|
+
style: {
|
|
722
|
+
width: 120
|
|
723
|
+
},
|
|
724
|
+
placeholder: "\u5168\u90E8\u7C7B\u578B",
|
|
725
|
+
allowClear: true,
|
|
726
|
+
value: fileType,
|
|
727
|
+
onChange: function onChange(value) {
|
|
728
|
+
setFileType(value || undefined);
|
|
729
|
+
setPage(1);
|
|
730
|
+
},
|
|
731
|
+
options: [{
|
|
732
|
+
label: '图片',
|
|
733
|
+
value: 'image'
|
|
734
|
+
}, {
|
|
735
|
+
label: '视频',
|
|
736
|
+
value: 'video'
|
|
737
|
+
}, {
|
|
738
|
+
label: '音频',
|
|
739
|
+
value: 'audio'
|
|
740
|
+
}, {
|
|
741
|
+
label: '文档',
|
|
742
|
+
value: 'application'
|
|
743
|
+
}]
|
|
744
|
+
}), /*#__PURE__*/_jsx(DatePicker.RangePicker, {
|
|
745
|
+
value: timeRange,
|
|
746
|
+
onChange: function onChange(range) {
|
|
747
|
+
setTimeRange(range);
|
|
748
|
+
setPage(1);
|
|
749
|
+
}
|
|
750
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
751
|
+
icon: /*#__PURE__*/_jsx(ReloadOutlined, {}),
|
|
752
|
+
onClick: function onClick() {
|
|
753
|
+
return loadList();
|
|
754
|
+
},
|
|
755
|
+
children: "\u5237\u65B0"
|
|
756
|
+
})]
|
|
757
|
+
}), showViewSwitch && /*#__PURE__*/_jsx(Segmented, {
|
|
758
|
+
value: view,
|
|
759
|
+
onChange: function onChange(value) {
|
|
760
|
+
return setView(value);
|
|
761
|
+
},
|
|
762
|
+
options: [{
|
|
763
|
+
value: 'table',
|
|
764
|
+
icon: /*#__PURE__*/_jsx(BarsOutlined, {}),
|
|
765
|
+
title: '表格视图'
|
|
766
|
+
}, {
|
|
767
|
+
value: 'grid',
|
|
768
|
+
icon: /*#__PURE__*/_jsx(AppstoreOutlined, {}),
|
|
769
|
+
title: '宫格视图'
|
|
770
|
+
}]
|
|
771
|
+
})]
|
|
772
|
+
}), /*#__PURE__*/_jsx(Spin, {
|
|
773
|
+
spinning: loading,
|
|
774
|
+
children: view === 'table' ? /*#__PURE__*/_jsx(Table, {
|
|
775
|
+
rowKey: "id",
|
|
776
|
+
size: "middle",
|
|
777
|
+
columns: columns,
|
|
778
|
+
dataSource: list,
|
|
779
|
+
pagination: false,
|
|
780
|
+
locale: {
|
|
781
|
+
emptyText: /*#__PURE__*/_jsx(Empty, {
|
|
782
|
+
description: "\u6682\u65E0\u6587\u4EF6"
|
|
783
|
+
})
|
|
784
|
+
}
|
|
785
|
+
}) : renderGrid()
|
|
786
|
+
}), total > 0 && /*#__PURE__*/_jsx("div", {
|
|
787
|
+
className: "bc-fc-filelist-pagination",
|
|
788
|
+
children: /*#__PURE__*/_jsx(Pagination, {
|
|
789
|
+
current: page,
|
|
790
|
+
pageSize: pageSize,
|
|
791
|
+
total: total,
|
|
792
|
+
showSizeChanger: true,
|
|
793
|
+
showTotal: function showTotal(count) {
|
|
794
|
+
return "\u5171 ".concat(count, " \u4E2A\u6587\u4EF6");
|
|
795
|
+
},
|
|
796
|
+
onChange: function onChange(nextPage, nextPageSize) {
|
|
797
|
+
setPage(nextPage);
|
|
798
|
+
setPageSize(nextPageSize);
|
|
799
|
+
}
|
|
800
|
+
})
|
|
801
|
+
}), previewNode, messageHolder]
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
export default FcFileList;
|