fan-standard-comp 3.1.1 → 3.1.3
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/dist/fan-standard-comp.umd.js +293 -285
- package/es/ButtonGroup/ButtonList.js +18 -36
- package/es/ButtonGroup/ButtonMenu.js +14 -27
- package/es/ButtonGroup/PopConfirmTitle.js +5 -16
- package/es/ButtonGroup/index.js +76 -107
- package/es/DragContent/DragBar.js +6 -18
- package/es/DragContent/index.js +12 -30
- package/es/FormComp/ChunkUploader/api.js +8 -21
- package/es/FormComp/ChunkUploader/index.js +27 -46
- package/es/FormComp/ChunkUploader/lib.js +9 -26
- package/es/FormComp/ChunkUploader/upload-queue.class.js +5 -12
- package/es/FormComp/ChunkUploader/worker.js +2 -7
- package/es/FormComp/EditButton/index.js +16 -35
- package/es/FormComp/FieldComponent/ReUpload.js +18 -38
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +32 -49
- package/es/FormComp/FieldComponent/TitleNode.js +3 -13
- package/es/FormComp/FieldComponent/index.js +81 -125
- package/es/FormComp/FieldComponent/setReadonlyValues.js +28 -55
- package/es/FormComp/RenderItemGroup/index.js +34 -55
- package/es/FormComp/Uploader/index.js +38 -64
- package/es/FormComp/Uploader/util.js +2 -11
- package/es/FormComp/VarTemplate/index.js +31 -44
- package/es/FormComp/index.js +1 -15
- package/es/NavLeafScroll/index.js +35 -53
- package/es/RefactorTree/index.js +29 -52
- package/es/RefactorTree/indexTreeNode.js +31 -54
- package/es/RefactorTree/style/index.js +1 -3
- package/es/RefactorTree/util.js +10 -18
- package/es/SpecIcon/fonts/iconfont.js +0 -2
- package/es/SpecIcon/index.js +17 -30
- package/es/SplitterLayout/Pane.js +5 -17
- package/es/SplitterLayout/index.js +13 -24
- package/es/StandardContent/SplitterLayout/Pane.js +13 -25
- package/es/StandardContent/SplitterLayout/index.js +30 -43
- package/es/StandardContent/SubfieldContent.js +13 -28
- package/es/StandardContent/WrapperContent.js +10 -24
- package/es/StandardDragModal/index.d.ts +11 -0
- package/es/StandardDragModal/index.js +30 -0
- package/es/StandardFilter/index.js +27 -46
- package/es/StandardForm/ActionList.js +8 -21
- package/es/StandardForm/StepForm.js +40 -68
- package/es/StandardForm/TabForm.js +26 -52
- package/es/StandardForm/index.js +28 -55
- package/es/StandardModal/UpdateFormRef.js +4 -18
- package/es/StandardModal/index.d.ts +3 -0
- package/es/StandardModal/index.js +118 -119
- package/es/StandardPanel/index.js +32 -53
- package/es/StandardTable/index.js +18 -36
- package/es/StandardTable/style/index.js +1 -3
- package/es/components/IconNode/index.js +6 -17
- package/es/components/index.js +2 -15
- package/es/data/func.code.js +2 -9
- package/es/data/general.config.js +2 -9
- package/es/data/index.js +3 -23
- package/es/index.js +24 -229
- package/es/utils/ValueFormat.js +1 -9
- package/es/utils/filterPermission.js +4 -20
- package/es/utils/getParentNodes.js +1 -12
- package/es/utils/index.js +3 -35
- package/lib/ButtonGroup/ButtonList.js +9 -9
- package/lib/ButtonGroup/ButtonMenu.js +11 -11
- package/lib/ButtonGroup/PopConfirmTitle.js +5 -5
- package/lib/ButtonGroup/index.js +47 -47
- package/lib/DragContent/DragBar.js +5 -5
- package/lib/DragContent/index.js +7 -7
- package/lib/FormComp/ChunkUploader/api.js +4 -4
- package/lib/FormComp/ChunkUploader/index.js +10 -10
- package/lib/FormComp/ChunkUploader/lib.js +2 -2
- package/lib/FormComp/ChunkUploader/upload-queue.class.js +2 -2
- package/lib/FormComp/ChunkUploader/worker.js +2 -2
- package/lib/FormComp/EditButton/index.js +10 -10
- package/lib/FormComp/FieldComponent/ReUpload.js +9 -9
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +22 -16
- package/lib/FormComp/FieldComponent/TitleNode.js +4 -4
- package/lib/FormComp/FieldComponent/index.js +41 -41
- package/lib/FormComp/FieldComponent/setReadonlyValues.js +17 -17
- package/lib/FormComp/RenderItemGroup/index.js +20 -20
- package/lib/FormComp/Uploader/index.js +16 -16
- package/lib/FormComp/VarTemplate/index.js +25 -23
- package/lib/FormComp/index.js +2 -2
- package/lib/NavLeafScroll/index.js +28 -28
- package/lib/RefactorTree/index.js +14 -14
- package/lib/RefactorTree/indexTreeNode.js +19 -19
- package/lib/SpecIcon/index.js +13 -13
- package/lib/SplitterLayout/Pane.js +4 -4
- package/lib/SplitterLayout/index.js +10 -10
- package/lib/StandardContent/SplitterLayout/Pane.js +11 -11
- package/lib/StandardContent/SplitterLayout/index.js +27 -27
- package/lib/StandardContent/SubfieldContent.js +9 -9
- package/lib/StandardContent/WrapperContent.js +7 -7
- package/lib/StandardDragModal/index.d.ts +11 -0
- package/lib/StandardDragModal/index.js +43 -0
- package/lib/StandardFilter/index.js +18 -18
- package/lib/StandardForm/ActionList.js +6 -6
- package/lib/StandardForm/StepForm.js +26 -26
- package/lib/StandardForm/TabForm.js +13 -13
- package/lib/StandardForm/index.js +14 -14
- package/lib/StandardModal/UpdateFormRef.js +4 -4
- package/lib/StandardModal/index.d.ts +3 -0
- package/lib/StandardModal/index.js +99 -70
- package/lib/StandardPanel/index.js +23 -23
- package/lib/StandardTable/index.js +9 -10
- package/lib/components/IconNode/index.js +6 -6
- package/lib/components/index.js +2 -2
- package/lib/data/func.code.js +2 -2
- package/lib/data/general.config.js +2 -2
- package/lib/data/index.js +3 -3
- package/lib/index.js +22 -22
- package/lib/utils/ValueFormat.js +2 -2
- package/lib/utils/filterPermission.js +2 -2
- package/lib/utils/index.js +2 -2
- package/package.json +4 -3
- package/es/ConfigContext/index.d.ts +0 -7
- package/es/ConfigContext/index.js +0 -12
- package/es/locale/index.d.ts +0 -12
- package/es/locale/index.js +0 -5
- package/es/locale/zh_CN.d.ts +0 -4
- package/es/locale/zh_CN.js +0 -34
- package/lib/ConfigContext/index.d.ts +0 -7
- package/lib/ConfigContext/index.js +0 -12
- package/lib/locale/index.d.ts +0 -12
- package/lib/locale/index.js +0 -5
- package/lib/locale/zh_CN.d.ts +0 -4
- package/lib/locale/zh_CN.js +0 -34
package/es/DragContent/index.js
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
var _DragBar = _interopRequireDefault(require("./DragBar"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
2
|
|
|
24
3
|
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."); }
|
|
@@ -31,6 +10,10 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
31
10
|
|
|
32
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
33
12
|
|
|
13
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import DragBar from './DragBar';
|
|
16
|
+
|
|
34
17
|
var DragContent = function DragContent(props) {
|
|
35
18
|
var children = props.children,
|
|
36
19
|
className = props.className,
|
|
@@ -43,19 +26,19 @@ var DragContent = function DragContent(props) {
|
|
|
43
26
|
dragMouseDown = props.dragMouseDown,
|
|
44
27
|
dragMouseMove = props.dragMouseMove,
|
|
45
28
|
dragMouseUp = props.dragMouseUp;
|
|
46
|
-
var divRef =
|
|
29
|
+
var divRef = useRef();
|
|
47
30
|
|
|
48
|
-
var _useState =
|
|
31
|
+
var _useState = useState(0),
|
|
49
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
50
33
|
targetWidth = _useState2[0],
|
|
51
34
|
setTargetWidth = _useState2[1];
|
|
52
35
|
|
|
53
|
-
var _useState3 =
|
|
36
|
+
var _useState3 = useState(0),
|
|
54
37
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
38
|
targetHeight = _useState4[0],
|
|
56
39
|
setTargetHeight = _useState4[1];
|
|
57
40
|
|
|
58
|
-
|
|
41
|
+
useEffect(function () {
|
|
59
42
|
setTargetWidth(divRef.current.offsetWidth);
|
|
60
43
|
setTargetHeight(divRef.current.offsetHeight);
|
|
61
44
|
}, []);
|
|
@@ -174,12 +157,12 @@ var DragContent = function DragContent(props) {
|
|
|
174
157
|
};
|
|
175
158
|
};
|
|
176
159
|
|
|
177
|
-
return /*#__PURE__*/
|
|
160
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
178
161
|
ref: divRef,
|
|
179
|
-
className: (
|
|
162
|
+
className: classNames("spec-grid-dragContent", className),
|
|
180
163
|
style: style
|
|
181
164
|
}, children, direction && direction.map(function (item, idx) {
|
|
182
|
-
return /*#__PURE__*/
|
|
165
|
+
return /*#__PURE__*/React.createElement(DragBar, {
|
|
183
166
|
key: idx,
|
|
184
167
|
direction: item,
|
|
185
168
|
onMouseDown: onmousedown
|
|
@@ -187,5 +170,4 @@ var DragContent = function DragContent(props) {
|
|
|
187
170
|
}));
|
|
188
171
|
};
|
|
189
172
|
|
|
190
|
-
|
|
191
|
-
exports["default"] = _default;
|
|
173
|
+
export default DragContent;
|
|
@@ -1,34 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.queryFileInfo = queryFileInfo;
|
|
7
|
-
exports.uploadChunk = uploadChunk;
|
|
8
|
-
exports.lockChunk = lockChunk;
|
|
9
|
-
|
|
10
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
1
|
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); } }
|
|
15
2
|
|
|
16
3
|
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); }); }; }
|
|
17
4
|
|
|
5
|
+
import axios from 'axios';
|
|
18
6
|
/**
|
|
19
7
|
* 查询文件上传情况
|
|
20
8
|
* @param {String} fileHash 文件内容Hash
|
|
21
9
|
* @param {String} fileName 文件名
|
|
22
10
|
* @param {Number} chunksLength 分片数量
|
|
23
11
|
*/
|
|
24
|
-
|
|
12
|
+
|
|
13
|
+
export function queryFileInfo(_ref) {
|
|
25
14
|
var fileHash = _ref.fileHash,
|
|
26
15
|
fileName = _ref.fileName,
|
|
27
16
|
size = _ref.size,
|
|
28
17
|
sizeStr = _ref.sizeStr,
|
|
29
18
|
chunksLength = _ref.chunksLength;
|
|
30
19
|
console.log('queryFileInfo ==> 查询文件上传情况');
|
|
31
|
-
return
|
|
20
|
+
return axios.get('/getFileInfo', {
|
|
32
21
|
params: {
|
|
33
22
|
fileHash: fileHash,
|
|
34
23
|
fileName: fileName,
|
|
@@ -48,20 +37,18 @@ function queryFileInfo(_ref) {
|
|
|
48
37
|
* @param {Blob} chunk 文件分片
|
|
49
38
|
*/
|
|
50
39
|
|
|
51
|
-
|
|
52
|
-
function uploadChunk(fileContentHash, chunkIndex, chunk) {
|
|
40
|
+
export function uploadChunk(fileContentHash, chunkIndex, chunk) {
|
|
53
41
|
var formData = new FormData();
|
|
54
42
|
formData.append('fileContentHash', fileContentHash);
|
|
55
43
|
formData.append('chunkIndex', chunkIndex);
|
|
56
44
|
formData.append('chunk', chunk);
|
|
57
|
-
return
|
|
45
|
+
return axios.post('/uploadChunk', formData).then(function (_ref3) {
|
|
58
46
|
var result = _ref3.data;
|
|
59
47
|
return result;
|
|
60
48
|
});
|
|
61
49
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return _axios["default"].post('/lockChunk', {
|
|
50
|
+
export function lockChunk(fileHash, chunkIndex) {
|
|
51
|
+
return axios.post('/lockChunk', {
|
|
65
52
|
fileHash: fileHash,
|
|
66
53
|
chunkIndex: chunkIndex
|
|
67
54
|
}).then( /*#__PURE__*/function () {
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = withUploader;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _lib = require("./lib");
|
|
15
|
-
|
|
16
|
-
var _api = require("./api");
|
|
17
|
-
|
|
18
|
-
var _uploadQueue = _interopRequireDefault(require("./upload-queue.class"));
|
|
19
|
-
|
|
20
|
-
require("./style/style.less");
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
-
|
|
24
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
25
|
-
|
|
26
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
1
|
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; }
|
|
29
2
|
|
|
30
3
|
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; }
|
|
@@ -59,15 +32,23 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
59
32
|
|
|
60
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
61
34
|
|
|
35
|
+
/* eslint-disable no-unused-vars */
|
|
36
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
37
|
+
import PropTypes from 'prop-types';
|
|
38
|
+
import { getComponentDisplayName, splitFileToChunks, calFileContentHash, bytesToSize, guid } from './lib';
|
|
39
|
+
import { queryFileInfo } from './api';
|
|
40
|
+
import UploadQueue from './upload-queue.class';
|
|
41
|
+
import './style/style.less';
|
|
62
42
|
/**
|
|
63
43
|
* 初始化组件
|
|
64
44
|
* @param {ReactComponent} component 本高阶组件
|
|
65
45
|
* @param {ReactComponent} WrappedComponent 被包装的具体实现组件
|
|
66
46
|
*/
|
|
47
|
+
|
|
67
48
|
function useComponentInit(component, WrappedComponent) {
|
|
68
49
|
var intervalIDArr = [];
|
|
69
50
|
|
|
70
|
-
var _useState =
|
|
51
|
+
var _useState = useState([]),
|
|
71
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
72
53
|
filesList = _useState2[0],
|
|
73
54
|
setFilesList = _useState2[1]; // 定义管理上传的列表
|
|
@@ -75,7 +56,7 @@ function useComponentInit(component, WrappedComponent) {
|
|
|
75
56
|
/* 定义上传队列,初始化就创建一个UploadQueue类实例 */
|
|
76
57
|
|
|
77
58
|
|
|
78
|
-
var _useState3 =
|
|
59
|
+
var _useState3 = useState(new UploadQueue({
|
|
79
60
|
/* 设立一个定时器,定时(根据hash)查询文件是否上传完成(因为后端需要把所有分片合并起来,因此需要一定的时间) */
|
|
80
61
|
fileFinishCb: function fileFinishCb(fileHash) {
|
|
81
62
|
/* 查询文件是否上传完成;是的话则更新状态,渲染上传结果 */
|
|
@@ -98,7 +79,7 @@ function useComponentInit(component, WrappedComponent) {
|
|
|
98
79
|
switch (_context3.prev = _context3.next) {
|
|
99
80
|
case 0:
|
|
100
81
|
_context3.next = 2;
|
|
101
|
-
return
|
|
82
|
+
return queryFileInfo({
|
|
102
83
|
fileHash: fileHash
|
|
103
84
|
});
|
|
104
85
|
|
|
@@ -191,23 +172,23 @@ function useComponentInit(component, WrappedComponent) {
|
|
|
191
172
|
_useState4 = _slicedToArray(_useState3, 1),
|
|
192
173
|
uploadQueue = _useState4[0];
|
|
193
174
|
|
|
194
|
-
|
|
175
|
+
useEffect(function () {
|
|
195
176
|
/* 定义displayName是为了在浏览器开发者工具里更好地显示高阶组件名称 */
|
|
196
|
-
component.displayName = "withUploader(".concat(
|
|
177
|
+
component.displayName = "withUploader(".concat(getComponentDisplayName(WrappedComponent), ")");
|
|
197
178
|
component.defaultProps = {
|
|
198
179
|
perChunkSize: 1024 * 512,
|
|
199
180
|
errorCb: function errorCb() {},
|
|
200
181
|
finishCb: function finishCb() {}
|
|
201
182
|
};
|
|
202
183
|
component.propTypes = {
|
|
203
|
-
perChunkSize:
|
|
204
|
-
errorCb:
|
|
205
|
-
finishCb:
|
|
184
|
+
perChunkSize: PropTypes.number,
|
|
185
|
+
errorCb: PropTypes.func,
|
|
186
|
+
finishCb: PropTypes.func
|
|
206
187
|
};
|
|
207
188
|
}, [component, WrappedComponent]);
|
|
208
189
|
/* 清理所有定时器 */
|
|
209
190
|
|
|
210
|
-
|
|
191
|
+
useEffect(function () {
|
|
211
192
|
return function () {
|
|
212
193
|
intervalIDArr.forEach(function (intervalID) {
|
|
213
194
|
return clearInterval(intervalID);
|
|
@@ -228,13 +209,13 @@ function useComponentInit(component, WrappedComponent) {
|
|
|
228
209
|
|
|
229
210
|
function initFilesListState(file) {
|
|
230
211
|
var fileInfo = {
|
|
231
|
-
hash:
|
|
212
|
+
hash: guid(),
|
|
232
213
|
// 用uuid来假装hash
|
|
233
214
|
fileName: file.name,
|
|
234
215
|
status: 'init',
|
|
235
216
|
publicPath: '',
|
|
236
217
|
size: file.size,
|
|
237
|
-
sizeStr:
|
|
218
|
+
sizeStr: bytesToSize(file.size) // 转换当前字节数
|
|
238
219
|
|
|
239
220
|
};
|
|
240
221
|
this.setFilesList([].concat(_toConsumableArray(this.filesList), [fileInfo]));
|
|
@@ -304,10 +285,10 @@ function returnFileInputChangeCb(_ref3) {
|
|
|
304
285
|
file = event.target.files[0];
|
|
305
286
|
currentFileInfo = initFilesListState.call(_this, file);
|
|
306
287
|
console.log('当前已选择需要上传的文件', file);
|
|
307
|
-
chunksArr =
|
|
288
|
+
chunksArr = splitFileToChunks(file, perChunkSize); // 文件分片
|
|
308
289
|
|
|
309
290
|
_context4.next = 6;
|
|
310
|
-
return
|
|
291
|
+
return calFileContentHash(chunksArr);
|
|
311
292
|
|
|
312
293
|
case 6:
|
|
313
294
|
fileContentHash = _context4.sent;
|
|
@@ -328,7 +309,7 @@ function returnFileInputChangeCb(_ref3) {
|
|
|
328
309
|
/* 查询该文件上传情况 */
|
|
329
310
|
|
|
330
311
|
_context4.next = 12;
|
|
331
|
-
return
|
|
312
|
+
return queryFileInfo(_objectSpread(_objectSpread({}, currentFileInfo), {}, {
|
|
332
313
|
fileHash: fileContentHash,
|
|
333
314
|
chunksLength: chunksArr.length
|
|
334
315
|
}));
|
|
@@ -377,13 +358,13 @@ function returnFileInputChangeCb(_ref3) {
|
|
|
377
358
|
*/
|
|
378
359
|
|
|
379
360
|
|
|
380
|
-
function withUploader(WrappedComponent) {
|
|
361
|
+
export default function withUploader(WrappedComponent) {
|
|
381
362
|
return function UploaderHoc(props) {
|
|
382
363
|
var perChunkSize = props.perChunkSize,
|
|
383
364
|
errorCb = props.errorCb,
|
|
384
365
|
restProps = _objectWithoutProperties(props, ["perChunkSize", "errorCb"]);
|
|
385
366
|
|
|
386
|
-
var fileInputRef =
|
|
367
|
+
var fileInputRef = useRef(null);
|
|
387
368
|
var state = useComponentInit(UploaderHoc, WrappedComponent);
|
|
388
369
|
/* 组装传给具体实现组件的props */
|
|
389
370
|
|
|
@@ -395,9 +376,9 @@ function withUploader(WrappedComponent) {
|
|
|
395
376
|
filesList: state.filesList
|
|
396
377
|
});
|
|
397
378
|
|
|
398
|
-
return /*#__PURE__*/
|
|
379
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
399
380
|
className: "upload-hoc"
|
|
400
|
-
}, /*#__PURE__*/
|
|
381
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
401
382
|
ref: fileInputRef,
|
|
402
383
|
type: "file",
|
|
403
384
|
className: "upload-hoc_file-input",
|
|
@@ -405,6 +386,6 @@ function withUploader(WrappedComponent) {
|
|
|
405
386
|
perChunkSize: perChunkSize,
|
|
406
387
|
errorCb: errorCb
|
|
407
388
|
})
|
|
408
|
-
}), /*#__PURE__*/
|
|
389
|
+
}), /*#__PURE__*/React.createElement(WrappedComponent, spreadProps));
|
|
409
390
|
};
|
|
410
391
|
}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getComponentDisplayName = getComponentDisplayName;
|
|
7
|
-
exports.splitFileToChunks = splitFileToChunks;
|
|
8
|
-
exports.calFileContentHash = calFileContentHash;
|
|
9
|
-
exports.bytesToSize = bytesToSize;
|
|
10
|
-
exports.guid = guid;
|
|
11
|
-
|
|
12
|
-
var _worker = _interopRequireDefault(require("worker-loader!./worker.js"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
1
|
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); } }
|
|
17
2
|
|
|
18
3
|
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); }); }; }
|
|
19
4
|
|
|
20
|
-
//
|
|
5
|
+
// eslint-disable-next-line import/no-webpack-loader-syntax
|
|
6
|
+
import Worker from 'worker-loader!./worker.js'; // 启动 Web Worker
|
|
21
7
|
|
|
22
8
|
/**
|
|
23
9
|
* 获取组件名称
|
|
24
10
|
* @param {ReactComponent} component
|
|
25
11
|
*/
|
|
26
|
-
|
|
12
|
+
|
|
13
|
+
export function getComponentDisplayName(component) {
|
|
27
14
|
return component.displayName || component.name || 'Component';
|
|
28
15
|
}
|
|
29
16
|
/**
|
|
@@ -31,8 +18,7 @@ function getComponentDisplayName(component) {
|
|
|
31
18
|
* @param {File} file 文件
|
|
32
19
|
*/
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
function splitFileToChunks(file, perChunkSize) {
|
|
21
|
+
export function splitFileToChunks(file, perChunkSize) {
|
|
36
22
|
var fileSize = file.size;
|
|
37
23
|
var total = Math.ceil(fileSize / perChunkSize); // 计算总共要分多少片
|
|
38
24
|
|
|
@@ -50,8 +36,7 @@ function splitFileToChunks(file, perChunkSize) {
|
|
|
50
36
|
* @param {File} file 文件
|
|
51
37
|
*/
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
function calFileContentHash(_x) {
|
|
39
|
+
export function calFileContentHash(_x) {
|
|
55
40
|
return _calFileContentHash.apply(this, arguments);
|
|
56
41
|
}
|
|
57
42
|
/**
|
|
@@ -60,7 +45,6 @@ function calFileContentHash(_x) {
|
|
|
60
45
|
* @param {Number} precise 小数精度
|
|
61
46
|
*/
|
|
62
47
|
|
|
63
|
-
|
|
64
48
|
function _calFileContentHash() {
|
|
65
49
|
_calFileContentHash = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(chunksArr) {
|
|
66
50
|
var worker;
|
|
@@ -68,7 +52,7 @@ function _calFileContentHash() {
|
|
|
68
52
|
while (1) {
|
|
69
53
|
switch (_context.prev = _context.next) {
|
|
70
54
|
case 0:
|
|
71
|
-
worker = new
|
|
55
|
+
worker = new Worker();
|
|
72
56
|
worker.postMessage({
|
|
73
57
|
chunksArr: chunksArr
|
|
74
58
|
}); // 传递文件分片
|
|
@@ -91,7 +75,7 @@ function _calFileContentHash() {
|
|
|
91
75
|
return _calFileContentHash.apply(this, arguments);
|
|
92
76
|
}
|
|
93
77
|
|
|
94
|
-
function bytesToSize(bytes) {
|
|
78
|
+
export function bytesToSize(bytes) {
|
|
95
79
|
var precise = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
96
80
|
if (bytes === 0) return '0 B';
|
|
97
81
|
var k = 1024,
|
|
@@ -103,8 +87,7 @@ function bytesToSize(bytes) {
|
|
|
103
87
|
* 生成guid
|
|
104
88
|
*/
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
function guid() {
|
|
90
|
+
export function guid() {
|
|
108
91
|
function S4() {
|
|
109
92
|
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
|
110
93
|
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _api = require("./api");
|
|
9
|
-
|
|
10
1
|
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); } }
|
|
11
2
|
|
|
12
3
|
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); }); }; }
|
|
@@ -31,6 +22,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
31
22
|
|
|
32
23
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
24
|
|
|
25
|
+
import { lockChunk, uploadChunk } from './api';
|
|
26
|
+
|
|
34
27
|
var UploadQueue = /*#__PURE__*/function () {
|
|
35
28
|
// 上传任务队列存储
|
|
36
29
|
// 是否正在上传
|
|
@@ -122,7 +115,7 @@ var UploadQueue = /*#__PURE__*/function () {
|
|
|
122
115
|
/* 给分片加锁,避免多个客户端上传同一个分片 */
|
|
123
116
|
|
|
124
117
|
_context.next = 7;
|
|
125
|
-
return
|
|
118
|
+
return lockChunk(fileHash, chunkIndex);
|
|
126
119
|
|
|
127
120
|
case 7:
|
|
128
121
|
lockResult = _context.sent;
|
|
@@ -133,7 +126,7 @@ var UploadQueue = /*#__PURE__*/function () {
|
|
|
133
126
|
}
|
|
134
127
|
|
|
135
128
|
_context.next = 11;
|
|
136
|
-
return
|
|
129
|
+
return uploadChunk(fileHash, chunkIndex, chunk);
|
|
137
130
|
|
|
138
131
|
case 11:
|
|
139
132
|
console.log('请求接口uploadChunk=>上传分片文件,执行任务数递减', this.tasksSizePerFile);
|
|
@@ -171,4 +164,4 @@ var UploadQueue = /*#__PURE__*/function () {
|
|
|
171
164
|
return UploadQueue;
|
|
172
165
|
}();
|
|
173
166
|
|
|
174
|
-
|
|
167
|
+
export { UploadQueue as default };
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _sparkMd = _interopRequireDefault(require("spark-md5"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
|
|
7
1
|
/* eslint-disable no-restricted-globals */
|
|
2
|
+
import SparkMD5 from 'spark-md5';
|
|
8
3
|
self.addEventListener('message', function (e) {
|
|
9
4
|
var chunksArr = e.data.chunksArr; // 收到主线程传递来的文件分片
|
|
10
5
|
|
|
11
6
|
console.log('监听\'message\'收到主线程传递来的文件分片', chunksArr);
|
|
12
|
-
var spark = new
|
|
7
|
+
var spark = new SparkMD5.ArrayBuffer();
|
|
13
8
|
var fileReader = new FileReader();
|
|
14
9
|
fileReader.readAsArrayBuffer(chunksArr.pop());
|
|
15
10
|
console.log('创建文件读取', fileReader);
|
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
require("antd/es/button/style");
|
|
11
|
-
|
|
12
|
-
var _button = _interopRequireDefault(require("antd/es/button"));
|
|
13
|
-
|
|
14
|
-
require("antd/es/input/style");
|
|
15
|
-
|
|
16
|
-
var _input = _interopRequireDefault(require("antd/es/input"));
|
|
17
|
-
|
|
18
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
|
-
|
|
22
|
-
var _icons = require("@ant-design/icons");
|
|
23
|
-
|
|
24
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
25
|
-
|
|
26
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
3
|
+
import "antd/es/button/style";
|
|
4
|
+
import _Button from "antd/es/button";
|
|
5
|
+
import "antd/es/input/style";
|
|
6
|
+
import _Input from "antd/es/input";
|
|
29
7
|
|
|
30
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
9
|
|
|
@@ -43,10 +21,14 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
43
21
|
|
|
44
22
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
23
|
|
|
46
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
24
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
25
|
|
|
48
26
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
27
|
|
|
28
|
+
import React, { Component } from 'react';
|
|
29
|
+
import classNames from 'classnames';
|
|
30
|
+
import { PlusOutlined } from '@ant-design/icons';
|
|
31
|
+
|
|
50
32
|
var EditButton = /*#__PURE__*/function (_Component) {
|
|
51
33
|
_inherits(EditButton, _Component);
|
|
52
34
|
|
|
@@ -108,7 +90,7 @@ var EditButton = /*#__PURE__*/function (_Component) {
|
|
|
108
90
|
size = _this$props2$size === void 0 ? 'middle' : _this$props2$size,
|
|
109
91
|
label = _this$props2.label,
|
|
110
92
|
_this$props2$icon = _this$props2.icon,
|
|
111
|
-
icon = _this$props2$icon === void 0 ? /*#__PURE__*/
|
|
93
|
+
icon = _this$props2$icon === void 0 ? /*#__PURE__*/React.createElement(PlusOutlined, null) : _this$props2$icon,
|
|
112
94
|
style = _this$props2.style,
|
|
113
95
|
className = _this$props2.className,
|
|
114
96
|
disabled = _this$props2.disabled,
|
|
@@ -117,14 +99,14 @@ var EditButton = /*#__PURE__*/function (_Component) {
|
|
|
117
99
|
var _this$state = this.state,
|
|
118
100
|
inputValue = _this$state.inputValue,
|
|
119
101
|
inputVisible = _this$state.inputVisible;
|
|
120
|
-
return /*#__PURE__*/
|
|
102
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
121
103
|
style: Object.assign({
|
|
122
104
|
display: 'inline-block',
|
|
123
105
|
width: "".concat(width, "px"),
|
|
124
106
|
verticalAlign: 'middle'
|
|
125
107
|
}, style),
|
|
126
|
-
className: (
|
|
127
|
-
}, inputVisible ? /*#__PURE__*/
|
|
108
|
+
className: classNames(className, 'spec-edit-button')
|
|
109
|
+
}, inputVisible ? /*#__PURE__*/React.createElement(_Input, {
|
|
128
110
|
ref: this.saveInputRef,
|
|
129
111
|
type: "text",
|
|
130
112
|
size: size,
|
|
@@ -139,7 +121,7 @@ var EditButton = /*#__PURE__*/function (_Component) {
|
|
|
139
121
|
onPressEnter: function onPressEnter() {
|
|
140
122
|
return _this2.handleInputConfirm();
|
|
141
123
|
}
|
|
142
|
-
}) : /*#__PURE__*/
|
|
124
|
+
}) : /*#__PURE__*/React.createElement(_Button, {
|
|
143
125
|
disabled: disabled,
|
|
144
126
|
icon: icon,
|
|
145
127
|
size: size,
|
|
@@ -153,7 +135,6 @@ var EditButton = /*#__PURE__*/function (_Component) {
|
|
|
153
135
|
}]);
|
|
154
136
|
|
|
155
137
|
return EditButton;
|
|
156
|
-
}(
|
|
138
|
+
}(Component);
|
|
157
139
|
|
|
158
|
-
|
|
159
|
-
exports["default"] = _default;
|
|
140
|
+
export default EditButton;
|