linkmore-design 1.0.84 → 1.0.87
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/ConfigProvider/demos/componentSize.d.ts +2 -0
- package/dist/ConfigProvider/demos/style.d.ts +2 -0
- package/dist/ConfigProvider/index.d.ts +2 -2
- package/dist/Form/demos/responsive.d.ts +1 -0
- package/dist/Form/demos/responsiveAll.d.ts +3 -0
- package/dist/Form/util.d.ts +1 -0
- package/dist/ImageViewer/fns/index.d.ts +1 -0
- package/dist/Input/index.d.ts +1 -1
- package/dist/InputRange/demos/basic.d.ts +2 -0
- package/dist/InputRange/index.d.ts +8 -0
- package/dist/InputRange/style/index.d.ts +1 -0
- package/dist/LmEditTable/EditTable.d.ts +2 -0
- package/dist/LmTable/util.d.ts +7 -0
- package/dist/LmTable/virTual/VirtualTable.d.ts +2 -2
- package/dist/LmUpload/LmUpload.d.ts +1 -0
- package/dist/LmUpload/demos/formCard.d.ts +2 -0
- package/dist/LmUpload/fns/index.d.ts +1 -0
- package/dist/LmUpload/utils.d.ts +1 -0
- package/dist/LmUpload/wrapper/UploadWrapper.d.ts +4 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.umd.js +483 -218
- package/dist/index.umd.min.js +5 -5
- package/es/Button/index.js +4 -2
- package/es/ConfigProvider/cssVariables.js +1 -1
- package/es/ConfigProvider/index.d.ts +2 -2
- package/es/ConfigProvider/index.js +2 -1
- package/es/DatePicker/generatePicker/generateSinglePicker.js +3 -3
- package/es/Form/container.js +2 -16
- package/es/Form/style/index.css +8 -2
- package/es/Form/util.d.ts +1 -0
- package/es/Form/util.js +22 -0
- package/es/ImageViewer/components/Carousel.js +20 -2
- package/es/ImageViewer/components/Thumb.js +24 -5
- package/es/ImageViewer/fns/index.d.ts +1 -0
- package/es/ImageViewer/fns/index.js +19 -2
- package/es/ImageViewer/style/index.css +26 -15
- package/es/Input/index.d.ts +1 -1
- package/es/Input/index.js +6 -2
- package/es/Input/style/index.css +9 -0
- package/es/InputRange/index.d.ts +8 -0
- package/es/InputRange/index.js +67 -0
- package/es/InputRange/style/index.css +511 -0
- package/es/InputRange/style/index.d.ts +1 -0
- package/es/InputRange/style/index.js +1 -0
- package/es/LmEditTable/EditTable.d.ts +2 -0
- package/es/LmEditTable/EditTable.js +19 -5
- package/es/LmFilter/style/index.css +159 -0
- package/es/LmTable/Table.js +50 -64
- package/es/LmTable/components/sheelTableCell.js +2 -2
- package/es/LmTable/style/index.css +1 -0
- package/es/LmTable/util.js +73 -16
- package/es/LmTable/virTual/VirtualTable.d.ts +2 -2
- package/es/LmTable/virTual/VirtualTable.js +6 -4
- package/es/LmUpload/LmUpload.d.ts +1 -0
- package/es/LmUpload/LmUpload.js +46 -26
- package/es/LmUpload/UploadList/ItemPicture.js +5 -4
- package/es/LmUpload/UploadList/ItemPictureCard.js +26 -12
- package/es/LmUpload/UploadList/ItemText.js +4 -3
- package/es/LmUpload/body/UploadCore.js +1 -1
- package/es/LmUpload/fns/index.d.ts +1 -0
- package/es/LmUpload/fns/index.js +91 -46
- package/es/LmUpload/style/index.css +42 -35
- package/es/LmUpload/utils.d.ts +1 -0
- package/es/LmUpload/utils.js +12 -0
- package/es/LmUpload/wrapper/UploadRoot.js +7 -13
- package/es/LmUpload/wrapper/UploadWrapper.d.ts +4 -3
- package/es/LmUpload/wrapper/UploadWrapper.js +1 -1
- package/es/Select/index.js +3 -2
- package/es/Tabs/index.js +3 -2
- package/es/index.d.ts +3 -0
- package/es/index.js +2 -1
- package/lib/Button/index.js +5 -2
- package/lib/ConfigProvider/cssVariables.js +1 -1
- package/lib/ConfigProvider/index.d.ts +2 -2
- package/lib/ConfigProvider/index.js +2 -1
- package/lib/DatePicker/generatePicker/generateSinglePicker.js +7 -7
- package/lib/Form/container.js +3 -16
- package/lib/Form/style/index.css +8 -2
- package/lib/Form/util.d.ts +1 -0
- package/lib/Form/util.js +24 -0
- package/lib/ImageViewer/components/Carousel.js +20 -2
- package/lib/ImageViewer/components/Thumb.js +25 -5
- package/lib/ImageViewer/fns/index.d.ts +1 -0
- package/lib/ImageViewer/fns/index.js +18 -1
- package/lib/ImageViewer/style/index.css +26 -15
- package/lib/Input/index.d.ts +1 -1
- package/lib/Input/index.js +7 -2
- package/lib/Input/style/index.css +9 -0
- package/lib/InputRange/index.d.ts +8 -0
- package/lib/InputRange/index.js +79 -0
- package/lib/InputRange/style/index.css +511 -0
- package/lib/InputRange/style/index.d.ts +1 -0
- package/lib/InputRange/style/index.js +3 -0
- package/lib/LmEditTable/EditTable.d.ts +2 -0
- package/lib/LmEditTable/EditTable.js +19 -4
- package/lib/LmFilter/style/index.css +159 -0
- package/lib/LmTable/Table.js +50 -64
- package/lib/LmTable/components/sheelTableCell.js +2 -2
- package/lib/LmTable/style/index.css +1 -0
- package/lib/LmTable/util.js +73 -16
- package/lib/LmTable/virTual/VirtualTable.d.ts +2 -2
- package/lib/LmTable/virTual/VirtualTable.js +6 -4
- package/lib/LmUpload/LmUpload.d.ts +1 -0
- package/lib/LmUpload/LmUpload.js +46 -26
- package/lib/LmUpload/UploadList/ItemPicture.js +5 -4
- package/lib/LmUpload/UploadList/ItemPictureCard.js +26 -12
- package/lib/LmUpload/UploadList/ItemText.js +4 -3
- package/lib/LmUpload/body/UploadCore.js +1 -1
- package/lib/LmUpload/fns/index.d.ts +1 -0
- package/lib/LmUpload/fns/index.js +89 -45
- package/lib/LmUpload/style/index.css +42 -35
- package/lib/LmUpload/utils.d.ts +1 -0
- package/lib/LmUpload/utils.js +17 -1
- package/lib/LmUpload/wrapper/UploadRoot.js +7 -13
- package/lib/LmUpload/wrapper/UploadWrapper.d.ts +4 -3
- package/lib/LmUpload/wrapper/UploadWrapper.js +2 -1
- package/lib/Select/index.js +4 -2
- package/lib/Tabs/index.js +4 -2
- package/lib/index.d.ts +3 -0
- package/lib/index.js +9 -1
- package/package.json +1 -1
package/es/LmUpload/LmUpload.js
CHANGED
|
@@ -15,24 +15,41 @@ import React, { useRef, useMemo, forwardRef } from 'react';
|
|
|
15
15
|
import LmFilterRoot from './wrapper/UploadRoot';
|
|
16
16
|
|
|
17
17
|
var LmUpload = function LmUpload(_a, ref) {
|
|
18
|
-
var
|
|
18
|
+
var _fileConfig = _a.fileConfig,
|
|
19
|
+
fileNames = _a.fileNames,
|
|
19
20
|
components = _a.components,
|
|
20
21
|
_ossConfig = _a.ossConfig,
|
|
21
|
-
resetProps = __rest(_a, ["fileConfig", "components", "ossConfig"]);
|
|
22
|
+
resetProps = __rest(_a, ["fileConfig", "fileNames", "components", "ossConfig"]);
|
|
22
23
|
|
|
23
24
|
var defaultRef = useRef(null); // 仅在初始化触发一次
|
|
24
25
|
|
|
25
26
|
var initConfig = useMemo(function () {
|
|
26
27
|
return {
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
// 文件参数配置: 存储时的数据
|
|
29
|
+
fileConfig: function fileConfig(fileConfigProps) {
|
|
30
|
+
var file = fileConfigProps.file,
|
|
31
|
+
timestamp = fileConfigProps.timestamp,
|
|
32
|
+
fileName = fileConfigProps.fileName,
|
|
33
|
+
filePath = fileConfigProps.filePath,
|
|
34
|
+
shortlink = fileConfigProps.shortlink,
|
|
35
|
+
url = fileConfigProps.url;
|
|
36
|
+
return Object.assign({
|
|
37
|
+
uid: timestamp,
|
|
38
|
+
fileTypeCode: file.type,
|
|
39
|
+
fileTypeName: file.type,
|
|
40
|
+
fileName: fileName,
|
|
41
|
+
realFileName: file.name,
|
|
42
|
+
fileSize: file.size,
|
|
43
|
+
internalUrl: shortlink,
|
|
44
|
+
externalUrl: shortlink,
|
|
45
|
+
filePath: filePath,
|
|
46
|
+
seq: 0,
|
|
47
|
+
url: url,
|
|
48
|
+
status: 'done'
|
|
49
|
+
}, _fileConfig === null || _fileConfig === void 0 ? void 0 : _fileConfig(fileConfigProps));
|
|
50
|
+
},
|
|
51
|
+
// 读取字段配置: 读取存储的参数字段
|
|
52
|
+
fileNames: Object.assign({
|
|
36
53
|
uid: 'uid',
|
|
37
54
|
fileTypeCode: 'fileTypeCode',
|
|
38
55
|
fileTypeName: 'fileTypeName',
|
|
@@ -43,32 +60,31 @@ var LmUpload = function LmUpload(_a, ref) {
|
|
|
43
60
|
externalUrl: 'externalUrl',
|
|
44
61
|
filePath: 'filePath',
|
|
45
62
|
seq: 'seq',
|
|
46
|
-
url: 'url'
|
|
47
|
-
|
|
63
|
+
url: 'url',
|
|
64
|
+
status: 'status'
|
|
65
|
+
}, fileNames),
|
|
48
66
|
// 初始化
|
|
49
67
|
components: Object.assign({
|
|
50
68
|
wrapper: null
|
|
51
69
|
}, components || {})
|
|
52
70
|
};
|
|
53
71
|
}, []);
|
|
54
|
-
var defaultProps = {
|
|
72
|
+
var defaultProps = Object.assign({
|
|
73
|
+
size: 100,
|
|
74
|
+
fileSize: 10,
|
|
55
75
|
uid: 'uid',
|
|
56
|
-
fileList: null,
|
|
57
|
-
type: ['jpg', 'jpeg', 'png'],
|
|
58
76
|
accept: '',
|
|
59
|
-
|
|
77
|
+
type: ['jpg', 'jpeg', 'png'],
|
|
60
78
|
listType: 'card',
|
|
61
|
-
|
|
79
|
+
readOnly: false,
|
|
62
80
|
disabled: false,
|
|
63
|
-
maxCount: null,
|
|
64
81
|
showUploadList: true,
|
|
65
|
-
|
|
82
|
+
fileList: null,
|
|
66
83
|
defaultFileList: [],
|
|
84
|
+
limit: null,
|
|
85
|
+
maxCount: null,
|
|
86
|
+
children: null,
|
|
67
87
|
itemRender: null,
|
|
68
|
-
readOnly: false,
|
|
69
|
-
onRemove: function onRemove() {
|
|
70
|
-
return true;
|
|
71
|
-
},
|
|
72
88
|
enabledOss: false,
|
|
73
89
|
// oss配置
|
|
74
90
|
ossConfig: function ossConfig() {
|
|
@@ -81,11 +97,15 @@ var LmUpload = function LmUpload(_a, ref) {
|
|
|
81
97
|
bucket: 'linkmore-scm-test',
|
|
82
98
|
shortlink: 'https://linkmore-scm-test.oss-cn-hangzhou.aliyuncs.com'
|
|
83
99
|
}, typeof _ossConfig === 'function' ? _ossConfig() : _ossConfig);
|
|
100
|
+
},
|
|
101
|
+
// 根据返回值决定是否可删除
|
|
102
|
+
onRemove: function onRemove() {
|
|
103
|
+
return true;
|
|
84
104
|
}
|
|
85
|
-
};
|
|
105
|
+
}, resetProps);
|
|
86
106
|
return /*#__PURE__*/React.createElement(LmFilterRoot, Object.assign({
|
|
87
107
|
ref: ref || defaultRef
|
|
88
|
-
}, initConfig, defaultProps
|
|
108
|
+
}, initConfig, defaultProps));
|
|
89
109
|
};
|
|
90
110
|
|
|
91
111
|
export default /*#__PURE__*/forwardRef(LmUpload);
|
|
@@ -8,9 +8,10 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
8
8
|
var readOnly = instance.readOnly,
|
|
9
9
|
remove = instance.remove,
|
|
10
10
|
preview = instance.preview,
|
|
11
|
-
download = instance.download
|
|
11
|
+
download = instance.download,
|
|
12
|
+
fileNames = instance.fileNames;
|
|
12
13
|
return /*#__PURE__*/React.createElement("div", {
|
|
13
|
-
className: cn('lm_upload_item lm_upload_item_picture', file.status === 'error' && '
|
|
14
|
+
className: cn('lm_upload_item lm_upload_item_picture', file[fileNames.status] === 'error' && 'lm_upload_item_error')
|
|
14
15
|
}, /*#__PURE__*/React.createElement("div", {
|
|
15
16
|
className: "picture_left"
|
|
16
17
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -19,14 +20,14 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
19
20
|
return preview(file);
|
|
20
21
|
}
|
|
21
22
|
}, /*#__PURE__*/React.createElement("img", {
|
|
22
|
-
src: file.url,
|
|
23
|
+
src: file[fileNames.url],
|
|
23
24
|
alt: ""
|
|
24
25
|
})), /*#__PURE__*/React.createElement("div", {
|
|
25
26
|
className: "lm_upload_item_name",
|
|
26
27
|
onClick: function onClick() {
|
|
27
28
|
return download(file);
|
|
28
29
|
}
|
|
29
|
-
}, file.fileName)), !readOnly && /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
}, file[fileNames.fileName])), !readOnly && /*#__PURE__*/React.createElement("div", {
|
|
30
31
|
className: "picture_right lm_upload_item_action"
|
|
31
32
|
}, /*#__PURE__*/React.createElement("div", {
|
|
32
33
|
className: "action_delete",
|
|
@@ -14,13 +14,22 @@ var renderThumb = function renderThumb(file) {
|
|
|
14
14
|
case 'png':
|
|
15
15
|
case 'jpg':
|
|
16
16
|
return /*#__PURE__*/React.createElement("div", {
|
|
17
|
-
className: "
|
|
17
|
+
className: "lm_upload_item_thumb_error"
|
|
18
18
|
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
19
19
|
type: "lmweb-image"
|
|
20
20
|
}), /*#__PURE__*/React.createElement("div", {
|
|
21
21
|
className: "lm_upload_item_name"
|
|
22
22
|
}, file.realFileName));
|
|
23
23
|
|
|
24
|
+
case 'mp4':
|
|
25
|
+
case 'm2v':
|
|
26
|
+
case 'mkv':
|
|
27
|
+
case 'ogm':
|
|
28
|
+
case 'webm':
|
|
29
|
+
return /*#__PURE__*/React.createElement(IconFont, {
|
|
30
|
+
type: "lmweb-video"
|
|
31
|
+
});
|
|
32
|
+
|
|
24
33
|
case 'doc':
|
|
25
34
|
case 'docx':
|
|
26
35
|
return /*#__PURE__*/React.createElement(IconFont, {
|
|
@@ -58,24 +67,29 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
58
67
|
var readOnly = instance.readOnly,
|
|
59
68
|
size = instance.size,
|
|
60
69
|
remove = instance.remove,
|
|
61
|
-
preview = instance.preview
|
|
70
|
+
preview = instance.preview,
|
|
71
|
+
getFileFields = instance.getFileFields;
|
|
62
72
|
|
|
63
73
|
var _useState = useState(false),
|
|
64
74
|
_useState2 = _slicedToArray(_useState, 2),
|
|
65
75
|
isError = _useState2[0],
|
|
66
|
-
setIsError = _useState2[1]; // 文件信息重组
|
|
76
|
+
setIsError = _useState2[1]; // 文件信息重组 获取文件名称 => 截取后缀文件名
|
|
67
77
|
|
|
68
78
|
|
|
69
79
|
var resetFile = useMemo(function () {
|
|
70
|
-
var
|
|
71
|
-
|
|
80
|
+
var fileParams = getFileFields(file);
|
|
81
|
+
var realFileName = fileParams.realFileName,
|
|
82
|
+
fileName = fileParams.fileName,
|
|
83
|
+
filename = fileParams.filename;
|
|
84
|
+
var fileExtension = (realFileName || fileName || filename).replace(/.*\./, '').toLowerCase();
|
|
85
|
+
return Object.assign(Object.assign({}, fileParams), {
|
|
72
86
|
fileExtension: fileExtension
|
|
73
87
|
});
|
|
74
|
-
}, [file]); // 预览小图
|
|
88
|
+
}, [getFileFields, file]); // 预览小图
|
|
75
89
|
|
|
76
90
|
var thumbUrl = useMemo(function () {
|
|
77
|
-
return "".concat(
|
|
78
|
-
}, [
|
|
91
|
+
return "".concat(resetFile.url, "?x-oss-process=image/resize,w_").concat(size);
|
|
92
|
+
}, [resetFile.url, size]); // 根据文件名后缀判断
|
|
79
93
|
|
|
80
94
|
var isImg = useMemo(function () {
|
|
81
95
|
return ['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(resetFile.fileExtension);
|
|
@@ -84,7 +98,7 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
84
98
|
var resetSize = useMemo(function () {
|
|
85
99
|
var width = size - 16;
|
|
86
100
|
var padding = size > 60 ? 8 : 4;
|
|
87
|
-
var fontSize = size > 60 ? 16 :
|
|
101
|
+
var fontSize = size > 60 ? 16 : 12;
|
|
88
102
|
return {
|
|
89
103
|
width: width,
|
|
90
104
|
padding: padding,
|
|
@@ -92,7 +106,7 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
92
106
|
};
|
|
93
107
|
}, [size]);
|
|
94
108
|
return /*#__PURE__*/React.createElement("div", {
|
|
95
|
-
className: cn('lm_upload_item', 'lm_upload_item_card', isError && '
|
|
109
|
+
className: cn('lm_upload_item', 'lm_upload_item_card', isError && 'lm_upload_item_error'),
|
|
96
110
|
style: {
|
|
97
111
|
height: size,
|
|
98
112
|
width: size
|
|
@@ -118,7 +132,7 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
118
132
|
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
119
133
|
type: "lmweb-eye",
|
|
120
134
|
style: {
|
|
121
|
-
fontSize:
|
|
135
|
+
fontSize: resetSize.fontSize
|
|
122
136
|
}
|
|
123
137
|
})), !readOnly && /*#__PURE__*/React.createElement("div", {
|
|
124
138
|
className: "action_delete",
|
|
@@ -128,7 +142,7 @@ var PictureItem = function PictureItem(_ref) {
|
|
|
128
142
|
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
129
143
|
type: "lmweb-delete",
|
|
130
144
|
style: {
|
|
131
|
-
fontSize:
|
|
145
|
+
fontSize: resetSize.fontSize
|
|
132
146
|
}
|
|
133
147
|
})))));
|
|
134
148
|
};
|
|
@@ -6,9 +6,10 @@ var TextItem = function TextItem(_ref) {
|
|
|
6
6
|
var file = _ref.file,
|
|
7
7
|
instance = _ref.instance;
|
|
8
8
|
var readOnly = instance.readOnly,
|
|
9
|
-
remove = instance.remove
|
|
9
|
+
remove = instance.remove,
|
|
10
|
+
fileNames = instance.fileNames;
|
|
10
11
|
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
-
className: cn('lm_upload_item lm_upload_item_text', file.status === 'error' && '
|
|
12
|
+
className: cn('lm_upload_item lm_upload_item_text', file[fileNames.status] === 'error' && 'lm_upload_item_error')
|
|
12
13
|
}, /*#__PURE__*/React.createElement("div", {
|
|
13
14
|
className: "text_left"
|
|
14
15
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -17,7 +18,7 @@ var TextItem = function TextItem(_ref) {
|
|
|
17
18
|
type: "lmweb-attachment"
|
|
18
19
|
})), /*#__PURE__*/React.createElement("div", {
|
|
19
20
|
className: "lm_upload_item_name"
|
|
20
|
-
}, file.fileName)), !readOnly && /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
}, file[fileNames.fileName])), !readOnly && /*#__PURE__*/React.createElement("div", {
|
|
21
22
|
className: "text_right lm_upload_item_text_action"
|
|
22
23
|
}, /*#__PURE__*/React.createElement("div", {
|
|
23
24
|
className: "action_delete",
|
|
@@ -31,7 +31,7 @@ var UploadCore = function UploadCore(_ref) {
|
|
|
31
31
|
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) {
|
|
32
32
|
inputRef.current.value = '';
|
|
33
33
|
}
|
|
34
|
-
}, [(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value]);
|
|
34
|
+
}, [beforeUpload, (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value]);
|
|
35
35
|
var inputConfig = {
|
|
36
36
|
type: 'file',
|
|
37
37
|
accept: accept,
|
|
@@ -5,6 +5,7 @@ declare const useCoreOptions: ({ state, dispatch, props }: {
|
|
|
5
5
|
}) => {
|
|
6
6
|
CoreMethods: {
|
|
7
7
|
getIsMaxCount: () => boolean;
|
|
8
|
+
getFileFields: (fileParams: any) => {};
|
|
8
9
|
beforeUpload: (e: any) => false | import("../../message").MessageType;
|
|
9
10
|
getUploadStatus: () => {
|
|
10
11
|
uploading: boolean;
|
package/es/LmUpload/fns/index.js
CHANGED
|
@@ -34,7 +34,8 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
import { useCallback } from 'react';
|
|
37
|
-
import { message } from 'linkmore-design';
|
|
37
|
+
import { message } from 'linkmore-design'; // import { message } from 'antd'
|
|
38
|
+
|
|
38
39
|
import OSS from 'ali-oss';
|
|
39
40
|
|
|
40
41
|
var useCoreOptions = function useCoreOptions(_ref) {
|
|
@@ -57,13 +58,38 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
57
58
|
return {
|
|
58
59
|
uploading: uploading
|
|
59
60
|
};
|
|
60
|
-
}, [state.percent]); //
|
|
61
|
+
}, [state.percent]); // 获取文件字段值
|
|
62
|
+
|
|
63
|
+
var getFileFields = useCallback(function (fileParams) {
|
|
64
|
+
var fileNames = props.fileNames;
|
|
65
|
+
var obj = {};
|
|
66
|
+
Object.entries(fileNames).forEach(function (v) {
|
|
67
|
+
var itemKey = v[0];
|
|
68
|
+
var itemValue = v[1];
|
|
69
|
+
|
|
70
|
+
if (fileParams[itemKey]) {
|
|
71
|
+
obj[itemKey] = fileParams[itemValue];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return obj;
|
|
75
|
+
}, [props]); // 获取是否达到最大上传数量
|
|
61
76
|
|
|
62
77
|
var getIsMaxCount = useCallback(function () {
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
var maxCount = props.maxCount,
|
|
79
|
+
limit = props.limit;
|
|
80
|
+
var flag = false;
|
|
81
|
+
var num = maxCount || limit;
|
|
82
|
+
|
|
83
|
+
if (num && typeof num === 'number') {
|
|
84
|
+
flag = !(getFileList().length < num);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return flag;
|
|
88
|
+
}, [getFileList, props]); // 上传成功事件: File, fileParams
|
|
89
|
+
|
|
90
|
+
var uploadSuccess = useCallback(function (file, params, ossCallBack) {
|
|
91
|
+
var _a;
|
|
65
92
|
|
|
66
|
-
var uploadDone = useCallback(function (file, params, ossCallBack) {
|
|
67
93
|
var fileList = [params].concat(_toConsumableArray(getFileList()));
|
|
68
94
|
dispatch({
|
|
69
95
|
type: 'changeFileList',
|
|
@@ -74,18 +100,25 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
74
100
|
percent: null
|
|
75
101
|
}); // 上传事件:抛出 file: 文件 filelist: 文件列表 event: 上传进度信息
|
|
76
102
|
|
|
103
|
+
(_a = props.onSuccess) === null || _a === void 0 ? void 0 : _a.call(props, {
|
|
104
|
+
file: file,
|
|
105
|
+
fileList: fileList
|
|
106
|
+
});
|
|
77
107
|
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
78
108
|
file: file,
|
|
79
109
|
fileList: fileList
|
|
80
110
|
});
|
|
81
111
|
ossCallBack === null || ossCallBack === void 0 ? void 0 : ossCallBack(params);
|
|
82
|
-
}, [getFileList]); // 上传进度事件
|
|
112
|
+
}, [getFileList, props.onSuccess, onChange, dispatch]); // 上传进度事件
|
|
83
113
|
|
|
84
114
|
var uploadProgress = useCallback(function (file, _ref2) {
|
|
85
115
|
var progress = _ref2.progress,
|
|
86
116
|
checkPoint = _ref2.checkPoint,
|
|
87
117
|
result = _ref2.result;
|
|
88
|
-
|
|
118
|
+
|
|
119
|
+
var _a;
|
|
120
|
+
|
|
121
|
+
var params = {
|
|
89
122
|
file: file,
|
|
90
123
|
fileList: getFileList(),
|
|
91
124
|
event: {
|
|
@@ -94,23 +127,43 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
94
127
|
result: result,
|
|
95
128
|
status: typeof progress !== 'number' ? 'done' : 'uploading'
|
|
96
129
|
}
|
|
97
|
-
}
|
|
130
|
+
};
|
|
131
|
+
(_a = props.onProgress) === null || _a === void 0 ? void 0 : _a.call(props, params);
|
|
132
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(params);
|
|
98
133
|
dispatch({
|
|
99
134
|
type: 'changePercent',
|
|
100
135
|
percent: Number((progress * 100).toFixed(2))
|
|
101
136
|
});
|
|
102
|
-
}, [getFileList]); //
|
|
137
|
+
}, [getFileList, props.onProgress, onChange, dispatch]); // 上传失败事件
|
|
138
|
+
|
|
139
|
+
var uploadError = useCallback(function (_ref3) {
|
|
140
|
+
var error = _ref3.error,
|
|
141
|
+
file = _ref3.file;
|
|
142
|
+
console.log('上传报错:', error);
|
|
143
|
+
props.onError ? props.onError({
|
|
144
|
+
error: error,
|
|
145
|
+
file: file,
|
|
146
|
+
fileList: getFileList()
|
|
147
|
+
}) : message.warning('文件上传失败!', 1.5);
|
|
148
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
149
|
+
file: file,
|
|
150
|
+
fileList: getFileList(),
|
|
151
|
+
event: {
|
|
152
|
+
status: 'error'
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}, [props.onError, getFileList, onChange]); // 上传至ali-oss
|
|
103
156
|
|
|
104
157
|
var uploadOss = useCallback(function (file) {
|
|
105
158
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
106
|
-
var
|
|
159
|
+
var _ossConfig, _ossConfig$dir, filePath, shortlink, _ossConfig$region, region, accessKeyId, accessKeySecret, stsToken, _ossConfig$bucket, bucket, ossCallBack, client, timestamp, fileName, pathName, url, params;
|
|
107
160
|
|
|
108
161
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
109
162
|
while (1) {
|
|
110
163
|
switch (_context.prev = _context.next) {
|
|
111
164
|
case 0:
|
|
112
165
|
_context.prev = 0;
|
|
113
|
-
_ossConfig = ossConfig(), _ossConfig$dir = _ossConfig.dir,
|
|
166
|
+
_ossConfig = ossConfig(), _ossConfig$dir = _ossConfig.dir, filePath = _ossConfig$dir === void 0 ? '/BizFile/4595/Supplier/' : _ossConfig$dir, shortlink = _ossConfig.shortlink, _ossConfig$region = _ossConfig.region, region = _ossConfig$region === void 0 ? 'oss-cn-hangzhou' : _ossConfig$region, accessKeyId = _ossConfig.accessKeyId, accessKeySecret = _ossConfig.accessKeySecret, stsToken = _ossConfig.stsToken, _ossConfig$bucket = _ossConfig.bucket, bucket = _ossConfig$bucket === void 0 ? 'linkmore-scm-test' : _ossConfig$bucket, ossCallBack = _ossConfig.ossCallBack;
|
|
114
167
|
client = new OSS({
|
|
115
168
|
region: region,
|
|
116
169
|
accessKeyId: accessKeyId,
|
|
@@ -120,7 +173,7 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
120
173
|
});
|
|
121
174
|
timestamp = Date.now();
|
|
122
175
|
fileName = "".concat(timestamp, "-").concat(file.name);
|
|
123
|
-
pathName =
|
|
176
|
+
pathName = filePath.slice(-1) === '/' ? "".concat(filePath).concat(fileName) : "".concat(filePath, "/").concat(fileName);
|
|
124
177
|
url = "".concat(shortlink).concat(pathName) || '';
|
|
125
178
|
_context.next = 9;
|
|
126
179
|
return client.multipartUpload(pathName, file, {
|
|
@@ -138,53 +191,44 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
138
191
|
});
|
|
139
192
|
|
|
140
193
|
case 9:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
fileTypeCode: file.type,
|
|
145
|
-
fileTypeName: file.type,
|
|
194
|
+
params = props.fileConfig({
|
|
195
|
+
file: file,
|
|
196
|
+
timestamp: timestamp,
|
|
146
197
|
fileName: fileName,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
internalUrl: 'internalUrl',
|
|
150
|
-
externalUrl: 'externalUrl',
|
|
151
|
-
filePath: dir,
|
|
152
|
-
seq: seq,
|
|
198
|
+
filePath: filePath,
|
|
199
|
+
shortlink: shortlink,
|
|
153
200
|
url: url
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
_context.next =
|
|
201
|
+
});
|
|
202
|
+
uploadSuccess(file, params, ossCallBack);
|
|
203
|
+
_context.next = 16;
|
|
157
204
|
break;
|
|
158
205
|
|
|
159
|
-
case
|
|
160
|
-
_context.prev =
|
|
206
|
+
case 13:
|
|
207
|
+
_context.prev = 13;
|
|
161
208
|
_context.t0 = _context["catch"](0);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
file: file
|
|
165
|
-
fileList: getFileList(),
|
|
166
|
-
event: {
|
|
167
|
-
status: 'error'
|
|
168
|
-
}
|
|
209
|
+
uploadError({
|
|
210
|
+
error: _context.t0,
|
|
211
|
+
file: file
|
|
169
212
|
});
|
|
170
213
|
|
|
171
|
-
case
|
|
214
|
+
case 16:
|
|
172
215
|
case "end":
|
|
173
216
|
return _context.stop();
|
|
174
217
|
}
|
|
175
218
|
}
|
|
176
|
-
}, _callee, null, [[0,
|
|
219
|
+
}, _callee, null, [[0, 13]]);
|
|
177
220
|
}));
|
|
178
|
-
}, [ossConfig,
|
|
221
|
+
}, [ossConfig, uploadProgress, props.fileConfig, uploadSuccess, uploadError]); // 自定义使用外部上传
|
|
222
|
+
|
|
179
223
|
var customUpload = useCallback(function (file) {
|
|
180
224
|
var _a;
|
|
181
225
|
|
|
182
226
|
(_a = props.fileUpload) === null || _a === void 0 ? void 0 : _a.call(props, {
|
|
183
227
|
file: file,
|
|
184
228
|
value: getFileList(),
|
|
185
|
-
onChange:
|
|
229
|
+
onChange: uploadSuccess
|
|
186
230
|
});
|
|
187
|
-
}, [props.fileUpload, getFileList,
|
|
231
|
+
}, [props.fileUpload, getFileList, uploadSuccess]); // 上传前的检测
|
|
188
232
|
|
|
189
233
|
var beforeUpload = useCallback(function (e) {
|
|
190
234
|
var files = e.target.files; // 循环文件检查是否存在不符合要求的文件
|
|
@@ -211,20 +255,20 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
211
255
|
|
|
212
256
|
var remove = useCallback(function (file) {
|
|
213
257
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
214
|
-
var
|
|
258
|
+
var _a, _b, res, fileList;
|
|
215
259
|
|
|
216
260
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
217
261
|
while (1) {
|
|
218
262
|
switch (_context2.prev = _context2.next) {
|
|
219
263
|
case 0:
|
|
220
264
|
_context2.next = 2;
|
|
221
|
-
return (
|
|
265
|
+
return (_a = props.onRemove) === null || _a === void 0 ? void 0 : _a.call(props, file);
|
|
222
266
|
|
|
223
267
|
case 2:
|
|
224
268
|
res = _context2.sent;
|
|
225
269
|
|
|
226
270
|
if (res) {
|
|
227
|
-
fileList = (
|
|
271
|
+
fileList = (_b = getFileList()) === null || _b === void 0 ? void 0 : _b.filter(function (v) {
|
|
228
272
|
return v[uid] !== file[uid];
|
|
229
273
|
});
|
|
230
274
|
dispatch({
|
|
@@ -244,21 +288,22 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
244
288
|
}
|
|
245
289
|
}, _callee2);
|
|
246
290
|
}));
|
|
247
|
-
}, [props.onRemove, getFileList, uid]); // 点击文件链接或预览图标时的回调
|
|
291
|
+
}, [props.onRemove, getFileList, onChange, dispatch, uid]); // 点击文件链接或预览图标时的回调
|
|
248
292
|
|
|
249
293
|
var preview = useCallback(function (file) {
|
|
250
294
|
var _a;
|
|
251
295
|
|
|
252
296
|
(_a = props.onPreview) === null || _a === void 0 ? void 0 : _a.call(props, file);
|
|
253
|
-
}, []); // 点击下载文件时的回调
|
|
297
|
+
}, [props.onPreview]); // 点击下载文件时的回调
|
|
254
298
|
|
|
255
299
|
var download = useCallback(function (file) {
|
|
256
300
|
var _a;
|
|
257
301
|
|
|
258
302
|
(_a = props.onDownload) === null || _a === void 0 ? void 0 : _a.call(props, file);
|
|
259
|
-
}, []);
|
|
303
|
+
}, [props.onDownload]);
|
|
260
304
|
var CoreMethods = {
|
|
261
305
|
getIsMaxCount: getIsMaxCount,
|
|
306
|
+
getFileFields: getFileFields,
|
|
262
307
|
beforeUpload: beforeUpload,
|
|
263
308
|
getUploadStatus: getUploadStatus,
|
|
264
309
|
remove: remove,
|