fan-standard-comp 3.1.2 → 3.1.4

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 (244) hide show
  1. package/package.json +1 -1
  2. package/dist/f26952c118ab6cdcd23dc0028ee98c11.svg +0 -173
  3. package/dist/fan-standard-comp.umd.js +0 -597
  4. package/dist/fonts/iconfont.eot +0 -0
  5. package/dist/fonts/iconfont.ttf +0 -0
  6. package/dist/fonts/iconfont.woff +0 -0
  7. package/es/ButtonGroup/ButtonList.d.ts +0 -2
  8. package/es/ButtonGroup/ButtonList.js +0 -37
  9. package/es/ButtonGroup/ButtonMenu.d.ts +0 -2
  10. package/es/ButtonGroup/ButtonMenu.js +0 -38
  11. package/es/ButtonGroup/PopConfirmTitle.d.ts +0 -9
  12. package/es/ButtonGroup/PopConfirmTitle.js +0 -37
  13. package/es/ButtonGroup/index.d.ts +0 -30
  14. package/es/ButtonGroup/index.js +0 -374
  15. package/es/ButtonGroup/style/index.less +0 -36
  16. package/es/DragContent/DragBar.js +0 -21
  17. package/es/DragContent/index.d.ts +0 -14
  18. package/es/DragContent/index.js +0 -173
  19. package/es/DragContent/index.less +0 -44
  20. package/es/FormComp/ChunkUploader/api.js +0 -76
  21. package/es/FormComp/ChunkUploader/index.js +0 -391
  22. package/es/FormComp/ChunkUploader/lib.js +0 -96
  23. package/es/FormComp/ChunkUploader/style/style.less +0 -3
  24. package/es/FormComp/ChunkUploader/upload-queue.class.js +0 -167
  25. package/es/FormComp/ChunkUploader/worker.js +0 -23
  26. package/es/FormComp/EditButton/index.d.ts +0 -26
  27. package/es/FormComp/EditButton/index.js +0 -140
  28. package/es/FormComp/FieldComponent/ReUpload.d.ts +0 -3
  29. package/es/FormComp/FieldComponent/ReUpload.js +0 -131
  30. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +0 -245
  31. package/es/FormComp/FieldComponent/TitleNode.d.ts +0 -6
  32. package/es/FormComp/FieldComponent/TitleNode.js +0 -9
  33. package/es/FormComp/FieldComponent/index.d.ts +0 -38
  34. package/es/FormComp/FieldComponent/index.js +0 -413
  35. package/es/FormComp/FieldComponent/setReadonlyValues.js +0 -236
  36. package/es/FormComp/FieldComponent/style/index.less +0 -116
  37. package/es/FormComp/RenderItemGroup/index.d.ts +0 -37
  38. package/es/FormComp/RenderItemGroup/index.js +0 -234
  39. package/es/FormComp/Uploader/index.d.ts +0 -19
  40. package/es/FormComp/Uploader/index.js +0 -275
  41. package/es/FormComp/Uploader/style/index.less +0 -14
  42. package/es/FormComp/Uploader/util.d.ts +0 -8
  43. package/es/FormComp/Uploader/util.js +0 -38
  44. package/es/FormComp/VarTemplate/index.js +0 -293
  45. package/es/FormComp/index.d.ts +0 -1
  46. package/es/FormComp/index.js +0 -1
  47. package/es/NavLeafScroll/index.js +0 -379
  48. package/es/NavLeafScroll/style/index.less +0 -119
  49. package/es/RefactorTree/data.d.ts +0 -7
  50. package/es/RefactorTree/index.d.ts +0 -40
  51. package/es/RefactorTree/index.js +0 -167
  52. package/es/RefactorTree/indexTreeNode.d.ts +0 -39
  53. package/es/RefactorTree/indexTreeNode.js +0 -237
  54. package/es/RefactorTree/style/index.d.ts +0 -1
  55. package/es/RefactorTree/style/index.js +0 -1
  56. package/es/RefactorTree/style/index.less +0 -22
  57. package/es/RefactorTree/util.d.ts +0 -42
  58. package/es/RefactorTree/util.js +0 -187
  59. package/es/SpecIcon/fonts/demo.css +0 -539
  60. package/es/SpecIcon/fonts/demo_index.html +0 -1315
  61. package/es/SpecIcon/fonts/iconfont.css +0 -211
  62. package/es/SpecIcon/fonts/iconfont.eot +0 -0
  63. package/es/SpecIcon/fonts/iconfont.js +0 -41
  64. package/es/SpecIcon/fonts/iconfont.json +0 -352
  65. package/es/SpecIcon/fonts/iconfont.svg +0 -173
  66. package/es/SpecIcon/fonts/iconfont.ttf +0 -0
  67. package/es/SpecIcon/fonts/iconfont.woff +0 -0
  68. package/es/SpecIcon/fonts/iconfont.woff2 +0 -0
  69. package/es/SpecIcon/index.d.ts +0 -17
  70. package/es/SpecIcon/index.js +0 -77
  71. package/es/SpecIcon/style/iconfont.less +0 -213
  72. package/es/SpecIcon/style/index.less +0 -98
  73. package/es/SplitterLayout/Pane.d.ts +0 -13
  74. package/es/SplitterLayout/Pane.js +0 -36
  75. package/es/SplitterLayout/index.js +0 -375
  76. package/es/SplitterLayout/index.less +0 -58
  77. package/es/StandardContent/SplitterLayout/Pane.js +0 -50
  78. package/es/StandardContent/SplitterLayout/index.js +0 -374
  79. package/es/StandardContent/SplitterLayout/index.less +0 -58
  80. package/es/StandardContent/SubfieldContent.d.ts +0 -17
  81. package/es/StandardContent/SubfieldContent.js +0 -41
  82. package/es/StandardContent/WrapperContent.d.ts +0 -13
  83. package/es/StandardContent/WrapperContent.js +0 -29
  84. package/es/StandardContent/data.d.ts +0 -101
  85. package/es/StandardContent/style/index.less +0 -80
  86. package/es/StandardDragModal/index.d.ts +0 -11
  87. package/es/StandardDragModal/index.js +0 -30
  88. package/es/StandardFilter/index.d.ts +0 -35
  89. package/es/StandardFilter/index.js +0 -253
  90. package/es/StandardFilter/style/index.less +0 -62
  91. package/es/StandardForm/ActionList.js +0 -44
  92. package/es/StandardForm/StepForm.d.ts +0 -19
  93. package/es/StandardForm/StepForm.js +0 -267
  94. package/es/StandardForm/TabForm.d.ts +0 -19
  95. package/es/StandardForm/TabForm.js +0 -122
  96. package/es/StandardForm/index.d.ts +0 -32
  97. package/es/StandardForm/index.js +0 -170
  98. package/es/StandardForm/style/index.less +0 -58
  99. package/es/StandardModal/UpdateFormRef.js +0 -18
  100. package/es/StandardModal/index.d.ts +0 -44
  101. package/es/StandardModal/index.js +0 -495
  102. package/es/StandardModal/style/index.less +0 -50
  103. package/es/StandardPanel/index.d.ts +0 -28
  104. package/es/StandardPanel/index.js +0 -134
  105. package/es/StandardPanel/style/index.less +0 -135
  106. package/es/StandardTable/index.d.ts +0 -22
  107. package/es/StandardTable/index.js +0 -126
  108. package/es/StandardTable/style/index.d.ts +0 -1
  109. package/es/StandardTable/style/index.js +0 -1
  110. package/es/StandardTable/style/index.less +0 -206
  111. package/es/components/IconNode/index.d.ts +0 -16
  112. package/es/components/IconNode/index.js +0 -28
  113. package/es/components/index.d.ts +0 -2
  114. package/es/components/index.js +0 -2
  115. package/es/data/func.code.js +0 -112
  116. package/es/data/general.config.js +0 -172
  117. package/es/data/index.js +0 -3
  118. package/es/index.d.ts +0 -24
  119. package/es/index.js +0 -31
  120. package/es/styles/index.less +0 -0
  121. package/es/theme/spec-variable.less +0 -48
  122. package/es/utils/ValueFormat.js +0 -50
  123. package/es/utils/filterPermission.js +0 -111
  124. package/es/utils/getParentNodes.js +0 -215
  125. package/es/utils/index.js +0 -3
  126. package/lib/ButtonGroup/ButtonList.d.ts +0 -2
  127. package/lib/ButtonGroup/ButtonList.js +0 -55
  128. package/lib/ButtonGroup/ButtonMenu.d.ts +0 -2
  129. package/lib/ButtonGroup/ButtonMenu.js +0 -51
  130. package/lib/ButtonGroup/PopConfirmTitle.d.ts +0 -9
  131. package/lib/ButtonGroup/PopConfirmTitle.js +0 -48
  132. package/lib/ButtonGroup/index.d.ts +0 -30
  133. package/lib/ButtonGroup/index.js +0 -405
  134. package/lib/ButtonGroup/style/index.less +0 -36
  135. package/lib/DragContent/DragBar.js +0 -33
  136. package/lib/DragContent/index.d.ts +0 -14
  137. package/lib/DragContent/index.js +0 -191
  138. package/lib/DragContent/index.less +0 -44
  139. package/lib/FormComp/ChunkUploader/api.js +0 -89
  140. package/lib/FormComp/ChunkUploader/index.js +0 -410
  141. package/lib/FormComp/ChunkUploader/lib.js +0 -113
  142. package/lib/FormComp/ChunkUploader/style/style.less +0 -3
  143. package/lib/FormComp/ChunkUploader/upload-queue.class.js +0 -174
  144. package/lib/FormComp/ChunkUploader/worker.js +0 -28
  145. package/lib/FormComp/EditButton/index.d.ts +0 -26
  146. package/lib/FormComp/EditButton/index.js +0 -159
  147. package/lib/FormComp/FieldComponent/ReUpload.d.ts +0 -3
  148. package/lib/FormComp/FieldComponent/ReUpload.js +0 -151
  149. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +0 -268
  150. package/lib/FormComp/FieldComponent/TitleNode.d.ts +0 -6
  151. package/lib/FormComp/FieldComponent/TitleNode.js +0 -19
  152. package/lib/FormComp/FieldComponent/index.d.ts +0 -38
  153. package/lib/FormComp/FieldComponent/index.js +0 -457
  154. package/lib/FormComp/FieldComponent/setReadonlyValues.js +0 -263
  155. package/lib/FormComp/FieldComponent/style/index.less +0 -116
  156. package/lib/FormComp/RenderItemGroup/index.d.ts +0 -37
  157. package/lib/FormComp/RenderItemGroup/index.js +0 -255
  158. package/lib/FormComp/Uploader/index.d.ts +0 -19
  159. package/lib/FormComp/Uploader/index.js +0 -301
  160. package/lib/FormComp/Uploader/style/index.less +0 -14
  161. package/lib/FormComp/Uploader/util.d.ts +0 -8
  162. package/lib/FormComp/Uploader/util.js +0 -47
  163. package/lib/FormComp/VarTemplate/index.js +0 -308
  164. package/lib/FormComp/index.d.ts +0 -1
  165. package/lib/FormComp/index.js +0 -15
  166. package/lib/NavLeafScroll/index.js +0 -397
  167. package/lib/NavLeafScroll/style/index.less +0 -119
  168. package/lib/RefactorTree/data.d.ts +0 -7
  169. package/lib/RefactorTree/index.d.ts +0 -40
  170. package/lib/RefactorTree/index.js +0 -190
  171. package/lib/RefactorTree/indexTreeNode.d.ts +0 -39
  172. package/lib/RefactorTree/indexTreeNode.js +0 -260
  173. package/lib/RefactorTree/style/index.d.ts +0 -1
  174. package/lib/RefactorTree/style/index.js +0 -3
  175. package/lib/RefactorTree/style/index.less +0 -22
  176. package/lib/RefactorTree/util.d.ts +0 -42
  177. package/lib/RefactorTree/util.js +0 -195
  178. package/lib/SpecIcon/fonts/demo.css +0 -539
  179. package/lib/SpecIcon/fonts/demo_index.html +0 -1315
  180. package/lib/SpecIcon/fonts/iconfont.css +0 -211
  181. package/lib/SpecIcon/fonts/iconfont.eot +0 -0
  182. package/lib/SpecIcon/fonts/iconfont.js +0 -43
  183. package/lib/SpecIcon/fonts/iconfont.json +0 -352
  184. package/lib/SpecIcon/fonts/iconfont.svg +0 -173
  185. package/lib/SpecIcon/fonts/iconfont.ttf +0 -0
  186. package/lib/SpecIcon/fonts/iconfont.woff +0 -0
  187. package/lib/SpecIcon/fonts/iconfont.woff2 +0 -0
  188. package/lib/SpecIcon/index.d.ts +0 -17
  189. package/lib/SpecIcon/index.js +0 -90
  190. package/lib/SpecIcon/style/iconfont.less +0 -213
  191. package/lib/SpecIcon/style/index.less +0 -98
  192. package/lib/SplitterLayout/Pane.d.ts +0 -13
  193. package/lib/SplitterLayout/Pane.js +0 -48
  194. package/lib/SplitterLayout/index.js +0 -386
  195. package/lib/SplitterLayout/index.less +0 -58
  196. package/lib/StandardContent/SplitterLayout/Pane.js +0 -62
  197. package/lib/StandardContent/SplitterLayout/index.js +0 -387
  198. package/lib/StandardContent/SplitterLayout/index.less +0 -58
  199. package/lib/StandardContent/SubfieldContent.d.ts +0 -17
  200. package/lib/StandardContent/SubfieldContent.js +0 -56
  201. package/lib/StandardContent/WrapperContent.d.ts +0 -13
  202. package/lib/StandardContent/WrapperContent.js +0 -43
  203. package/lib/StandardContent/data.d.ts +0 -101
  204. package/lib/StandardContent/style/index.less +0 -80
  205. package/lib/StandardDragModal/index.d.ts +0 -11
  206. package/lib/StandardDragModal/index.js +0 -43
  207. package/lib/StandardFilter/index.d.ts +0 -35
  208. package/lib/StandardFilter/index.js +0 -272
  209. package/lib/StandardFilter/style/index.less +0 -62
  210. package/lib/StandardForm/ActionList.js +0 -57
  211. package/lib/StandardForm/StepForm.d.ts +0 -19
  212. package/lib/StandardForm/StepForm.js +0 -295
  213. package/lib/StandardForm/TabForm.d.ts +0 -19
  214. package/lib/StandardForm/TabForm.js +0 -148
  215. package/lib/StandardForm/index.d.ts +0 -32
  216. package/lib/StandardForm/index.js +0 -197
  217. package/lib/StandardForm/style/index.less +0 -58
  218. package/lib/StandardModal/UpdateFormRef.js +0 -32
  219. package/lib/StandardModal/index.d.ts +0 -44
  220. package/lib/StandardModal/index.js +0 -525
  221. package/lib/StandardModal/style/index.less +0 -50
  222. package/lib/StandardPanel/index.d.ts +0 -28
  223. package/lib/StandardPanel/index.js +0 -155
  224. package/lib/StandardPanel/style/index.less +0 -135
  225. package/lib/StandardTable/index.d.ts +0 -22
  226. package/lib/StandardTable/index.js +0 -143
  227. package/lib/StandardTable/style/index.d.ts +0 -1
  228. package/lib/StandardTable/style/index.js +0 -3
  229. package/lib/StandardTable/style/index.less +0 -206
  230. package/lib/components/IconNode/index.d.ts +0 -16
  231. package/lib/components/IconNode/index.js +0 -39
  232. package/lib/components/index.d.ts +0 -2
  233. package/lib/components/index.js +0 -15
  234. package/lib/data/func.code.js +0 -119
  235. package/lib/data/general.config.js +0 -179
  236. package/lib/data/index.js +0 -23
  237. package/lib/index.d.ts +0 -24
  238. package/lib/index.js +0 -236
  239. package/lib/styles/index.less +0 -0
  240. package/lib/theme/spec-variable.less +0 -48
  241. package/lib/utils/ValueFormat.js +0 -58
  242. package/lib/utils/filterPermission.js +0 -127
  243. package/lib/utils/getParentNodes.js +0 -226
  244. package/lib/utils/index.js +0 -35
