@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.
Files changed (47) hide show
  1. package/README.md +259 -2
  2. package/dist/file-center/api/endpoints.d.ts +42 -0
  3. package/dist/file-center/api/endpoints.js +45 -0
  4. package/dist/file-center/api/error.d.ts +6 -0
  5. package/dist/file-center/api/error.js +34 -0
  6. package/dist/file-center/api/index.d.ts +64 -0
  7. package/dist/file-center/api/index.js +238 -0
  8. package/dist/file-center/api/request.d.ts +28 -0
  9. package/dist/file-center/api/request.js +170 -0
  10. package/dist/file-center/api/token.d.ts +10 -0
  11. package/dist/file-center/api/token.js +122 -0
  12. package/dist/file-center/components/FcFileList/index.d.ts +39 -0
  13. package/dist/file-center/components/FcFileList/index.js +804 -0
  14. package/dist/file-center/components/FcFileList/style.css +106 -0
  15. package/dist/file-center/components/FcImage/index.d.ts +30 -0
  16. package/dist/file-center/components/FcImage/index.js +144 -0
  17. package/dist/file-center/components/FcImage/style.css +14 -0
  18. package/dist/file-center/components/FcUpload/index.d.ts +5 -0
  19. package/dist/file-center/components/FcUpload/index.js +642 -0
  20. package/dist/file-center/components/FcUpload/interface.d.ts +65 -0
  21. package/dist/file-center/components/FcUpload/interface.js +1 -0
  22. package/dist/file-center/components/FcUpload/style.css +279 -0
  23. package/dist/file-center/context.d.ts +22 -0
  24. package/dist/file-center/context.js +22 -0
  25. package/dist/file-center/index.d.ts +26 -0
  26. package/dist/file-center/index.js +21 -0
  27. package/dist/file-center/types.d.ts +144 -0
  28. package/dist/file-center/types.js +1 -0
  29. package/dist/file-center/upload.d.ts +35 -0
  30. package/dist/file-center/upload.js +295 -0
  31. package/dist/file-center/utils/common.d.ts +10 -0
  32. package/dist/file-center/utils/common.js +165 -0
  33. package/dist/file-center/utils/compress.d.ts +18 -0
  34. package/dist/file-center/utils/compress.js +108 -0
  35. package/dist/file-center/utils/md5.d.ts +5 -0
  36. package/dist/file-center/utils/md5.js +41 -0
  37. package/dist/index.d.ts +11 -0
  38. package/dist/index.js +15 -0
  39. package/dist/mobile/FcImage/index.d.ts +26 -0
  40. package/dist/mobile/FcImage/index.js +114 -0
  41. package/dist/mobile/FcImage/style.css +11 -0
  42. package/dist/mobile/FcUpload/index.d.ts +74 -0
  43. package/dist/mobile/FcUpload/index.js +539 -0
  44. package/dist/mobile/FcUpload/style.css +233 -0
  45. package/dist/mobile/index.d.ts +13 -0
  46. package/dist/mobile/index.js +9 -0
  47. package/package.json +70 -4
