@vtx/components 4.0.0-beta.8 → 4.0.0-beta.9
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/es/utils/filterSpecialCharacters.js +47 -46
- package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +4 -1
- package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
- package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
- package/es/vtx-datagrid/style/index.js +2 -2
- package/es/vtx-ellipsis-text/index.js +6 -1
- package/es/vtx-export/index.js +5 -0
- package/es/vtx-export-async/index.js +28 -8
- package/es/vtx-form-layout/Card.js +10 -10
- package/es/vtx-form-layout/Divider.js +1 -1
- package/es/vtx-form-layout/Pane.js +23 -12
- package/es/vtx-image/Preview.js +11 -6
- package/es/vtx-import/index.js +73 -33
- package/es/vtx-import2/index.js +1 -0
- package/es/vtx-import2/style/index.js +1 -1
- package/es/vtx-provider/index.js +4 -2
- package/es/vtx-search/style/index.js +2 -1
- package/es/vtx-signature/index.js +5 -4
- package/es/vtx-signature/style/index.js +1 -1
- package/es/vtx-tree/index.js +79 -34
- package/es/vtx-wang-editor/index.js +54 -9
- package/es/vtx-wang-editor/wangEditorUtil.js +4 -0
- package/lib/utils/filterSpecialCharacters.js +48 -46
- package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +4 -1
- package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
- package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
- package/lib/vtx-datagrid/style/index.js +2 -2
- package/lib/vtx-ellipsis-text/index.js +6 -1
- package/lib/vtx-export/index.js +5 -0
- package/lib/vtx-export-async/index.js +26 -6
- package/lib/vtx-form-layout/Card.js +9 -9
- package/lib/vtx-form-layout/Divider.js +1 -1
- package/lib/vtx-form-layout/Pane.js +22 -11
- package/lib/vtx-image/Preview.js +11 -6
- package/lib/vtx-import/index.js +73 -33
- package/lib/vtx-import2/index.js +1 -0
- package/lib/vtx-import2/style/index.js +1 -1
- package/lib/vtx-provider/index.js +4 -2
- package/lib/vtx-search/style/index.js +2 -1
- package/lib/vtx-signature/index.js +4 -3
- package/lib/vtx-signature/style/index.js +1 -1
- package/lib/vtx-tree/index.js +77 -32
- package/lib/vtx-wang-editor/index.js +54 -9
- package/lib/vtx-wang-editor/wangEditorUtil.js +4 -0
- package/package.json +34 -21
|
@@ -9,6 +9,52 @@ function isNotEmpty(value) {
|
|
|
9
9
|
return Array.isArray(value) && value.length > 0;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// 特殊符号,- _ 排除
|
|
13
|
+
export var SpecialCharacters = [
|
|
14
|
+
// 小括号
|
|
15
|
+
'(', ')', '(', ')',
|
|
16
|
+
// 中括号
|
|
17
|
+
'\\[', '\\]', '[', ']',
|
|
18
|
+
// 大括号
|
|
19
|
+
'{', '}', '{', '}',
|
|
20
|
+
// 方头括号
|
|
21
|
+
'【', '】',
|
|
22
|
+
// 尖括号
|
|
23
|
+
'<', '>',
|
|
24
|
+
// 书名号
|
|
25
|
+
'《', '》',
|
|
26
|
+
// 斜杠
|
|
27
|
+
'/',
|
|
28
|
+
// 反斜杠
|
|
29
|
+
'\\\\',
|
|
30
|
+
// 逗号
|
|
31
|
+
',', ',',
|
|
32
|
+
// 句号
|
|
33
|
+
'.', '。',
|
|
34
|
+
// 冒号
|
|
35
|
+
':', ':',
|
|
36
|
+
// 分号
|
|
37
|
+
';', ';',
|
|
38
|
+
// 顿号
|
|
39
|
+
'、',
|
|
40
|
+
// 破折号
|
|
41
|
+
'——',
|
|
42
|
+
// 感叹号
|
|
43
|
+
'!', '!',
|
|
44
|
+
// 问号
|
|
45
|
+
'?', '?',
|
|
46
|
+
// 加减等于
|
|
47
|
+
'+', '=',
|
|
48
|
+
// 单引号
|
|
49
|
+
"'", '‘', '’',
|
|
50
|
+
// 双引号
|
|
51
|
+
'"', '“', '”',
|
|
52
|
+
// 金钱
|
|
53
|
+
'$', '¥',
|
|
54
|
+
// 百分号
|
|
55
|
+
'%', '%',
|
|
56
|
+
// 其它
|
|
57
|
+
'@', '#', '`', '~', '*', '^', '……', '|', '&'];
|
|
12
58
|
/**
|
|
13
59
|
* 过滤特殊字符
|
|
14
60
|
* @param {String} value 值
|
|
@@ -22,52 +68,7 @@ export default function filterSpecialCharacters(value) {
|
|
|
22
68
|
include = _ref$include === void 0 ? [] : _ref$include,
|
|
23
69
|
_ref$exclude = _ref.exclude,
|
|
24
70
|
exclude = _ref$exclude === void 0 ? [] : _ref$exclude;
|
|
25
|
-
|
|
26
|
-
var specialCharacter = [
|
|
27
|
-
// 小括号
|
|
28
|
-
'(', ')', '(', ')',
|
|
29
|
-
// 中括号
|
|
30
|
-
'\\[', '\\]', '[', ']',
|
|
31
|
-
// 大括号
|
|
32
|
-
'{', '}', '{', '}',
|
|
33
|
-
// 方头括号
|
|
34
|
-
'【', '】',
|
|
35
|
-
// 尖括号
|
|
36
|
-
'<', '>',
|
|
37
|
-
// 书名号
|
|
38
|
-
'《', '》',
|
|
39
|
-
// 斜杠
|
|
40
|
-
'/',
|
|
41
|
-
// 反斜杠
|
|
42
|
-
'\\\\',
|
|
43
|
-
// 逗号
|
|
44
|
-
',', ',',
|
|
45
|
-
// 句号
|
|
46
|
-
'.', '。',
|
|
47
|
-
// 冒号
|
|
48
|
-
':', ':',
|
|
49
|
-
// 分号
|
|
50
|
-
';', ';',
|
|
51
|
-
// 顿号
|
|
52
|
-
'、',
|
|
53
|
-
// 破折号
|
|
54
|
-
'——',
|
|
55
|
-
// 感叹号
|
|
56
|
-
'!', '!',
|
|
57
|
-
// 问号
|
|
58
|
-
'?', '?',
|
|
59
|
-
// 加减等于
|
|
60
|
-
'+', '=',
|
|
61
|
-
// 单引号
|
|
62
|
-
"'", '‘', '’',
|
|
63
|
-
// 双引号
|
|
64
|
-
'"', '“', '”',
|
|
65
|
-
// 金钱
|
|
66
|
-
'$', '¥',
|
|
67
|
-
// 百分号
|
|
68
|
-
'%', '%',
|
|
69
|
-
// 其它
|
|
70
|
-
'@', '#', '`', '~', '*', '^', '……', '|', '&'];
|
|
71
|
+
var specialCharacter = JSON.parse(JSON.stringify(SpecialCharacters));
|
|
71
72
|
|
|
72
73
|
// 新增
|
|
73
74
|
if (isNotEmpty(include)) {
|
|
@@ -501,7 +501,10 @@ export default function ColumnSetting(props) {
|
|
|
501
501
|
children: TextEnum.columnSettingSaveText
|
|
502
502
|
})]
|
|
503
503
|
}) : null]
|
|
504
|
-
})
|
|
504
|
+
}),
|
|
505
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
506
|
+
return triggerNode.parentNode;
|
|
507
|
+
}
|
|
505
508
|
// open={true}
|
|
506
509
|
,
|
|
507
510
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
@@ -28,6 +28,9 @@ function Density() {
|
|
|
28
28
|
selectedKeys: [counter.tableSize]
|
|
29
29
|
},
|
|
30
30
|
trigger: ['click'],
|
|
31
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
32
|
+
return triggerNode.parentNode;
|
|
33
|
+
},
|
|
31
34
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
32
35
|
title: TextEnum.columnDensityText,
|
|
33
36
|
children: /*#__PURE__*/_jsx("span", {
|
|
@@ -31,6 +31,9 @@ function TableStyle() {
|
|
|
31
31
|
trigger: ['click'],
|
|
32
32
|
placement: "bottomRight",
|
|
33
33
|
title: null,
|
|
34
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
35
|
+
return triggerNode.parentNode;
|
|
36
|
+
},
|
|
34
37
|
content: list === null || list === void 0 ? void 0 : list.map(function (v) {
|
|
35
38
|
return /*#__PURE__*/_jsx("div", {
|
|
36
39
|
children: /*#__PURE__*/_jsx(Checkbox, {
|
|
@@ -50,7 +50,7 @@ var genVtxStyle = function genVtxStyle(token) {
|
|
|
50
50
|
}
|
|
51
51
|
}))))), "&.vtx-datagrid-striped", _defineProperty({}, "".concat(antCls, "-table-wrapper"), _defineProperty({}, "".concat(antCls, "-table"), _defineProperty({}, '>.ant-table-container', _defineProperty({}, '.ant-table-body', {
|
|
52
52
|
'>table >tbody>tr:nth-child(odd)>td': {
|
|
53
|
-
backgroundColor: token.
|
|
53
|
+
backgroundColor: token.colorBgLayoutTable,
|
|
54
54
|
'&.ant-table-cell-row-hover': {
|
|
55
55
|
backgroundColor: token.colorFillAlterSolid
|
|
56
56
|
}
|
|
@@ -66,7 +66,7 @@ var genVtxStyle = function genVtxStyle(token) {
|
|
|
66
66
|
}
|
|
67
67
|
}))))), "&.vtx-datagrid-header-background", _defineProperty({}, "".concat(antCls, "-table-wrapper"), _defineProperty({}, '.ant-table', _defineProperty({}, '.ant-table-header', _defineProperty({}, '.ant-table-thead', {
|
|
68
68
|
'>tr>th': {
|
|
69
|
-
background: token.
|
|
69
|
+
background: token.colorBgLayoutTable
|
|
70
70
|
}
|
|
71
71
|
}))))));
|
|
72
72
|
};
|
|
@@ -19,6 +19,11 @@ function VtxEllipsisText(props) {
|
|
|
19
19
|
tooltip = _props$tooltip === void 0 ? {} : _props$tooltip,
|
|
20
20
|
className = props.className,
|
|
21
21
|
style = props.style;
|
|
22
|
+
|
|
23
|
+
// 边界检查
|
|
24
|
+
if (!text) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
22
27
|
var _useContext = useContext(ConfigProvider.ConfigContext),
|
|
23
28
|
getPrefixCls = _useContext.getPrefixCls;
|
|
24
29
|
var prefixCls = getPrefixCls('vtx-ellipsis-text');
|
|
@@ -26,7 +31,7 @@ function VtxEllipsisText(props) {
|
|
|
26
31
|
wrapSSR = _useStyle.wrapSSR,
|
|
27
32
|
hashId = _useStyle.hashId;
|
|
28
33
|
var textStyle = {};
|
|
29
|
-
if (lineClamp
|
|
34
|
+
if (lineClamp >= 2) {
|
|
30
35
|
textStyle['WebkitLineClamp'] = lineClamp;
|
|
31
36
|
}
|
|
32
37
|
return wrapSSR( /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({
|
package/es/vtx-export/index.js
CHANGED
|
@@ -124,8 +124,13 @@ var VtxExport = function VtxExport(props) {
|
|
|
124
124
|
// 关闭loading,执行回调
|
|
125
125
|
document.body.removeChild(div);
|
|
126
126
|
if (afterExport && typeof afterExport === 'function') {
|
|
127
|
+
console.log('Export status:', status);
|
|
127
128
|
afterExport(status);
|
|
128
129
|
}
|
|
130
|
+
}).catch(function (err) {
|
|
131
|
+
console.error('Export failed:', err);
|
|
132
|
+
message.error('导出失败');
|
|
133
|
+
document.body.removeChild(div);
|
|
129
134
|
});
|
|
130
135
|
}
|
|
131
136
|
/* 下载并 兼容IE */
|
|
@@ -10,11 +10,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
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; }
|
|
11
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { useEffect, forwardRef, useContext, useMemo } from 'react';
|
|
13
|
+
import React, { useEffect, forwardRef, useContext, useMemo, useRef } from 'react';
|
|
14
14
|
import { ExportOutlined } from '@ant-design/icons';
|
|
15
15
|
import PropTypes from 'prop-types';
|
|
16
16
|
import { useSetState } from 'ahooks';
|
|
17
|
-
import { Button, Form,
|
|
17
|
+
import { Button, Form, message, Modal, Radio, ConfigProvider } from 'antd';
|
|
18
18
|
import dayjs from 'dayjs';
|
|
19
19
|
import { postData } from "./util";
|
|
20
20
|
import History from "./History";
|
|
@@ -23,9 +23,11 @@ import { useStyle } from "./style/index";
|
|
|
23
23
|
import classnames from 'classnames';
|
|
24
24
|
import { useIntl } from "../vtx-provider";
|
|
25
25
|
import VtxModal from "../vtx-modal";
|
|
26
|
+
import VtxInput from "../vtx-input";
|
|
27
|
+
import { SpecialCharacters } from "../utils/filterSpecialCharacters";
|
|
26
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
29
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
-
var
|
|
30
|
+
var Includes = ['\\\\', '\\/', ':', '*', '?', '"', '<', '>', '|'];
|
|
29
31
|
var VtxExportAsync = function VtxExportAsync(props) {
|
|
30
32
|
var intl = useIntl();
|
|
31
33
|
var _useContext = useContext(ConfigProvider.ConfigContext),
|
|
@@ -34,6 +36,7 @@ var VtxExportAsync = function VtxExportAsync(props) {
|
|
|
34
36
|
var _useStyle = useStyle(prefixCls),
|
|
35
37
|
wrapSSR = _useStyle.wrapSSR,
|
|
36
38
|
hashId = _useStyle.hashId;
|
|
39
|
+
var timerRef = useRef(null);
|
|
37
40
|
var uniqueKey = props.uniqueKey,
|
|
38
41
|
_props$title = props.title,
|
|
39
42
|
title = _props$title === void 0 ? '' : _props$title,
|
|
@@ -160,9 +163,9 @@ var VtxExportAsync = function VtxExportAsync(props) {
|
|
|
160
163
|
});
|
|
161
164
|
}, [state.visible]);
|
|
162
165
|
function close() {
|
|
163
|
-
if (
|
|
164
|
-
clearInterval(
|
|
165
|
-
|
|
166
|
+
if (timerRef.current) {
|
|
167
|
+
clearInterval(timerRef.current);
|
|
168
|
+
timerRef.current = null;
|
|
166
169
|
}
|
|
167
170
|
form.resetFields();
|
|
168
171
|
setState({
|
|
@@ -172,6 +175,15 @@ var VtxExportAsync = function VtxExportAsync(props) {
|
|
|
172
175
|
timer: null
|
|
173
176
|
});
|
|
174
177
|
}
|
|
178
|
+
|
|
179
|
+
// 组件卸载时也要清理
|
|
180
|
+
useEffect(function () {
|
|
181
|
+
return function () {
|
|
182
|
+
if (timerRef.current) {
|
|
183
|
+
clearInterval(timerRef.current);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}, []);
|
|
175
187
|
function showHistory() {
|
|
176
188
|
setState({
|
|
177
189
|
showHistoryModal: true
|
|
@@ -253,6 +265,8 @@ var VtxExportAsync = function VtxExportAsync(props) {
|
|
|
253
265
|
} else {
|
|
254
266
|
message.error((res === null || res === void 0 ? void 0 : res.msg) || "".concat(intl.getMessage('export.exportText', '导出')).concat(intl.getMessage('export.failure', '失败')));
|
|
255
267
|
}
|
|
268
|
+
}).catch(function (err) {
|
|
269
|
+
message.error('导出失败:' + (err.message || '网络错误'));
|
|
256
270
|
});
|
|
257
271
|
}
|
|
258
272
|
});
|
|
@@ -313,8 +327,14 @@ var VtxExportAsync = function VtxExportAsync(props) {
|
|
|
313
327
|
required: true,
|
|
314
328
|
message: TextEnum.requireFieldMsgText
|
|
315
329
|
}],
|
|
316
|
-
children: /*#__PURE__*/_jsx(
|
|
317
|
-
placeholder: TextEnum.placeholderFileName
|
|
330
|
+
children: /*#__PURE__*/_jsx(VtxInput, {
|
|
331
|
+
placeholder: TextEnum.placeholderFileName,
|
|
332
|
+
specialCharactersFilter: {
|
|
333
|
+
include: Includes,
|
|
334
|
+
exclude: SpecialCharacters.filter(function (v) {
|
|
335
|
+
return !Includes.includes(v);
|
|
336
|
+
})
|
|
337
|
+
}
|
|
318
338
|
})
|
|
319
339
|
}), /*#__PURE__*/_jsx(Form.Item, {
|
|
320
340
|
label: TextEnum.fieldTypeText,
|
|
@@ -8,7 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
8
8
|
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; }
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
import React, { useEffect, useState, useContext } from 'react';
|
|
11
|
+
import React, { useEffect, useState, useContext, useMemo } from 'react';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
import { Card, ConfigProvider } from 'antd';
|
|
@@ -22,17 +22,17 @@ function VtxCard(props) {
|
|
|
22
22
|
_props$expand = props.expand,
|
|
23
23
|
expand = _props$expand === void 0 ? true : _props$expand,
|
|
24
24
|
extra = props.extra,
|
|
25
|
-
onExpandChange = props.onExpandChange
|
|
25
|
+
onExpandChange = props.onExpandChange,
|
|
26
|
+
children = props.children;
|
|
26
27
|
var _useState = useState(expand),
|
|
27
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
29
|
visible = _useState2[0],
|
|
29
30
|
setVisible = _useState2[1];
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
style = {
|
|
31
|
+
var iconStyle = useMemo(function () {
|
|
32
|
+
return visible ? {
|
|
33
33
|
transform: 'rotate(90deg)'
|
|
34
|
-
};
|
|
35
|
-
}
|
|
34
|
+
} : {};
|
|
35
|
+
}, [visible]);
|
|
36
36
|
useEffect(function () {
|
|
37
37
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
38
38
|
onExpandChange && onExpandChange(visible);
|
|
@@ -50,8 +50,8 @@ function VtxCard(props) {
|
|
|
50
50
|
},
|
|
51
51
|
children: extra
|
|
52
52
|
}) : /*#__PURE__*/_jsx(RightOutlined, {
|
|
53
|
-
className: "".concat(prefixCls, "-expand-icon
|
|
54
|
-
style:
|
|
53
|
+
className: "".concat(prefixCls, "-expand-icon"),
|
|
54
|
+
style: iconStyle,
|
|
55
55
|
onClick: function onClick() {
|
|
56
56
|
return setVisible(function (pre) {
|
|
57
57
|
return !pre;
|
|
@@ -60,7 +60,7 @@ function VtxCard(props) {
|
|
|
60
60
|
}),
|
|
61
61
|
children: /*#__PURE__*/_jsx("div", {
|
|
62
62
|
className: classnames("".concat(prefixCls, "-content"), _defineProperty({}, "".concat(prefixCls, "-content-hide"), !visible)),
|
|
63
|
-
children:
|
|
63
|
+
children: children
|
|
64
64
|
})
|
|
65
65
|
});
|
|
66
66
|
}
|
|
@@ -13,7 +13,7 @@ function VtxDivider(props) {
|
|
|
13
13
|
var prefixCls = getPrefixCls('', 'vtx-form-layout-divider');
|
|
14
14
|
var size = props.size;
|
|
15
15
|
return /*#__PURE__*/_jsx(Divider, {
|
|
16
|
-
className: classnames(prefixCls, _defineProperty({}, "".concat(prefixCls, "--small
|
|
16
|
+
className: classnames(prefixCls, _defineProperty({}, "".concat(prefixCls, "--small"), size === 'small'))
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
VtxDivider.propTypes = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ConfigProvider, Collapse } from 'antd';
|
|
4
4
|
import { CaretRightOutlined } from '@ant-design/icons';
|
|
@@ -8,18 +8,29 @@ function Pane(props) {
|
|
|
8
8
|
var _useContext = useContext(ConfigProvider.ConfigContext),
|
|
9
9
|
getPrefixCls = _useContext.getPrefixCls;
|
|
10
10
|
var prefixCls = getPrefixCls('', 'vtx-form-layout-pane');
|
|
11
|
-
var title = props.title
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
11
|
+
var title = props.title,
|
|
12
|
+
children = props.children;
|
|
13
|
+
|
|
14
|
+
// 无标题时直接渲染内容
|
|
15
|
+
if (!title) {
|
|
16
|
+
return /*#__PURE__*/_jsx("div", {
|
|
19
17
|
className: "".concat(prefixCls, "-content"),
|
|
20
|
-
children:
|
|
21
|
-
})
|
|
22
|
-
}
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var items = useMemo(function () {
|
|
22
|
+
return [{
|
|
23
|
+
key: '1',
|
|
24
|
+
label: /*#__PURE__*/_jsx("div", {
|
|
25
|
+
className: "".concat(prefixCls, "-title"),
|
|
26
|
+
children: title
|
|
27
|
+
}),
|
|
28
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
29
|
+
className: "".concat(prefixCls, "-content"),
|
|
30
|
+
children: children
|
|
31
|
+
})
|
|
32
|
+
}];
|
|
33
|
+
}, [title, children, prefixCls]);
|
|
23
34
|
return /*#__PURE__*/_jsx(Collapse, {
|
|
24
35
|
className: prefixCls,
|
|
25
36
|
bordered: false,
|
package/es/vtx-image/Preview.js
CHANGED
|
@@ -22,15 +22,12 @@ var VIEWER = 'viewer';
|
|
|
22
22
|
// 多张
|
|
23
23
|
var GALLERY = 'gallery';
|
|
24
24
|
function checkMode(x) {
|
|
25
|
-
var mode = '';
|
|
26
|
-
if (isObject(x)) {
|
|
27
|
-
mode = VIEWER;
|
|
28
|
-
}
|
|
29
25
|
if (Array.isArray(x)) {
|
|
30
26
|
var len = x.length;
|
|
31
|
-
|
|
27
|
+
if (len === 0) return null;
|
|
28
|
+
return len === 1 ? VIEWER : GALLERY;
|
|
32
29
|
}
|
|
33
|
-
return
|
|
30
|
+
return isObject(x) ? VIEWER : null;
|
|
34
31
|
}
|
|
35
32
|
export default function Preview(props) {
|
|
36
33
|
var _useState = useState(),
|
|
@@ -87,6 +84,9 @@ export default function Preview(props) {
|
|
|
87
84
|
setContainer(container);
|
|
88
85
|
setViewer(viewer);
|
|
89
86
|
return function () {
|
|
87
|
+
if (container) {
|
|
88
|
+
container.innerHTML = '';
|
|
89
|
+
}
|
|
90
90
|
viewer && viewer.destroy();
|
|
91
91
|
};
|
|
92
92
|
}, []);
|
|
@@ -96,6 +96,7 @@ export default function Preview(props) {
|
|
|
96
96
|
container.innerHTML = '';
|
|
97
97
|
}
|
|
98
98
|
var mode = checkMode(photo);
|
|
99
|
+
if (!mode) return null;
|
|
99
100
|
var newIndex = index;
|
|
100
101
|
// 单张
|
|
101
102
|
if (mode === VIEWER) {
|
|
@@ -126,6 +127,10 @@ export default function Preview(props) {
|
|
|
126
127
|
}
|
|
127
128
|
viewer.update();
|
|
128
129
|
viewer.view(newIndex);
|
|
130
|
+
} else {
|
|
131
|
+
if (container) {
|
|
132
|
+
container.innerHTML = '';
|
|
133
|
+
}
|
|
129
134
|
}
|
|
130
135
|
}, [visible]);
|
|
131
136
|
return /*#__PURE__*/_jsx(_Fragment, {});
|
package/es/vtx-import/index.js
CHANGED
|
@@ -32,14 +32,19 @@ function VtxImport(props) {
|
|
|
32
32
|
var _useStyle = useStyle(prefixCls),
|
|
33
33
|
wrapSSR = _useStyle.wrapSSR,
|
|
34
34
|
hashId = _useStyle.hashId;
|
|
35
|
+
|
|
36
|
+
// 用 useRef 管理 DOM 引用,而不是 state
|
|
37
|
+
var fileInputRef = useRef(null);
|
|
38
|
+
var iframeRef = useRef(null);
|
|
39
|
+
var formRef = useRef(null);
|
|
40
|
+
|
|
41
|
+
// 用于追踪当前 XHR 请求,方便取消
|
|
42
|
+
var xhrRef = useRef(null);
|
|
35
43
|
var indexRef = useRef(0);
|
|
36
44
|
var _useSet = useSet({
|
|
37
|
-
fileForm: null,
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
// 保存上传的文件
|
|
41
|
-
iframe: null,
|
|
42
|
-
// form表单提交之后跳转的
|
|
45
|
+
// fileForm: null, // form表单
|
|
46
|
+
// fileInput: null, // 保存上传的文件
|
|
47
|
+
// iframe: null, // form表单提交之后跳转的
|
|
43
48
|
useFormData: window.FormData ? true : false,
|
|
44
49
|
// 是否查看
|
|
45
50
|
uploading: false,
|
|
@@ -102,7 +107,7 @@ function VtxImport(props) {
|
|
|
102
107
|
data.append('chunkNo', i + 1);
|
|
103
108
|
data.append('chunkId', state.chunkId);
|
|
104
109
|
data.append('tenantId', getVtxToken('tenantId'));
|
|
105
|
-
data.append('file', new File([e],
|
|
110
|
+
data.append('file', new File([e], fileInputRef.current.files[0].name));
|
|
106
111
|
dataArr.push(data);
|
|
107
112
|
});
|
|
108
113
|
uploadAsync(dataArr);
|
|
@@ -112,6 +117,7 @@ function VtxImport(props) {
|
|
|
112
117
|
function uploadAsync(list) {
|
|
113
118
|
if (indexRef.current < list.length) {
|
|
114
119
|
var xhr = new XMLHttpRequest();
|
|
120
|
+
xhrRef.current = xhr;
|
|
115
121
|
xhr.onload = function () {
|
|
116
122
|
if (xhr.status === 200) {
|
|
117
123
|
setState({
|
|
@@ -135,15 +141,27 @@ function VtxImport(props) {
|
|
|
135
141
|
// 合并分片
|
|
136
142
|
function mergeFile() {
|
|
137
143
|
var xhr = new XMLHttpRequest();
|
|
144
|
+
xhrRef.current = xhr;
|
|
138
145
|
// 当上传完成时调用
|
|
139
146
|
xhr.onload = function () {
|
|
140
147
|
if (xhr.status === 200) {
|
|
141
|
-
var
|
|
142
|
-
|
|
148
|
+
var _res;
|
|
149
|
+
var res;
|
|
150
|
+
try {
|
|
151
|
+
res = JSON.parse(xhr.responseText);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
message.error(intl.getMessage('import.error', '解析响应失败'));
|
|
154
|
+
setState({
|
|
155
|
+
uploading: false
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (((_res = res) === null || _res === void 0 ? void 0 : _res.result) == 0) {
|
|
143
160
|
message.success(intl.getMessage('import.success', '上传成功'));
|
|
144
161
|
chunkUpload(res.data);
|
|
145
162
|
} else {
|
|
146
|
-
|
|
163
|
+
var _res2;
|
|
164
|
+
message.error(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.msg) || intl.getMessage('import.error', '上传失败'));
|
|
147
165
|
}
|
|
148
166
|
}
|
|
149
167
|
};
|
|
@@ -156,7 +174,7 @@ function VtxImport(props) {
|
|
|
156
174
|
data.append('chunkId', state.chunkId);
|
|
157
175
|
data.append('tenantId', getVtxToken('tenantId'));
|
|
158
176
|
data.append('chunkSize', state.chunks.length);
|
|
159
|
-
data.append('fileName',
|
|
177
|
+
data.append('fileName', fileInputRef.current.files[0].name);
|
|
160
178
|
xhr.send(data);
|
|
161
179
|
}
|
|
162
180
|
|
|
@@ -166,6 +184,7 @@ function VtxImport(props) {
|
|
|
166
184
|
var postData = props.postData || {};
|
|
167
185
|
if (state.useFormData) {
|
|
168
186
|
var request = new XMLHttpRequest();
|
|
187
|
+
xhrRef.current = request;
|
|
169
188
|
// 发送请求
|
|
170
189
|
request.open('POST', postUrl);
|
|
171
190
|
request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
@@ -196,6 +215,7 @@ function VtxImport(props) {
|
|
|
196
215
|
var postData = props.postData || {};
|
|
197
216
|
if (state.useFormData) {
|
|
198
217
|
var request = new XMLHttpRequest();
|
|
218
|
+
xhrRef.current = request;
|
|
199
219
|
// 发送请求
|
|
200
220
|
request.open('POST', postUrl);
|
|
201
221
|
request.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
|
|
@@ -216,7 +236,7 @@ function VtxImport(props) {
|
|
|
216
236
|
};
|
|
217
237
|
//创建formdata对象
|
|
218
238
|
var fmd = new FormData();
|
|
219
|
-
fmd.append(state.fileKey,
|
|
239
|
+
fmd.append(state.fileKey, fileInputRef.current.files[0]);
|
|
220
240
|
request.send(fmd);
|
|
221
241
|
}
|
|
222
242
|
}
|
|
@@ -247,7 +267,9 @@ function VtxImport(props) {
|
|
|
247
267
|
return postArray.length > 0 ? "".concat(postUrl, "?").concat(postArray.join('&')) : postUrl;
|
|
248
268
|
};
|
|
249
269
|
var closeModal = function closeModal() {
|
|
250
|
-
|
|
270
|
+
if (fileInputRef.current) {
|
|
271
|
+
fileInputRef.current.value = '';
|
|
272
|
+
}
|
|
251
273
|
if (typeof props.close === 'function') {
|
|
252
274
|
props.close();
|
|
253
275
|
} else {
|
|
@@ -258,15 +280,24 @@ function VtxImport(props) {
|
|
|
258
280
|
};
|
|
259
281
|
// 上传之后的回调 - 展示报错信息
|
|
260
282
|
var uploadSuccess = function uploadSuccess(data) {
|
|
261
|
-
|
|
283
|
+
var _parseData;
|
|
284
|
+
if (fileInputRef.current) {
|
|
285
|
+
fileInputRef.current.value = '';
|
|
286
|
+
}
|
|
262
287
|
setState({
|
|
263
288
|
uploading: false
|
|
264
289
|
});
|
|
290
|
+
var parseData;
|
|
291
|
+
try {
|
|
292
|
+
parseData = JSON.parse(data);
|
|
293
|
+
} catch (e) {
|
|
294
|
+
message.error(intl.getMessage('import.error', '解析响应数据失败'));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
265
297
|
if (typeof props.afterUpload === 'function') {
|
|
266
298
|
afterUpload(data);
|
|
267
299
|
}
|
|
268
|
-
|
|
269
|
-
if (Array.isArray(parseData === null || parseData === void 0 ? void 0 : parseData.data)) {
|
|
300
|
+
if (Array.isArray((_parseData = parseData) === null || _parseData === void 0 ? void 0 : _parseData.data)) {
|
|
270
301
|
setState({
|
|
271
302
|
resultVisible: true,
|
|
272
303
|
resultData: parseData.data.map(function (item, index) {
|
|
@@ -281,7 +312,8 @@ function VtxImport(props) {
|
|
|
281
312
|
} else {
|
|
282
313
|
// 新增其他错误提示
|
|
283
314
|
if (parseData.result !== 0) {
|
|
284
|
-
|
|
315
|
+
var _parseData2;
|
|
316
|
+
message.error(((_parseData2 = parseData) === null || _parseData2 === void 0 ? void 0 : _parseData2.msg) || intl.getMessage('import.success', '上传成功'));
|
|
285
317
|
}
|
|
286
318
|
}
|
|
287
319
|
};
|
|
@@ -306,22 +338,21 @@ function VtxImport(props) {
|
|
|
306
338
|
type: "primary",
|
|
307
339
|
loading: state.uploading,
|
|
308
340
|
onClick: function onClick() {
|
|
341
|
+
var _fileInputRef$current2;
|
|
309
342
|
if (typeof props.beforeUpload === 'function') {
|
|
310
|
-
var
|
|
343
|
+
var _fileInputRef$current;
|
|
344
|
+
var flag = beforeUpload((_fileInputRef$current = fileInputRef.current) === null || _fileInputRef$current === void 0 || (_fileInputRef$current = _fileInputRef$current.files) === null || _fileInputRef$current === void 0 ? void 0 : _fileInputRef$current[0]);
|
|
311
345
|
if (!flag) {
|
|
312
|
-
|
|
313
|
-
setState({
|
|
314
|
-
fileInput: null
|
|
315
|
-
});
|
|
346
|
+
fileInputRef.current.value = '';
|
|
316
347
|
return;
|
|
317
348
|
}
|
|
318
349
|
}
|
|
319
|
-
if (
|
|
350
|
+
if ((_fileInputRef$current2 = fileInputRef.current) !== null && _fileInputRef$current2 !== void 0 && _fileInputRef$current2.value) {
|
|
320
351
|
setState({
|
|
321
352
|
uploading: true
|
|
322
353
|
});
|
|
323
354
|
// 上传文件
|
|
324
|
-
checkFile(
|
|
355
|
+
checkFile(fileInputRef.current.files[0]);
|
|
325
356
|
// const postUrl = getPostURL();
|
|
326
357
|
// if (state.useFormData) {
|
|
327
358
|
// const request = new XMLHttpRequest();
|
|
@@ -363,6 +394,21 @@ function VtxImport(props) {
|
|
|
363
394
|
},
|
|
364
395
|
modalWidth: state.modalWidth
|
|
365
396
|
};
|
|
397
|
+
|
|
398
|
+
// 组件卸载时清理
|
|
399
|
+
useEffect(function () {
|
|
400
|
+
return function () {
|
|
401
|
+
// 取消进行中的 XHR 请求
|
|
402
|
+
if (xhrRef.current) {
|
|
403
|
+
xhrRef.current.abort();
|
|
404
|
+
xhrRef.current = null;
|
|
405
|
+
}
|
|
406
|
+
// 清理文件输入
|
|
407
|
+
if (fileInputRef.current) {
|
|
408
|
+
fileInputRef.current.value = '';
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}, []);
|
|
366
412
|
useEffect(function () {
|
|
367
413
|
if (state.chunkId) {
|
|
368
414
|
startUpload();
|
|
@@ -374,25 +420,19 @@ function VtxImport(props) {
|
|
|
374
420
|
method: "post",
|
|
375
421
|
target: "tmp",
|
|
376
422
|
action: uploadURL,
|
|
377
|
-
ref:
|
|
378
|
-
if (dom) state.fileForm = dom;
|
|
379
|
-
},
|
|
423
|
+
ref: formRef,
|
|
380
424
|
children: /*#__PURE__*/_jsx("input", {
|
|
381
425
|
type: "file",
|
|
382
426
|
name: state.fileKey,
|
|
383
427
|
accept: state.accept,
|
|
384
|
-
ref:
|
|
385
|
-
if (dom) state.fileInput = dom;
|
|
386
|
-
}
|
|
428
|
+
ref: fileInputRef
|
|
387
429
|
})
|
|
388
430
|
}), /*#__PURE__*/_jsx("iframe", {
|
|
389
431
|
name: "tmp",
|
|
390
432
|
style: {
|
|
391
433
|
display: 'none'
|
|
392
434
|
},
|
|
393
|
-
ref:
|
|
394
|
-
if (dom) state.iframe = dom;
|
|
395
|
-
}
|
|
435
|
+
ref: iframeRef
|
|
396
436
|
}), state.resultVisible && /*#__PURE__*/_jsx(VtxImportResult, _objectSpread({}, resultProps))]
|
|
397
437
|
})));
|
|
398
438
|
}
|