@@ -1,44 +0,0 @@
1
- @root-entry-name: default;
2
- @import (reference) '~antd/es/style/themes/index';
3
-
4
-
5
- .spec-grid-dragContent{
6
- position: relative;
7
- // padding: 5px;
8
-
9
- .spec-grid-dragbar-left-horizontal{
10
- height: 100%;
11
- width: 5px;
12
- position: absolute;
13
- left: 0;
14
- top: 0;
15
- cursor: col-resize;
16
-
17
- }
18
- .spec-grid-dragbar-right-horizontal{
19
- height: 100%;
20
- width: 5px;
21
- position: absolute;
22
- right: 0;
23
- top: 0;
24
- cursor: col-resize;
25
- }
26
- .spec-grid-dragbar-up-vertical{
27
- height: 5px;
28
- width: 100%;
29
- position: absolute;
30
- left: 0;
31
- top: 0;
32
- cursor: row-resize;
33
- }
34
- .spec-grid-dragbar-down-vertical{
35
- height: 5px;
36
- width: 100%;
37
- position: absolute;
38
- left: 0;
39
- bottom: 0;
40
- cursor: row-resize;
41
- }
42
- }
43
-
44
-
@@ -1,89 +0,0 @@
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
- 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
-
16
- 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
-
18
- /**
19
- * 查询文件上传情况
20
- * @param {String} fileHash 文件内容Hash
21
- * @param {String} fileName 文件名
22
- * @param {Number} chunksLength 分片数量
23
- */
24
- function queryFileInfo(_ref) {
25
- var fileHash = _ref.fileHash,
26
- fileName = _ref.fileName,
27
- size = _ref.size,
28
- sizeStr = _ref.sizeStr,
29
- chunksLength = _ref.chunksLength;
30
- console.log('queryFileInfo ==> 查询文件上传情况');
31
- return _axios.default.get('/getFileInfo', {
32
- params: {
33
- fileHash: fileHash,
34
- fileName: fileName,
35
- size: size,
36
- sizeStr: sizeStr,
37
- chunksLength: chunksLength
38
- }
39
- }).then(function (_ref2) {
40
- var data = _ref2.data;
41
- return data;
42
- });
43
- }
44
- /**
45
- * 上传文件分片
46
- * @param {String} fileContentHash 文件的Hash
47
- * @param {Number} chunkIndex 分片序号
48
- * @param {Blob} chunk 文件分片
49
- */
50
-
51
-
52
- function uploadChunk(fileContentHash, chunkIndex, chunk) {
53
- var formData = new FormData();
54
- formData.append('fileContentHash', fileContentHash);
55
- formData.append('chunkIndex', chunkIndex);
56
- formData.append('chunk', chunk);
57
- return _axios.default.post('/uploadChunk', formData).then(function (_ref3) {
58
- var result = _ref3.data;
59
- return result;
60
- });
61
- }
62
-
63
- function lockChunk(fileHash, chunkIndex) {
64
- return _axios.default.post('/lockChunk', {
65
- fileHash: fileHash,
66
- chunkIndex: chunkIndex
67
- }).then( /*#__PURE__*/function () {
68
- var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref4) {
69
- var result;
70
- return regeneratorRuntime.wrap(function _callee$(_context) {
71
- while (1) {
72
- switch (_context.prev = _context.next) {
73
- case 0:
74
- result = _ref4.data;
75
- return _context.abrupt("return", result);
76
-
77
- case 2:
78
- case "end":
79
- return _context.stop();
80
- }
81
- }
82
- }, _callee);
83
- }));
84
-
85
- return function (_x) {
86
- return _ref5.apply(this, arguments);
87
- };
88
- }());
89
- }
@@ -1,410 +0,0 @@
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
- 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
-
30
- 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; }
31
-
32
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
33
-
34
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
35
-
36
- 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; }
37
-
38
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
39
-
40
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
41
-
42
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
43
-
44
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
45
-
46
- 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); } }
47
-
48
- 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); }); }; }
49
-
50
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
51
-
52
- 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."); }
53
-
54
- 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); }
55
-
56
- 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; }
57
-
58
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
59
-
60
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
61
-
62
- /**
63
- * 初始化组件
64
- * @param {ReactComponent} component 本高阶组件
65
- * @param {ReactComponent} WrappedComponent 被包装的具体实现组件
66
- */
67
- function useComponentInit(component, WrappedComponent) {
68
- var intervalIDArr = [];
69
-
70
- var _useState = (0, _react.useState)([]),
71
- _useState2 = _slicedToArray(_useState, 2),
72
- filesList = _useState2[0],
73
- setFilesList = _useState2[1]; // 定义管理上传的列表
74
-
75
- /* 定义上传队列,初始化就创建一个UploadQueue类实例 */
76
-
77
-
78
- var _useState3 = (0, _react.useState)(new _uploadQueue.default({
79
- /* 设立一个定时器,定时(根据hash)查询文件是否上传完成(因为后端需要把所有分片合并起来,因此需要一定的时间) */
80
- fileFinishCb: function fileFinishCb(fileHash) {
81
- /* 查询文件是否上传完成;是的话则更新状态,渲染上传结果 */
82
- console.log('调用=》fileFinishCb==》查询文件是否上传完成;是的话则更新状态,渲染上传结果');
83
-
84
- function checkIfFinish() {
85
- return _checkIfFinish.apply(this, arguments);
86
- }
87
- /*
88
- 第一次定时器会很快触发,这是针对小文件,争取尽快渲染上传结果
89
- 之后的定时器则是针对较大的文件,以较大的时间间隔来触发查询
90
- */
91
-
92
-
93
- function _checkIfFinish() {
94
- _checkIfFinish = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
95
- var remoteFileInfo;
96
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
97
- while (1) {
98
- switch (_context3.prev = _context3.next) {
99
- case 0:
100
- _context3.next = 2;
101
- return (0, _api.queryFileInfo)({
102
- fileHash: fileHash
103
- });
104
-
105
- case 2:
106
- remoteFileInfo = _context3.sent;
107
- console.log('请求接口queryFileInfo=》 完成分片上传后,更新上传状态');
108
-
109
- if (!(remoteFileInfo.status === 'finish')) {
110
- _context3.next = 7;
111
- break;
112
- }
113
-
114
- updateFileInfo.call({
115
- filesList: filesList,
116
- setFilesList: setFilesList
117
- }, fileHash, {
118
- status: remoteFileInfo.status,
119
- url: remoteFileInfo.publicPath
120
- });
121
- return _context3.abrupt("return", true);
122
-
123
- case 7:
124
- console.log('更新上传状态==》remoteFileInfo', remoteFileInfo);
125
- return _context3.abrupt("return", false);
126
-
127
- case 9:
128
- case "end":
129
- return _context3.stop();
130
- }
131
- }
132
- }, _callee3);
133
- }));
134
- return _checkIfFinish.apply(this, arguments);
135
- }
136
-
137
- setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
138
- var intervalID;
139
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
140
- while (1) {
141
- switch (_context2.prev = _context2.next) {
142
- case 0:
143
- _context2.next = 2;
144
- return checkIfFinish();
145
-
146
- case 2:
147
- _context2.t0 = _context2.sent;
148
-
149
- if (!(_context2.t0 === false)) {
150
- _context2.next = 6;
151
- break;
152
- }
153
-
154
- intervalID = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
155
- return regeneratorRuntime.wrap(function _callee$(_context) {
156
- while (1) {
157
- switch (_context.prev = _context.next) {
158
- case 0:
159
- _context.next = 2;
160
- return checkIfFinish();
161
-
162
- case 2:
163
- _context.t0 = _context.sent;
164
-
165
- if (!(_context.t0 === true)) {
166
- _context.next = 6;
167
- break;
168
- }
169
-
170
- clearInterval(intervalID);
171
- intervalIDArr.splice(intervalIDArr.indexOf(intervalIDArr), 1);
172
-
173
- case 6:
174
- case "end":
175
- return _context.stop();
176
- }
177
- }
178
- }, _callee);
179
- })), 5000);
180
- intervalIDArr.push(intervalID);
181
-
182
- case 6:
183
- case "end":
184
- return _context2.stop();
185
- }
186
- }
187
- }, _callee2);
188
- })), 500);
189
- }
190
- })),
191
- _useState4 = _slicedToArray(_useState3, 1),
192
- uploadQueue = _useState4[0];
193
-
194
- (0, _react.useEffect)(function () {
195
- /* 定义displayName是为了在浏览器开发者工具里更好地显示高阶组件名称 */
196
- component.displayName = "withUploader(".concat((0, _lib.getComponentDisplayName)(WrappedComponent), ")");
197
- component.defaultProps = {
198
- perChunkSize: 1024 * 512,
199
- errorCb: function errorCb() {},
200
- finishCb: function finishCb() {}
201
- };
202
- component.propTypes = {
203
- perChunkSize: _propTypes.default.number,
204
- errorCb: _propTypes.default.func,
205
- finishCb: _propTypes.default.func
206
- };
207
- }, [component, WrappedComponent]);
208
- /* 清理所有定时器 */
209
-
210
- (0, _react.useEffect)(function () {
211
- return function () {
212
- intervalIDArr.forEach(function (intervalID) {
213
- return clearInterval(intervalID);
214
- });
215
- };
216
- }, [intervalIDArr]);
217
- return {
218
- filesList: filesList,
219
- setFilesList: setFilesList,
220
- uploadQueue: uploadQueue
221
- };
222
- }
223
- /**
224
- * 根据用户选择上传的文件来初始化文件信息,并添加到state里
225
- * @param {File} file 用户选择上传的文件
226
- */
227
-
228
-
229
- function initFilesListState(file) {
230
- var fileInfo = {
231
- hash: (0, _lib.guid)(),
232
- // 用uuid来假装hash
233
- fileName: file.name,
234
- status: 'init',
235
- publicPath: '',
236
- size: file.size,
237
- sizeStr: (0, _lib.bytesToSize)(file.size) // 转换当前字节数
238
-
239
- };
240
- this.setFilesList([].concat(_toConsumableArray(this.filesList), [fileInfo]));
241
- console.log('根据用户选择上传的文件来初始化文件信息', fileInfo);
242
- return fileInfo;
243
- }
244
- /**
245
- * 根据文件hash查询当前组件管理的文件列表里是否已存在目标文件
246
- * @param {String} hash 文件hash
247
- */
248
-
249
-
250
- function checkDuplicateByHash(hash) {
251
- return this.filesList.some(function (file) {
252
- return file.hash === hash;
253
- });
254
- }
255
- /**
256
- * 根据文件hash,从当前组件管理的文件列表中删除目标文件信息
257
- * @param {Object} currentFileInfo 用户当前选择上传的文件的信息
258
- */
259
-
260
-
261
- function removeFile(currentFileInfo) {
262
- this.setFilesList(function (filesList) {
263
- return filesList.filter(function (file) {
264
- return currentFileInfo.hash !== file.hash;
265
- });
266
- });
267
- }
268
- /**
269
- * 更新state中的文件信息
270
- * @param {String} hash 文件hash
271
- * @param {Object} newFileAttrs 需要更新的文件信息字段;不需要更新的字段就不需要传进来
272
- */
273
-
274
-
275
- function updateFileInfo(hash, newFileAttrs) {
276
- console.log('updateFileInfo=》 更新state中的文件信息');
277
- this.setFilesList(function (filesList) {
278
- return filesList.map(function (file) {
279
- return file.hash === hash ? _objectSpread(_objectSpread({}, file), newFileAttrs) : file;
280
- });
281
- });
282
- console.log('最新的this.filesList=》', this.filesList);
283
- }
284
- /**
285
- * <input type="file">的change事件回调函数
286
- * @param {Number} perChunkSize 每个分片的大小
287
- * @param {Function} errorCb 错误异常的处理函数
288
- */
289
-
290
-
291
- function returnFileInputChangeCb(_ref3) {
292
- var _this = this;
293
-
294
- var perChunkSize = _ref3.perChunkSize,
295
- errorCb = _ref3.errorCb;
296
- console.log('调用input更新事件');
297
- return /*#__PURE__*/function () {
298
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(event) {
299
- var file, currentFileInfo, chunksArr, fileContentHash, remoteFileInfo;
300
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
301
- while (1) {
302
- switch (_context4.prev = _context4.next) {
303
- case 0:
304
- file = event.target.files[0];
305
- currentFileInfo = initFilesListState.call(_this, file);
306
- console.log('当前已选择需要上传的文件', file);
307
- chunksArr = (0, _lib.splitFileToChunks)(file, perChunkSize); // 文件分片
308
-
309
- _context4.next = 6;
310
- return (0, _lib.calFileContentHash)(chunksArr);
311
-
312
- case 6:
313
- fileContentHash = _context4.sent;
314
-
315
- // 计算文件内容的hash
316
- if (checkDuplicateByHash.call(_this, fileContentHash)) {
317
- removeFile.call(_this, currentFileInfo);
318
- errorCb({
319
- errorCode: 1,
320
- message: 'duplicate file found by hash'
321
- });
322
- }
323
-
324
- console.log('当前文件内的fileContentHash', fileContentHash);
325
- updateFileInfo.call(_this, currentFileInfo.hash, {
326
- hash: fileContentHash
327
- });
328
- /* 查询该文件上传情况 */
329
-
330
- _context4.next = 12;
331
- return (0, _api.queryFileInfo)(_objectSpread(_objectSpread({}, currentFileInfo), {}, {
332
- fileHash: fileContentHash,
333
- chunksLength: chunksArr.length
334
- }));
335
-
336
- case 12:
337
- remoteFileInfo = _context4.sent;
338
- console.log('请求接口queryFileInfo=》初始化,返回当前文件上传情况 =>remoteFileInfo:', remoteFileInfo);
339
- updateFileInfo.call(_this, fileContentHash, {
340
- status: remoteFileInfo.status,
341
- url: remoteFileInfo.publicPath,
342
- chunks: remoteFileInfo.chunks,
343
- chunksLength: remoteFileInfo.chunksLength
344
- });
345
- /* 秒传 */
346
-
347
- if (!(remoteFileInfo.status === 'finish')) {
348
- _context4.next = 17;
349
- break;
350
- }
351
-
352
- return _context4.abrupt("return");
353
-
354
- case 17:
355
- _this.uploadQueue.addChunksToQueue(remoteFileInfo, chunksArr); // 建立上传队列
356
-
357
-
358
- _this.uploadQueue.run(); // 触发上传
359
-
360
-
361
- case 19:
362
- case "end":
363
- return _context4.stop();
364
- }
365
- }
366
- }, _callee4);
367
- }));
368
-
369
- return function (_x) {
370
- return _ref4.apply(this, arguments);
371
- };
372
- }();
373
- }
374
- /**
375
- * 高阶组件的主函数
376
- * @param {ReactComponent} WrappedComponent 被封装的具体实现的组件
377
- */
378
-
379
-
380
- function withUploader(WrappedComponent) {
381
- return function UploaderHoc(props) {
382
- var perChunkSize = props.perChunkSize,
383
- errorCb = props.errorCb,
384
- restProps = _objectWithoutProperties(props, ["perChunkSize", "errorCb"]);
385
-
386
- var fileInputRef = (0, _react.useRef)(null);
387
- var state = useComponentInit(UploaderHoc, WrappedComponent);
388
- /* 组装传给具体实现组件的props */
389
-
390
- var spreadProps = _objectSpread(_objectSpread({}, restProps), {}, {
391
- // 透传
392
- triggerFile: function triggerFile() {
393
- return fileInputRef.current.click();
394
- },
395
- filesList: state.filesList
396
- });
397
-
398
- return /*#__PURE__*/_react.default.createElement("div", {
399
- className: "upload-hoc"
400
- }, /*#__PURE__*/_react.default.createElement("input", {
401
- ref: fileInputRef,
402
- type: "file",
403
- className: "upload-hoc_file-input",
404
- onChange: returnFileInputChangeCb.call(state, {
405
- perChunkSize: perChunkSize,
406
- errorCb: errorCb
407
- })
408
- }), /*#__PURE__*/_react.default.createElement(WrappedComponent, spreadProps));
409
- };
410
- }
@@ -1,113 +0,0 @@
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
- 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
-
18
- 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
-
20
- // 启动 Web Worker
21
-
22
- /**
23
- * 获取组件名称
24
- * @param {ReactComponent} component
25
- */
26
- function getComponentDisplayName(component) {
27
- return component.displayName || component.name || 'Component';
28
- }
29
- /**
30
- * 文件切分分片
31
- * @param {File} file 文件
32
- */
33
-
34
-
35
- function splitFileToChunks(file, perChunkSize) {
36
- var fileSize = file.size;
37
- var total = Math.ceil(fileSize / perChunkSize); // 计算总共要分多少片
38
-
39
- var chunksArr = [];
40
-
41
- for (var i = 1; i <= total; i++) {
42
- chunksArr.push(file.slice((i - 1) * perChunkSize, i * perChunkSize));
43
- }
44
-
45
- console.log('splitFileToChunks==》文件切分分片', chunksArr);
46
- return chunksArr;
47
- }
48
- /**
49
- * 利用WebWorker计算文件内容的Hash
50
- * @param {File} file 文件
51
- */
52
-
53
-
54
- function calFileContentHash(_x) {
55
- return _calFileContentHash.apply(this, arguments);
56
- }
57
- /**
58
- * 把字节数转化成更友好的显示(单位转化)
59
- * @param {String} bytes 字节数
60
- * @param {Number} precise 小数精度
61
- */
62
-
63
-
64
- function _calFileContentHash() {
65
- _calFileContentHash = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(chunksArr) {
66
- var worker;
67
- return regeneratorRuntime.wrap(function _callee$(_context) {
68
- while (1) {
69
- switch (_context.prev = _context.next) {
70
- case 0:
71
- worker = new _worker.default();
72
- worker.postMessage({
73
- chunksArr: chunksArr
74
- }); // 传递文件分片
75
-
76
- /* 接受计算好的hash */
77
-
78
- return _context.abrupt("return", new Promise(function (resolve) {
79
- worker.onmessage = function (event) {
80
- resolve(event.data.hash);
81
- };
82
- }));
83
-
84
- case 3:
85
- case "end":
86
- return _context.stop();
87
- }
88
- }
89
- }, _callee);
90
- }));
91
- return _calFileContentHash.apply(this, arguments);
92
- }
93
-
94
- function bytesToSize(bytes) {
95
- var precise = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
96
- if (bytes === 0) return '0 B';
97
- var k = 1024,
98
- sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
99
- i = Math.floor(Math.log(bytes) / Math.log(k));
100
- return (bytes / Math.pow(k, i)).toFixed(precise) + ' ' + sizes[i];
101
- }
102
- /**
103
- * 生成guid
104
- */
105
-
106
-
107
- function guid() {
108
- function S4() {
109
- return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
110
- }
111
-
112
- return "".concat(S4()).concat(S4(), "-").concat(S4(), "-").concat(S4(), "-").concat(S4(), "-").concat(S4()).concat(S4()).concat(S4());
113
- }
@@ -1,3 +0,0 @@
1
- .upload-hoc_file-input {
2
- display: none;
3
- }