@@ -0,0 +1,106 @@
1
+ /* FcFileList 样式:前缀 bc-fc-filelist */
2
+
3
+ .bc-fc-filelist-toolbar {
4
+ display: flex;
5
+ flex-wrap: wrap;
6
+ gap: 12px;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ margin-bottom: 16px;
10
+ }
11
+
12
+ /* ---- 缩略图 ---- */
13
+
14
+ .bc-fc-filelist-thumb {
15
+ object-fit: cover;
16
+ border-radius: 4px;
17
+ }
18
+
19
+ .bc-fc-filelist-thumb-icon {
20
+ display: inline-flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ color: rgba(0, 0, 0, 0.35);
24
+ font-size: 20px;
25
+ background: #fafafa;
26
+ border: 1px solid #f0f0f0;
27
+ }
28
+
29
+ /* ---- 宫格视图 ---- */
30
+
31
+ .bc-fc-filelist-grid {
32
+ display: grid;
33
+ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
34
+ gap: 16px;
35
+ }
36
+
37
+ .bc-fc-filelist-grid-cover {
38
+ position: relative;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ height: 140px;
43
+ overflow: hidden;
44
+ background: #fafafa;
45
+ cursor: pointer;
46
+ }
47
+
48
+ .bc-fc-filelist-grid-cover img {
49
+ width: 100%;
50
+ height: 100%;
51
+ object-fit: cover;
52
+ }
53
+
54
+ .bc-fc-filelist-grid-icon {
55
+ color: rgba(0, 0, 0, 0.3);
56
+ font-size: 32px;
57
+ }
58
+
59
+ .bc-fc-filelist-grid-private {
60
+ position: absolute;
61
+ top: 8px;
62
+ right: 8px;
63
+ margin: 0;
64
+ }
65
+
66
+ .bc-fc-filelist-grid-name {
67
+ display: block;
68
+ overflow: hidden;
69
+ font-size: 13px;
70
+ white-space: nowrap;
71
+ text-overflow: ellipsis;
72
+ }
73
+
74
+ /* ---- 分页 ---- */
75
+
76
+ .bc-fc-filelist-pagination {
77
+ display: flex;
78
+ justify-content: flex-end;
79
+ margin-top: 16px;
80
+ }
81
+
82
+ /* ---- 引用列表(删除确认弹窗) ---- */
83
+
84
+ .bc-fc-filelist-refs ul {
85
+ max-height: 200px;
86
+ margin: 8px 0;
87
+ padding-left: 18px;
88
+ overflow-y: auto;
89
+ }
90
+
91
+ .bc-fc-filelist-refs li {
92
+ display: flex;
93
+ gap: 8px;
94
+ align-items: center;
95
+ padding: 3px 0;
96
+ font-size: 13px;
97
+ }
98
+
99
+ .bc-fc-filelist-refs-project {
100
+ color: rgba(0, 0, 0, 0.88);
101
+ font-weight: 500;
102
+ }
103
+
104
+ .bc-fc-filelist-refs-biz {
105
+ color: rgba(0, 0, 0, 0.55);
106
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import type { ImageProps } from 'antd';
3
+ import type { FcComponentConfigProps } from '../../context';
4
+ import './style.css';
5
+ export interface FcImageProps extends FcComponentConfigProps, Omit<ImageProps, 'src' | 'loading'> {
6
+ /** 文件中心文件 ID:传入后组件自动换取可访问 URL(私有文件带签名) */
7
+ fileId?: string;
8
+ /** 直接给 URL(业务表里存的是 URL 的场景);与 fileId 二选一,fileId 优先 */
9
+ src?: string;
10
+ /** URL 加载失败时的兜底图 */
11
+ fallback?: string;
12
+ /** 是否允许在签名过期(403/加载失败)时自动刷新签名,默认 true */
13
+ autoRefreshSign?: boolean;
14
+ /** 加载中占位内容,默认转圈动画 */
15
+ loading?: React.ReactNode;
16
+ }
17
+ /**
18
+ * 文件中心图片回显组件
19
+ *
20
+ * - 传 fileId:内部调 OPEN-9 批量取 URL 接口换取可访问地址(私有文件返回带签名的临时 URL);
21
+ * - 传 src:直接回显,加载失败时如带 fileId 会尝试刷新签名;
22
+ * - 签名过期导致加载失败时自动调 OPEN-11 刷新签名并重试一次。
23
+ *
24
+ * ```tsx
25
+ * <FcImage fileId="1234567890" width={120} />
26
+ * <FcImage src={record.avatarUrl} width={40} height={40} />
27
+ * ```
28
+ */
29
+ export declare function FcImage(props: FcImageProps): React.JSX.Element;
30
+ export default FcImage;
@@ -0,0 +1,144 @@
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
+ var _excluded = ["fileId", "src", "fallback", "autoRefreshSign", "loading", "appKey", "baseUrl", "getToken"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ 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."); }
10
+ 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); }
11
+ 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; }
12
+ 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; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
17
+ import { Image, Spin } from 'antd';
18
+ import { resolveFcContext } from "../../context";
19
+ import { fetchFileUrls, refreshFileSign } from "../../api";
20
+ import "./style.css";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ /**
23
+ * 文件中心图片回显组件
24
+ *
25
+ * - 传 fileId:内部调 OPEN-9 批量取 URL 接口换取可访问地址(私有文件返回带签名的临时 URL);
26
+ * - 传 src:直接回显,加载失败时如带 fileId 会尝试刷新签名;
27
+ * - 签名过期导致加载失败时自动调 OPEN-11 刷新签名并重试一次。
28
+ *
29
+ * ```tsx
30
+ * <FcImage fileId="1234567890" width={120} />
31
+ * <FcImage src={record.avatarUrl} width={40} height={40} />
32
+ * ```
33
+ */
34
+ export function FcImage(props) {
35
+ var fileId = props.fileId,
36
+ src = props.src,
37
+ fallback = props.fallback,
38
+ _props$autoRefreshSig = props.autoRefreshSign,
39
+ autoRefreshSign = _props$autoRefreshSig === void 0 ? true : _props$autoRefreshSig,
40
+ loadingNode = props.loading,
41
+ appKey = props.appKey,
42
+ baseUrl = props.baseUrl,
43
+ getToken = props.getToken,
44
+ imageProps = _objectWithoutProperties(props, _excluded);
45
+ var fcCtx = useMemo(function () {
46
+ return resolveFcContext({
47
+ appKey: appKey,
48
+ baseUrl: baseUrl,
49
+ getToken: getToken
50
+ });
51
+ }, [appKey, baseUrl, getToken]);
52
+ var _useState = useState(src),
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ resolvedUrl = _useState2[0],
55
+ setResolvedUrl = _useState2[1];
56
+ var _useState3 = useState(false),
57
+ _useState4 = _slicedToArray(_useState3, 2),
58
+ loading = _useState4[0],
59
+ setLoading = _useState4[1];
60
+ var _useState5 = useState(false),
61
+ _useState6 = _slicedToArray(_useState5, 2),
62
+ loadFailed = _useState6[0],
63
+ setLoadFailed = _useState6[1];
64
+ /** 是否已经尝试过刷新签名(防止死循环) */
65
+ var refreshedRef = useRef(false);
66
+ var mountedRef = useRef(true);
67
+ useEffect(function () {
68
+ mountedRef.current = true;
69
+ return function () {
70
+ mountedRef.current = false;
71
+ };
72
+ }, []);
73
+
74
+ // fileId 变化时重新取 URL(OPEN-9)
75
+ useEffect(function () {
76
+ if (!fileId) {
77
+ setResolvedUrl(src);
78
+ return;
79
+ }
80
+ var cancelled = false;
81
+ setLoading(true);
82
+ setLoadFailed(false);
83
+ refreshedRef.current = false;
84
+ fetchFileUrls(fcCtx, [fileId]).then(function (urlMap) {
85
+ var _urlMap$fileId;
86
+ if (cancelled) return;
87
+ setResolvedUrl((_urlMap$fileId = urlMap[fileId]) !== null && _urlMap$fileId !== void 0 ? _urlMap$fileId : src);
88
+ }).catch(function () {
89
+ if (cancelled) return;
90
+ setResolvedUrl(src);
91
+ setLoadFailed(true);
92
+ }).finally(function () {
93
+ if (!cancelled) setLoading(false);
94
+ });
95
+ return function () {
96
+ cancelled = true;
97
+ };
98
+ // eslint-disable-next-line react-hooks/exhaustive-deps
99
+ }, [fileId, src, fcCtx.baseUrl, fcCtx.appKey]);
100
+
101
+ /** 加载失败:私有文件签名过期时自动刷新签名(OPEN-11)并重试一次 */
102
+ var handleError = useCallback(function () {
103
+ if (fileId && autoRefreshSign && !refreshedRef.current) {
104
+ refreshedRef.current = true;
105
+ refreshFileSign(fcCtx, fileId).then(function (result) {
106
+ if (mountedRef.current) {
107
+ setLoadFailed(false);
108
+ setResolvedUrl(result.url);
109
+ }
110
+ }).catch(function () {
111
+ if (mountedRef.current) setLoadFailed(true);
112
+ });
113
+ return;
114
+ }
115
+ setLoadFailed(true);
116
+ }, [autoRefreshSign, fcCtx, fileId]);
117
+ var finalSrc = useMemo(function () {
118
+ if (loadFailed && fallback) return fallback;
119
+ return resolvedUrl;
120
+ }, [fallback, loadFailed, resolvedUrl]);
121
+ if (loading) {
122
+ return /*#__PURE__*/_jsx("span", {
123
+ className: "bc-fc-image-loading",
124
+ children: loadingNode !== null && loadingNode !== void 0 ? loadingNode : /*#__PURE__*/_jsx(Spin, {
125
+ size: "small"
126
+ })
127
+ });
128
+ }
129
+ if (!finalSrc) {
130
+ return fallback ? /*#__PURE__*/_jsx(Image, _objectSpread(_objectSpread({}, imageProps), {}, {
131
+ src: fallback,
132
+ preview: false
133
+ })) : /*#__PURE__*/_jsx("span", {
134
+ className: "bc-fc-image-empty",
135
+ children: "\u6682\u65E0\u56FE\u7247"
136
+ });
137
+ }
138
+ return /*#__PURE__*/_jsx(Image, _objectSpread(_objectSpread({}, imageProps), {}, {
139
+ src: finalSrc,
140
+ fallback: fallback,
141
+ onError: handleError
142
+ }));
143
+ }
144
+ export default FcImage;
@@ -0,0 +1,14 @@
1
+ /* FcImage 样式 */
2
+
3
+ .bc-fc-image-loading,
4
+ .bc-fc-image-empty {
5
+ display: inline-flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ min-width: 48px;
9
+ min-height: 48px;
10
+ color: rgba(0, 0, 0, 0.35);
11
+ font-size: 12px;
12
+ background: #fafafa;
13
+ border-radius: 6px;
14
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { FcUploadProps } from './interface';
3
+ import './style.css';
4
+ export declare function FcUpload(props: FcUploadProps): React.JSX.Element;
5
+ export default FcUpload;