@zat-design/sisyphus-react 3.5.1-beta.6 → 3.5.1-beta.8
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/ProDownload/index.js +6 -3
- package/es/ProDownload/propsType.d.ts +18 -13
- package/es/ProDownload/utils.d.ts +5 -0
- package/es/ProDownload/utils.js +14 -13
- package/es/ProEditTable/components/DndWrapper/index.js +1 -1
- package/lib/ProDownload/index.js +6 -3
- package/lib/ProDownload/propsType.d.ts +18 -13
- package/lib/ProDownload/utils.d.ts +5 -0
- package/lib/ProDownload/utils.js +14 -13
- package/lib/ProEditTable/components/DndWrapper/index.js +1 -1
- package/package.json +1 -1
package/es/ProDownload/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
5
5
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
6
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
|
-
var _excluded = ["source", "action", "url", "method", "params", "fileName", "children", "onFinish", "beforeDownload", "className", "transformResponse"];
|
|
8
|
+
var _excluded = ["source", "action", "url", "method", "params", "fileName", "children", "onFinish", "beforeDownload", "className", "transformResponse", "onError"];
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { useSetState } from 'ahooks';
|
|
11
11
|
import classNames from 'classnames';
|
|
@@ -24,6 +24,7 @@ var ProDownload = function ProDownload(props) {
|
|
|
24
24
|
beforeDownload = props.beforeDownload,
|
|
25
25
|
className = props.className,
|
|
26
26
|
transformResponse = props.transformResponse,
|
|
27
|
+
onError = props.onError,
|
|
27
28
|
defaultProps = _objectWithoutProperties(props, _excluded);
|
|
28
29
|
var _useSetState = useSetState({
|
|
29
30
|
loading: false
|
|
@@ -32,7 +33,8 @@ var ProDownload = function ProDownload(props) {
|
|
|
32
33
|
loading = _useSetState2[0].loading,
|
|
33
34
|
setState = _useSetState2[1];
|
|
34
35
|
var _ref = useProConfig('ProDownload') || {},
|
|
35
|
-
headers = _ref.headers
|
|
36
|
+
headers = _ref.headers,
|
|
37
|
+
onErrorConfig = _ref.onError;
|
|
36
38
|
defaultProps.headers = _objectSpread(_objectSpread({}, headers), defaultProps.headers);
|
|
37
39
|
var handDownload = /*#__PURE__*/function () {
|
|
38
40
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -94,7 +96,8 @@ var ProDownload = function ProDownload(props) {
|
|
|
94
96
|
params: _params,
|
|
95
97
|
transformResponse: transformResponse,
|
|
96
98
|
fileName: fileName,
|
|
97
|
-
onFinish: onFinish
|
|
99
|
+
onFinish: onFinish,
|
|
100
|
+
onError: onError || onErrorConfig
|
|
98
101
|
});
|
|
99
102
|
case 17:
|
|
100
103
|
_context.next = 23;
|
|
@@ -8,9 +8,9 @@ export interface IProDownloadProps extends ButtonProps {
|
|
|
8
8
|
*/
|
|
9
9
|
source?: string;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
* @description 下载请求的地址
|
|
12
|
+
* @default (必选)
|
|
13
|
+
*/
|
|
14
14
|
url: string;
|
|
15
15
|
/**
|
|
16
16
|
* @description 下载请求的地址
|
|
@@ -39,21 +39,26 @@ export interface IProDownloadProps extends ButtonProps {
|
|
|
39
39
|
*/
|
|
40
40
|
headers?: object;
|
|
41
41
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
* @description 禁用状态
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
45
|
disabled?: boolean;
|
|
46
46
|
/** 格式化数据 */
|
|
47
47
|
transformResponse?: (data: any) => any;
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
beforeDownload?: (
|
|
49
|
+
* @description 上传文件之前的钩子,若返回 false 则停止下载。支持返回一个 Promise 对象,Promise 对象 reject 时则停止下载
|
|
50
|
+
* @default -
|
|
51
|
+
*/
|
|
52
|
+
beforeDownload?: () => boolean | Promise<any>;
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
* @description service 执行完成时触发
|
|
55
|
+
* @default -
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* @description 下载出错的回调
|
|
59
|
+
* @default -
|
|
60
|
+
*/
|
|
61
|
+
onError?: (response: object) => void;
|
|
57
62
|
onFinish?: () => void;
|
|
58
63
|
/**
|
|
59
64
|
* @description 下载按钮的填充内容
|
package/es/ProDownload/utils.js
CHANGED
|
@@ -71,11 +71,11 @@ export function getFilenameFromContentDisposition(contentDisposition) {
|
|
|
71
71
|
// 发起请求获取下载文件
|
|
72
72
|
export var DownloadRequest = /*#__PURE__*/function () {
|
|
73
73
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
|
|
74
|
-
var url, _ref2$method, method, params, headers, transformResponse, fileName, onFinish, config, res, fileBlob, data, contentFileName;
|
|
74
|
+
var url, _ref2$method, method, params, headers, transformResponse, fileName, onFinish, onError, config, res, fileBlob, data, contentFileName;
|
|
75
75
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
76
76
|
while (1) switch (_context2.prev = _context2.next) {
|
|
77
77
|
case 0:
|
|
78
|
-
url = _ref2.url, _ref2$method = _ref2.method, method = _ref2$method === void 0 ? 'post' : _ref2$method, params = _ref2.params, headers = _ref2.headers, transformResponse = _ref2.transformResponse, fileName = _ref2.fileName, onFinish = _ref2.onFinish;
|
|
78
|
+
url = _ref2.url, _ref2$method = _ref2.method, method = _ref2$method === void 0 ? 'post' : _ref2$method, params = _ref2.params, headers = _ref2.headers, transformResponse = _ref2.transformResponse, fileName = _ref2.fileName, onFinish = _ref2.onFinish, onError = _ref2.onError;
|
|
79
79
|
config = {
|
|
80
80
|
method: method,
|
|
81
81
|
credentials: 'include',
|
|
@@ -116,37 +116,38 @@ export var DownloadRequest = /*#__PURE__*/function () {
|
|
|
116
116
|
return _context.abrupt("return", Promise.reject("".concat(locale.ProDownload.errorMessage)));
|
|
117
117
|
case 7:
|
|
118
118
|
if (!((_data === null || _data === void 0 ? void 0 : _data.status) > 200 || (_data === null || _data === void 0 ? void 0 : _data.code) === 401)) {
|
|
119
|
-
_context.next =
|
|
119
|
+
_context.next = 12;
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
122
|
errorMsg = (_data === null || _data === void 0 ? void 0 : _data.message) || (_data === null || _data === void 0 ? void 0 : _data.msg);
|
|
123
123
|
errorMsg && _message.error(errorMsg);
|
|
124
|
+
onError && onError(_data);
|
|
124
125
|
return _context.abrupt("return", Promise.reject(errorMsg));
|
|
125
|
-
case
|
|
126
|
+
case 12:
|
|
126
127
|
if (!isFunction(transformResponse)) {
|
|
127
|
-
_context.next =
|
|
128
|
+
_context.next = 14;
|
|
128
129
|
break;
|
|
129
130
|
}
|
|
130
131
|
return _context.abrupt("return", Promise.resolve(transformResponse(_data)));
|
|
131
|
-
case
|
|
132
|
+
case 14:
|
|
132
133
|
Promise.resolve(_data);
|
|
133
|
-
_context.next =
|
|
134
|
+
_context.next = 21;
|
|
134
135
|
break;
|
|
135
|
-
case
|
|
136
|
-
_context.prev =
|
|
136
|
+
case 17:
|
|
137
|
+
_context.prev = 17;
|
|
137
138
|
_context.t0 = _context["catch"](0);
|
|
138
139
|
if (!response.ok) {
|
|
139
|
-
_context.next =
|
|
140
|
+
_context.next = 21;
|
|
140
141
|
break;
|
|
141
142
|
}
|
|
142
143
|
return _context.abrupt("return", Promise.resolve(response));
|
|
143
|
-
case 20:
|
|
144
|
-
return _context.abrupt("return", Promise.reject("".concat(locale.ProDownload.errorMessage)));
|
|
145
144
|
case 21:
|
|
145
|
+
return _context.abrupt("return", Promise.reject("".concat(locale.ProDownload.errorMessage)));
|
|
146
|
+
case 22:
|
|
146
147
|
case "end":
|
|
147
148
|
return _context.stop();
|
|
148
149
|
}
|
|
149
|
-
}, _callee, null, [[0,
|
|
150
|
+
}, _callee, null, [[0, 17]]);
|
|
150
151
|
}));
|
|
151
152
|
return function (_x2) {
|
|
152
153
|
return _ref4.apply(this, arguments);
|
|
@@ -36,7 +36,7 @@ export var Row = function Row(props) {
|
|
|
36
36
|
style: style
|
|
37
37
|
}, attributes), {}, {
|
|
38
38
|
children: React.Children.map(children, function (child) {
|
|
39
|
-
if (child.key === 'RC_TABLE_KEY') {
|
|
39
|
+
if (child.key === 'RC_TABLE_KEY' && !disabled) {
|
|
40
40
|
var _ref = (child === null || child === void 0 ? void 0 : child.props) || {},
|
|
41
41
|
render = _ref.render,
|
|
42
42
|
record = _ref.record,
|
package/lib/ProDownload/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
18
18
|
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
19
19
|
var _utils = require("./utils");
|
|
20
20
|
var _ProConfigProvider = require("../ProConfigProvider");
|
|
21
|
-
var _excluded = ["source", "action", "url", "method", "params", "fileName", "children", "onFinish", "beforeDownload", "className", "transformResponse"];
|
|
21
|
+
var _excluded = ["source", "action", "url", "method", "params", "fileName", "children", "onFinish", "beforeDownload", "className", "transformResponse", "onError"];
|
|
22
22
|
var ProDownload = function ProDownload(props) {
|
|
23
23
|
var source = props.source,
|
|
24
24
|
action = props.action,
|
|
@@ -31,6 +31,7 @@ var ProDownload = function ProDownload(props) {
|
|
|
31
31
|
beforeDownload = props.beforeDownload,
|
|
32
32
|
className = props.className,
|
|
33
33
|
transformResponse = props.transformResponse,
|
|
34
|
+
onError = props.onError,
|
|
34
35
|
defaultProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
35
36
|
var _useSetState = (0, _ahooks.useSetState)({
|
|
36
37
|
loading: false
|
|
@@ -39,7 +40,8 @@ var ProDownload = function ProDownload(props) {
|
|
|
39
40
|
loading = _useSetState2[0].loading,
|
|
40
41
|
setState = _useSetState2[1];
|
|
41
42
|
var _ref = (0, _ProConfigProvider.useProConfig)('ProDownload') || {},
|
|
42
|
-
headers = _ref.headers
|
|
43
|
+
headers = _ref.headers,
|
|
44
|
+
onErrorConfig = _ref.onError;
|
|
43
45
|
defaultProps.headers = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, headers), defaultProps.headers);
|
|
44
46
|
var handDownload = /*#__PURE__*/function () {
|
|
45
47
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
|
|
@@ -101,7 +103,8 @@ var ProDownload = function ProDownload(props) {
|
|
|
101
103
|
params: _params,
|
|
102
104
|
transformResponse: transformResponse,
|
|
103
105
|
fileName: fileName,
|
|
104
|
-
onFinish: onFinish
|
|
106
|
+
onFinish: onFinish,
|
|
107
|
+
onError: onError || onErrorConfig
|
|
105
108
|
});
|
|
106
109
|
case 17:
|
|
107
110
|
_context.next = 23;
|
|
@@ -8,9 +8,9 @@ export interface IProDownloadProps extends ButtonProps {
|
|
|
8
8
|
*/
|
|
9
9
|
source?: string;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
* @description 下载请求的地址
|
|
12
|
+
* @default (必选)
|
|
13
|
+
*/
|
|
14
14
|
url: string;
|
|
15
15
|
/**
|
|
16
16
|
* @description 下载请求的地址
|
|
@@ -39,21 +39,26 @@ export interface IProDownloadProps extends ButtonProps {
|
|
|
39
39
|
*/
|
|
40
40
|
headers?: object;
|
|
41
41
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
* @description 禁用状态
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
45
|
disabled?: boolean;
|
|
46
46
|
/** 格式化数据 */
|
|
47
47
|
transformResponse?: (data: any) => any;
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
beforeDownload?: (
|
|
49
|
+
* @description 上传文件之前的钩子,若返回 false 则停止下载。支持返回一个 Promise 对象,Promise 对象 reject 时则停止下载
|
|
50
|
+
* @default -
|
|
51
|
+
*/
|
|
52
|
+
beforeDownload?: () => boolean | Promise<any>;
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
* @description service 执行完成时触发
|
|
55
|
+
* @default -
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* @description 下载出错的回调
|
|
59
|
+
* @default -
|
|
60
|
+
*/
|
|
61
|
+
onError?: (response: object) => void;
|
|
57
62
|
onFinish?: () => void;
|
|
58
63
|
/**
|
|
59
64
|
* @description 下载按钮的填充内容
|
package/lib/ProDownload/utils.js
CHANGED
|
@@ -80,11 +80,11 @@ function getFilenameFromContentDisposition(contentDisposition) {
|
|
|
80
80
|
// 发起请求获取下载文件
|
|
81
81
|
var DownloadRequest = exports.DownloadRequest = /*#__PURE__*/function () {
|
|
82
82
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(_ref2) {
|
|
83
|
-
var url, _ref2$method, method, params, headers, transformResponse, fileName, onFinish, config, res, fileBlob, data, contentFileName;
|
|
83
|
+
var url, _ref2$method, method, params, headers, transformResponse, fileName, onFinish, onError, config, res, fileBlob, data, contentFileName;
|
|
84
84
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
85
85
|
while (1) switch (_context2.prev = _context2.next) {
|
|
86
86
|
case 0:
|
|
87
|
-
url = _ref2.url, _ref2$method = _ref2.method, method = _ref2$method === void 0 ? 'post' : _ref2$method, params = _ref2.params, headers = _ref2.headers, transformResponse = _ref2.transformResponse, fileName = _ref2.fileName, onFinish = _ref2.onFinish;
|
|
87
|
+
url = _ref2.url, _ref2$method = _ref2.method, method = _ref2$method === void 0 ? 'post' : _ref2$method, params = _ref2.params, headers = _ref2.headers, transformResponse = _ref2.transformResponse, fileName = _ref2.fileName, onFinish = _ref2.onFinish, onError = _ref2.onError;
|
|
88
88
|
config = {
|
|
89
89
|
method: method,
|
|
90
90
|
credentials: 'include',
|
|
@@ -125,37 +125,38 @@ var DownloadRequest = exports.DownloadRequest = /*#__PURE__*/function () {
|
|
|
125
125
|
return _context.abrupt("return", Promise.reject("".concat(_locale.default.ProDownload.errorMessage)));
|
|
126
126
|
case 7:
|
|
127
127
|
if (!((_data === null || _data === void 0 ? void 0 : _data.status) > 200 || (_data === null || _data === void 0 ? void 0 : _data.code) === 401)) {
|
|
128
|
-
_context.next =
|
|
128
|
+
_context.next = 12;
|
|
129
129
|
break;
|
|
130
130
|
}
|
|
131
131
|
errorMsg = (_data === null || _data === void 0 ? void 0 : _data.message) || (_data === null || _data === void 0 ? void 0 : _data.msg);
|
|
132
132
|
errorMsg && _antd.message.error(errorMsg);
|
|
133
|
+
onError && onError(_data);
|
|
133
134
|
return _context.abrupt("return", Promise.reject(errorMsg));
|
|
134
|
-
case
|
|
135
|
+
case 12:
|
|
135
136
|
if (!(0, _lodash.isFunction)(transformResponse)) {
|
|
136
|
-
_context.next =
|
|
137
|
+
_context.next = 14;
|
|
137
138
|
break;
|
|
138
139
|
}
|
|
139
140
|
return _context.abrupt("return", Promise.resolve(transformResponse(_data)));
|
|
140
|
-
case
|
|
141
|
+
case 14:
|
|
141
142
|
Promise.resolve(_data);
|
|
142
|
-
_context.next =
|
|
143
|
+
_context.next = 21;
|
|
143
144
|
break;
|
|
144
|
-
case
|
|
145
|
-
_context.prev =
|
|
145
|
+
case 17:
|
|
146
|
+
_context.prev = 17;
|
|
146
147
|
_context.t0 = _context["catch"](0);
|
|
147
148
|
if (!response.ok) {
|
|
148
|
-
_context.next =
|
|
149
|
+
_context.next = 21;
|
|
149
150
|
break;
|
|
150
151
|
}
|
|
151
152
|
return _context.abrupt("return", Promise.resolve(response));
|
|
152
|
-
case 20:
|
|
153
|
-
return _context.abrupt("return", Promise.reject("".concat(_locale.default.ProDownload.errorMessage)));
|
|
154
153
|
case 21:
|
|
154
|
+
return _context.abrupt("return", Promise.reject("".concat(_locale.default.ProDownload.errorMessage)));
|
|
155
|
+
case 22:
|
|
155
156
|
case "end":
|
|
156
157
|
return _context.stop();
|
|
157
158
|
}
|
|
158
|
-
}, _callee, null, [[0,
|
|
159
|
+
}, _callee, null, [[0, 17]]);
|
|
159
160
|
}));
|
|
160
161
|
return function (_x2) {
|
|
161
162
|
return _ref4.apply(this, arguments);
|
|
@@ -43,7 +43,7 @@ var Row = exports.Row = function Row(props) {
|
|
|
43
43
|
style: style
|
|
44
44
|
}, attributes), {}, {
|
|
45
45
|
children: _react.default.Children.map(children, function (child) {
|
|
46
|
-
if (child.key === 'RC_TABLE_KEY') {
|
|
46
|
+
if (child.key === 'RC_TABLE_KEY' && !disabled) {
|
|
47
47
|
var _ref = (child === null || child === void 0 ? void 0 : child.props) || {},
|
|
48
48
|
render = _ref.render,
|
|
49
49
|
record = _ref.record,
|