ronds-metadata 1.2.38 → 1.2.39
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/api/index.js +83 -131
- package/es/comps/DynamicPorts/comps/ContextMenu.js +3 -11
- package/es/comps/DynamicPorts/comps/DragNode.js +2 -7
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +4 -5
- package/es/comps/DynamicPorts/comps/NodeElement.js +1 -4
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +3 -6
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +3 -7
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +18 -21
- package/es/comps/DynamicPorts/comps/shape/edge.js +5 -18
- package/es/comps/DynamicPorts/comps/shape/node.js +4 -17
- package/es/comps/DynamicPorts/constant/index.js +2 -5
- package/es/comps/DynamicPorts/graph.d.ts +2 -2
- package/es/comps/DynamicPorts/graph.js +228 -312
- package/es/comps/DynamicPorts/index.js +39 -58
- package/es/comps/DynamicPorts/utils.js +21 -25
- package/es/comps/Editable/DataCell/ButtonCell.js +4 -10
- package/es/comps/Editable/DataCell/ColorPicker.js +2 -7
- package/es/comps/Editable/DataCell/Input.js +5 -14
- package/es/comps/Editable/DataCell/Number.js +3 -10
- package/es/comps/Editable/DataCell/Select.js +7 -14
- package/es/comps/Editable/DataCell/Switch.js +2 -7
- package/es/comps/Editable/comps/EditableAction.js +8 -12
- package/es/comps/Editable/comps/EditableCell.js +16 -26
- package/es/comps/Editable/comps/EditableHeardCell.js +21 -34
- package/es/comps/Editable/comps/EditableRow.js +49 -59
- package/es/comps/Editable/comps/Texty.js +36 -72
- package/es/comps/Editable/index.js +67 -112
- package/es/comps/Editable/interface.d.ts +1 -1
- package/es/comps/Editable/utils.js +0 -1
- package/es/comps/FileView/index.js +65 -101
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +8 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +6 -10
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +8 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +6 -10
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +6 -3
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +2 -5
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +86 -109
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +3 -7
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +54 -91
- package/es/comps/FormGenerator/comps/Canvas/core/index.less +23 -23
- package/es/comps/FormGenerator/comps/Canvas/index.js +8 -15
- package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
- package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
- package/es/comps/FormGenerator/index.js +3 -9
- package/es/comps/FormGenerator/interface.d.ts +1 -1
- package/es/comps/FormGenerator/settings/index.js +12 -11
- package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
- package/es/comps/FormGenerator/transformer.js +40 -105
- package/es/comps/Icons/index.js +4 -7
- package/es/comps/JsonEdit/index.js +25 -50
- package/es/comps/JsonView/index.js +7 -21
- package/es/comps/JsonView/index.less +41 -41
- package/es/comps/MdEdit/index.js +7 -10
- package/es/comps/MdEdit/index.less +6 -6
- package/es/comps/MdEditPro/index.d.ts +10 -0
- package/es/comps/MdEditPro/index.js +22 -0
- package/es/comps/MdEditPro/index.less +74 -0
- package/es/comps/MdNavbar/index.js +17 -40
- package/es/comps/MdNavbar/utils.js +0 -4
- package/es/comps/MdView/index.js +7 -11
- package/es/comps/MdView/index.less +353 -353
- package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
- package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
- package/es/comps/MetadataEdit/hooks/index.js +3 -11
- package/es/comps/MetadataEdit/index.js +25 -58
- package/es/comps/MetadataEdit/index.less +10 -10
- package/es/comps/MetadataEdit/type.d.ts +20 -20
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
- package/es/comps/MetadataEditV2/hooks/index.js +5 -12
- package/es/comps/MetadataEditV2/index.js +30 -65
- package/es/comps/MetadataForm/DataCell/Array.js +12 -23
- package/es/comps/MetadataForm/DataCell/Input.js +12 -32
- package/es/comps/MetadataForm/DataCell/Number.js +10 -21
- package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
- package/es/comps/MetadataForm/DataCell/Select.js +127 -222
- package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +93 -164
- package/es/comps/MetadataForm/HOC/index.js +20 -37
- package/es/comps/MetadataForm/HOC/index.less +41 -41
- package/es/comps/MetadataForm/hooks/index.js +12 -38
- package/es/comps/MetadataForm/index.js +37 -72
- package/es/comps/MetadataForm/interface.d.ts +3 -3
- package/es/comps/MetadataForm/utils.js +0 -14
- package/es/comps/Split/index.js +20 -22
- package/es/config.js +0 -4
- package/es/framework/RxStore/demo/index.js +9 -10
- package/es/framework/RxStore/hooks.d.ts +9 -9
- package/es/framework/RxStore/hooks.js +10 -35
- package/es/framework/RxStore/store.d.ts +4 -4
- package/es/framework/RxStore/store.js +0 -10
- package/es/framework/fg/index.js +18 -80
- package/es/framework/fg/interface.d.ts +2 -2
- package/es/framework/fg/utils.js +0 -10
- package/es/framework/graph/index.d.ts +2 -2
- package/es/framework/graph/index.js +55 -110
- package/es/framework/hooks/use-async-memo.js +3 -7
- package/es/framework/hooks/use-sync-scroll.js +2 -15
- package/es/framework/http/cache.js +25 -32
- package/es/framework/http/cancel.js +1 -7
- package/es/framework/http/index.js +22 -82
- package/es/framework/http/msgpack.js +0 -4
- package/es/framework/http/msgpack5/index.js +2 -12
- package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
- package/es/framework/http/msgpack5/lib/decoder.js +10 -68
- package/es/framework/http/msgpack5/lib/encoder.js +8 -36
- package/es/framework/http/msgpack5/lib/helpers.js +3 -2
- package/es/framework/http/msgpack5/lib/streams.js +0 -18
- package/es/framework/libs/jquery.min.js +1009 -1696
- package/es/framework/locale/dil8/di18n.js +4 -15
- package/es/framework/locale/dil8/translate.js +0 -14
- package/es/framework/locale/dil8/util.js +0 -3
- package/es/framework/locale/index.js +2 -3
- package/es/framework/metadata/MetadataService.js +39 -78
- package/es/framework/metadata/index.js +4 -70
- package/es/framework/metadata/types.d.ts +98 -98
- package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
- package/es/framework/rxjs-hooks/useObservable.js +2 -4
- package/es/framework/rxjs-hooks/useObservableState.js +8 -14
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/theme.less +79 -79
- package/es/utils.js +58 -97
- package/package.json +104 -102
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
4
|
import { cloneDeep } from 'lodash';
|
|
4
5
|
/**
|
|
@@ -6,32 +7,36 @@ import { cloneDeep } from 'lodash';
|
|
|
6
7
|
*
|
|
7
8
|
* @class httpCache
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
var HttpCache = function HttpCache() {
|
|
10
|
+
var HttpCache = /*#__PURE__*/_createClass(function HttpCache() {
|
|
11
11
|
var _this = this;
|
|
12
|
-
|
|
13
12
|
_classCallCheck(this, HttpCache);
|
|
14
|
-
|
|
13
|
+
// 缓存数据
|
|
15
14
|
this._Data = {};
|
|
15
|
+
/** 缓存最大数量 默认500 */
|
|
16
16
|
this.maxCount = 100;
|
|
17
|
+
/** 过期时间 单位s 默认值600 */
|
|
17
18
|
this.expirys = 600;
|
|
18
|
-
|
|
19
|
+
/** 允许缓存的url 只要请求url包含就命中 */
|
|
20
|
+
this.urlKeys = [
|
|
21
|
+
// `objectStorage/objectStream`,
|
|
19
22
|
// `/OriginalVibWaveData`,
|
|
20
|
-
'OrderData', 'ProcessPointGroups', 'AngleWave', 'IndexCfgs',
|
|
21
|
-
|
|
23
|
+
'OrderData', 'ProcessPointGroups', 'AngleWave', 'IndexCfgs',
|
|
24
|
+
// 'OriginalVibWave', //原始波形
|
|
25
|
+
'Spectrum', '/TimeScales', '/Sections/', 'Cepstrum', 'DynamicPoints', 'CrossPhase', 'HighFreMeasdefID', 'SolutionAveSquareRoot',
|
|
26
|
+
// 'OriginalVibWaveData',
|
|
22
27
|
'SolutionAveSquareRootSpectrum', 'LogSpectrum', 'SolutionAveSquareRootLogSpectrum', 'GetTraitDatasWithMultiType', 'HarmonicDistortion'];
|
|
23
|
-
|
|
28
|
+
/** 设置缓存的url */
|
|
24
29
|
this.setCacheUrlKeys = function (urls) {
|
|
25
30
|
_this.urlKeys = urls;
|
|
26
31
|
};
|
|
27
|
-
|
|
32
|
+
/** 重置缓存 */
|
|
28
33
|
this.resetCache = function () {
|
|
29
34
|
_this._Data = {};
|
|
30
35
|
};
|
|
31
|
-
|
|
36
|
+
/** 生成缓存的Key */
|
|
32
37
|
this.generateCode = function (url, options) {
|
|
33
|
-
var allow = false;
|
|
34
|
-
|
|
38
|
+
var allow = false;
|
|
39
|
+
//如果不允许做缓存
|
|
35
40
|
_this.urlKeys && _this.urlKeys.forEach(function (item) {
|
|
36
41
|
if (url.indexOf(item) >= 0) {
|
|
37
42
|
allow = true;
|
|
@@ -47,20 +52,17 @@ var HttpCache = function HttpCache() {
|
|
|
47
52
|
var fingerprint = url + JSON.stringify(params).replace(new RegExp(/( )/g), '');
|
|
48
53
|
return fingerprint;
|
|
49
54
|
};
|
|
50
|
-
|
|
55
|
+
/** 添加缓存 */
|
|
51
56
|
this.Add = function (url, options, data) {
|
|
52
57
|
if ((options === null || options === void 0 ? void 0 : options.method) !== 'get' && (options === null || options === void 0 ? void 0 : options.method) !== 'GET') {
|
|
53
58
|
return;
|
|
54
59
|
}
|
|
55
|
-
|
|
56
60
|
var hashCode = _this.generateCode(url, options) || '';
|
|
57
|
-
|
|
58
61
|
if (!url || !data || !data.data) {
|
|
59
62
|
return;
|
|
60
63
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
var allow = false;
|
|
65
|
+
//如果不允许做缓存
|
|
64
66
|
_this.urlKeys && _this.urlKeys.forEach(function (item) {
|
|
65
67
|
if (url.indexOf(item) >= 0) {
|
|
66
68
|
allow = true;
|
|
@@ -69,41 +71,34 @@ var HttpCache = function HttpCache() {
|
|
|
69
71
|
});
|
|
70
72
|
if (!allow) return;
|
|
71
73
|
var arr = Object.keys(_this._Data);
|
|
72
|
-
|
|
73
74
|
if (arr.length >= _this.maxCount) {
|
|
74
75
|
_this.Delete(arr[0]);
|
|
75
76
|
}
|
|
76
|
-
|
|
77
77
|
_this._Data[hashCode] = {
|
|
78
78
|
data: cloneDeep(data),
|
|
79
79
|
timestamp: Date.now()
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
|
-
|
|
82
|
+
/** 删除某一缓存项 */
|
|
83
83
|
this.Delete = function (hashCode) {
|
|
84
84
|
_this._Data[hashCode] = null;
|
|
85
85
|
delete _this._Data[hashCode];
|
|
86
86
|
};
|
|
87
|
-
|
|
87
|
+
/** 获取缓存 */
|
|
88
88
|
this.Get = function (url, options) {
|
|
89
89
|
if ((options === null || options === void 0 ? void 0 : options.method) !== 'get' && (options === null || options === void 0 ? void 0 : options.method) !== 'GET') {
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
|
-
|
|
93
92
|
if ((options === null || options === void 0 ? void 0 : options.cache) === false) {
|
|
94
93
|
return null;
|
|
95
94
|
}
|
|
96
|
-
|
|
97
95
|
var hashCode = _this.generateCode(url, options) || '';
|
|
98
|
-
|
|
99
96
|
try {
|
|
100
97
|
var cached = _this._Data[hashCode];
|
|
101
|
-
|
|
102
98
|
if (cached && cached.data && cached.timestamp) {
|
|
103
99
|
var expirys = _this.expirys;
|
|
104
100
|
var whenCached = cached.timestamp;
|
|
105
101
|
var age = (Date.now() - whenCached) / 1000;
|
|
106
|
-
|
|
107
102
|
if (age < expirys) {
|
|
108
103
|
// 防止外部修改数据
|
|
109
104
|
return cloneDeep(cached.data);
|
|
@@ -112,15 +107,14 @@ var HttpCache = function HttpCache() {
|
|
|
112
107
|
}
|
|
113
108
|
}
|
|
114
109
|
} catch (e) {}
|
|
115
|
-
|
|
116
110
|
return null;
|
|
117
111
|
};
|
|
118
|
-
|
|
112
|
+
/** 清除缓存 */
|
|
119
113
|
this.Clear = function () {
|
|
120
114
|
// this._Data = undefined;
|
|
121
115
|
_this._Data = {};
|
|
122
116
|
};
|
|
123
|
-
|
|
117
|
+
/** 根据缓存key 批量删除缓存 */
|
|
124
118
|
this.clearByUrlKey = function (key) {
|
|
125
119
|
if (_this._Data) {
|
|
126
120
|
Object.keys(_this._Data).forEach(function (cKey) {
|
|
@@ -131,7 +125,6 @@ var HttpCache = function HttpCache() {
|
|
|
131
125
|
});
|
|
132
126
|
}
|
|
133
127
|
};
|
|
134
|
-
};
|
|
135
|
-
|
|
128
|
+
});
|
|
136
129
|
window.rondsGraphCache = window.rondsGraphCache ? window.rondsGraphCache : new HttpCache();
|
|
137
130
|
export default window.rondsGraphCache;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
export var cancelTokenMap = {};
|
|
3
3
|
/** 取消请求 */
|
|
4
|
-
|
|
5
4
|
export function cancelRequest(url) {
|
|
6
5
|
if (cancelTokenMap && cancelTokenMap[url]) {
|
|
7
6
|
cancelTokenMap[url].cancel();
|
|
8
7
|
delete cancelTokenMap[url];
|
|
9
8
|
return true;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
return false;
|
|
13
11
|
}
|
|
14
12
|
export function setupCancelInterceptors(httpClient) {
|
|
@@ -16,25 +14,21 @@ export function setupCancelInterceptors(httpClient) {
|
|
|
16
14
|
if (response.config.url) {
|
|
17
15
|
delete cancelTokenMap[response.config.url];
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
return response;
|
|
21
18
|
}, function (e) {
|
|
22
19
|
try {
|
|
23
20
|
var _e$config = e.config,
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
config = _e$config === void 0 ? {} : _e$config;
|
|
26
22
|
if (config.url) {
|
|
27
23
|
delete cancelTokenMap[config.url];
|
|
28
24
|
}
|
|
29
25
|
} catch (ex) {}
|
|
30
|
-
|
|
31
26
|
return e;
|
|
32
27
|
});
|
|
33
28
|
httpClient.interceptors.request.use(function (config) {
|
|
34
29
|
if (config.cancelToken) {
|
|
35
30
|
return config;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
var cancelToken = axios.CancelToken.source();
|
|
39
33
|
config = config || {};
|
|
40
34
|
config.cancelToken = cancelToken.token;
|
|
@@ -7,30 +7,24 @@ import httpCache from './cache';
|
|
|
7
7
|
import qs from 'qs';
|
|
8
8
|
import { setupMsgPackInterceptors } from './msgpack';
|
|
9
9
|
import { getConfig } from '../../config';
|
|
10
|
-
|
|
11
10
|
function changeStr(str, index, changeStr) {
|
|
12
11
|
return str.substr(0, index) + changeStr + str.substr(index + changeStr.length);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
function nameTo_(object) {
|
|
16
14
|
if (!object) {
|
|
17
15
|
return object;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
var regObj = new RegExp('([A-Z])', 'g');
|
|
21
|
-
|
|
22
18
|
for (var i in object) {
|
|
23
19
|
if (object.hasOwnProperty(i)) {
|
|
24
20
|
var temp = object[i];
|
|
25
21
|
var first = i[0].toString();
|
|
26
22
|
regObj.lastIndex = 0;
|
|
27
|
-
|
|
28
23
|
if (regObj.test(first)) {
|
|
29
24
|
var newStr = changeStr(i, 0, first.toLowerCase());
|
|
30
25
|
object[newStr] = object[i];
|
|
31
26
|
delete object[i];
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
if (_typeof(temp) === 'object' || Object.prototype.toString.call(temp) === '[object Array]') {
|
|
35
29
|
if (Array.isArray(temp)) {
|
|
36
30
|
if (_typeof(temp[0]) === 'object' || Object.prototype.toString.call(temp[0]) === '[object Array]') {
|
|
@@ -42,16 +36,13 @@ function nameTo_(object) {
|
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
return object;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
41
|
var defaultOptions = {
|
|
50
42
|
credentials: 'include',
|
|
51
43
|
timeout: 30 * 1000 //超时时间
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
};
|
|
45
|
+
//上传文件需要上传凭证设置为true
|
|
55
46
|
var httpClient = axios.create({
|
|
56
47
|
withCredentials: true
|
|
57
48
|
});
|
|
@@ -63,19 +54,19 @@ httpClient.defaults.timeout = defaultOptions.timeout;
|
|
|
63
54
|
* @class BaseResData
|
|
64
55
|
* @template T
|
|
65
56
|
*/
|
|
66
|
-
|
|
67
|
-
export var BaseResData = function BaseResData(data, successed) {
|
|
57
|
+
export var BaseResData = /*#__PURE__*/_createClass(function BaseResData(data, successed) {
|
|
68
58
|
var msg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
69
59
|
var status = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 200;
|
|
70
60
|
var errData = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
71
61
|
var response = arguments.length > 5 ? arguments[5] : undefined;
|
|
72
|
-
|
|
73
62
|
_classCallCheck(this, BaseResData);
|
|
74
|
-
|
|
75
63
|
this.response = void 0;
|
|
76
64
|
this.status = void 0;
|
|
65
|
+
/** 请求返回的数据 */
|
|
77
66
|
this.data = void 0;
|
|
67
|
+
/**请求是否成功 */
|
|
78
68
|
this.successed = void 0;
|
|
69
|
+
/**请求失败的消息 */
|
|
79
70
|
this.msg = void 0;
|
|
80
71
|
this.errorData = void 0;
|
|
81
72
|
this.data = nameTo_(data);
|
|
@@ -86,141 +77,107 @@ export var BaseResData = function BaseResData(data, successed) {
|
|
|
86
77
|
this.errorData = errData;
|
|
87
78
|
this.errorData = errData;
|
|
88
79
|
this.msg = msg ? msg : getErrorMessage(this);
|
|
89
|
-
|
|
90
80
|
if (this.msg) {
|
|
91
81
|
this.successed = false;
|
|
92
82
|
}
|
|
93
|
-
|
|
94
83
|
if (this.successed === false) {
|
|
95
84
|
this.data = undefined;
|
|
96
85
|
}
|
|
97
|
-
};
|
|
98
|
-
|
|
86
|
+
});
|
|
87
|
+
//数据转换拦截器
|
|
99
88
|
httpClient.interceptors.response.use(function (response) {
|
|
100
89
|
//正常数据
|
|
101
90
|
if (response.status >= 200 && response.status <= 300) {
|
|
102
91
|
var _response$data2, _response$data3;
|
|
103
|
-
|
|
104
92
|
// 如果自定义转换
|
|
105
93
|
if (response.data && response.data.success || response.status === 200 || response.status === 204) {
|
|
106
94
|
var _response$data;
|
|
107
|
-
|
|
108
95
|
response.data = new BaseResData(((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.data) || response.data, true, '', response.status);
|
|
109
|
-
}
|
|
96
|
+
}
|
|
97
|
+
//没有包装的数据
|
|
110
98
|
else if (((_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.data) === undefined && ((_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : _response$data3.success) === undefined) {
|
|
111
99
|
response.data = new BaseResData(response.data, true, '', response.status, null, response);
|
|
112
100
|
} else {
|
|
113
101
|
var _response$data$error, _response$data4;
|
|
114
|
-
|
|
115
102
|
response.data = new BaseResData(response.data, false, '', response.status, (_response$data$error = response === null || response === void 0 ? void 0 : (_response$data4 = response.data) === null || _response$data4 === void 0 ? void 0 : _response$data4.error) !== null && _response$data$error !== void 0 ? _response$data$error : response.data, response);
|
|
116
103
|
}
|
|
117
|
-
}
|
|
104
|
+
}
|
|
105
|
+
//异常数据
|
|
118
106
|
else {
|
|
119
107
|
var _response$data5, _response$data5$error, _response$data$error2, _response$data6;
|
|
120
|
-
|
|
121
108
|
response.data = new BaseResData(response.data, false, response === null || response === void 0 ? void 0 : (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : (_response$data5$error = _response$data5.error) === null || _response$data5$error === void 0 ? void 0 : _response$data5$error.details, response.status, (_response$data$error2 = response === null || response === void 0 ? void 0 : (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.error) !== null && _response$data$error2 !== void 0 ? _response$data$error2 : response.data, response);
|
|
122
109
|
}
|
|
123
|
-
|
|
124
110
|
return response;
|
|
125
111
|
}, function (e) {
|
|
126
112
|
var _e$response, _response$data$error3, _response$data7;
|
|
127
|
-
|
|
128
113
|
var _ref = e || {},
|
|
129
|
-
|
|
130
|
-
|
|
114
|
+
response = _ref.response;
|
|
131
115
|
var data = new BaseResData(response, false, e.message, e === null || e === void 0 ? void 0 : (_e$response = e.response) === null || _e$response === void 0 ? void 0 : _e$response.status, (_response$data$error3 = response === null || response === void 0 ? void 0 : (_response$data7 = response.data) === null || _response$data7 === void 0 ? void 0 : _response$data7.error) !== null && _response$data$error3 !== void 0 ? _response$data$error3 : response === null || response === void 0 ? void 0 : response.data, response);
|
|
132
|
-
|
|
133
116
|
if (response) {
|
|
134
117
|
response.data = data;
|
|
135
118
|
}
|
|
136
|
-
|
|
137
119
|
return response ? response : {
|
|
138
120
|
data: data
|
|
139
121
|
};
|
|
140
122
|
});
|
|
141
123
|
export function getErrorMessage(res) {
|
|
142
124
|
var _res$errorData, _res$errorData$error, _res$errorData4, _res$errorData4$error, _res$errorData5, _res$errorData5$error, _res$errorData6, _res$errorData6$error, _res$errorData7, _res$errorData7$error, _res$data3, _res$data4, _res$errorData8, _res$errorData10, _res$errorData12, _res$errorData12$Erro, _res$errorData13, _res$errorData13$Erro, _res$errorData14;
|
|
143
|
-
|
|
144
125
|
if (res.successed) {
|
|
145
126
|
var _res$data, _res$data2, _res$data2$data;
|
|
146
|
-
|
|
147
127
|
if ((res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.code) && (res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$data = _res$data2.data) === null || _res$data2$data === void 0 ? void 0 : _res$data2$data.message)) {
|
|
148
128
|
return res.data.data.message;
|
|
149
129
|
}
|
|
150
|
-
|
|
151
130
|
return '';
|
|
152
131
|
}
|
|
153
|
-
|
|
154
132
|
if ((_res$errorData = res.errorData) === null || _res$errorData === void 0 ? void 0 : (_res$errorData$error = _res$errorData.error) === null || _res$errorData$error === void 0 ? void 0 : _res$errorData$error.validationErrors) {
|
|
155
133
|
var text = '';
|
|
156
|
-
|
|
157
134
|
for (var i = 0; i < ((_res$errorData2 = res.errorData) === null || _res$errorData2 === void 0 ? void 0 : (_res$errorData2$error = _res$errorData2.error) === null || _res$errorData2$error === void 0 ? void 0 : _res$errorData2$error.validationErrors.length); i++) {
|
|
158
135
|
var _res$errorData2, _res$errorData2$error, _res$errorData3, _res$errorData3$error;
|
|
159
|
-
|
|
160
136
|
text += (_res$errorData3 = res.errorData) === null || _res$errorData3 === void 0 ? void 0 : (_res$errorData3$error = _res$errorData3.error) === null || _res$errorData3$error === void 0 ? void 0 : _res$errorData3$error.validationErrors[i].message;
|
|
161
137
|
}
|
|
162
|
-
|
|
163
138
|
return text;
|
|
164
139
|
}
|
|
165
|
-
|
|
166
140
|
if ((_res$errorData4 = res.errorData) === null || _res$errorData4 === void 0 ? void 0 : (_res$errorData4$error = _res$errorData4.error) === null || _res$errorData4$error === void 0 ? void 0 : _res$errorData4$error.details) return (_res$errorData5 = res.errorData) === null || _res$errorData5 === void 0 ? void 0 : (_res$errorData5$error = _res$errorData5.error) === null || _res$errorData5$error === void 0 ? void 0 : _res$errorData5$error.details;
|
|
167
141
|
if ((_res$errorData6 = res.errorData) === null || _res$errorData6 === void 0 ? void 0 : (_res$errorData6$error = _res$errorData6.error) === null || _res$errorData6$error === void 0 ? void 0 : _res$errorData6$error.message) return (_res$errorData7 = res.errorData) === null || _res$errorData7 === void 0 ? void 0 : (_res$errorData7$error = _res$errorData7.error) === null || _res$errorData7$error === void 0 ? void 0 : _res$errorData7$error.message;
|
|
168
|
-
|
|
169
|
-
if (((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.data) && ((_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.data.message)) {
|
|
142
|
+
if (((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.data) && ((_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.data).message) {
|
|
170
143
|
var _res$data5;
|
|
171
|
-
|
|
172
|
-
return (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.data.message;
|
|
144
|
+
return ((_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.data).message;
|
|
173
145
|
}
|
|
174
|
-
|
|
175
146
|
if ((_res$errorData8 = res.errorData) === null || _res$errorData8 === void 0 ? void 0 : _res$errorData8.error_description) {
|
|
176
147
|
var _res$errorData9;
|
|
177
|
-
|
|
178
148
|
return res === null || res === void 0 ? void 0 : (_res$errorData9 = res.errorData) === null || _res$errorData9 === void 0 ? void 0 : _res$errorData9.error_description;
|
|
179
149
|
}
|
|
180
|
-
|
|
181
150
|
if (res === null || res === void 0 ? void 0 : (_res$errorData10 = res.errorData) === null || _res$errorData10 === void 0 ? void 0 : _res$errorData10.details) {
|
|
182
151
|
var _res$errorData11;
|
|
183
|
-
|
|
184
152
|
return (_res$errorData11 = res.errorData) === null || _res$errorData11 === void 0 ? void 0 : _res$errorData11.details;
|
|
185
153
|
}
|
|
186
|
-
|
|
187
154
|
if ((_res$errorData12 = res.errorData) === null || _res$errorData12 === void 0 ? void 0 : (_res$errorData12$Erro = _res$errorData12.Error) === null || _res$errorData12$Erro === void 0 ? void 0 : _res$errorData12$Erro.Message) return (_res$errorData13 = res.errorData) === null || _res$errorData13 === void 0 ? void 0 : (_res$errorData13$Erro = _res$errorData13.Error) === null || _res$errorData13$Erro === void 0 ? void 0 : _res$errorData13$Erro.Message;
|
|
188
|
-
|
|
189
155
|
if (res === null || res === void 0 ? void 0 : (_res$errorData14 = res.errorData) === null || _res$errorData14 === void 0 ? void 0 : _res$errorData14.message) {
|
|
190
156
|
var _res$errorData15;
|
|
191
|
-
|
|
192
157
|
return (_res$errorData15 = res.errorData) === null || _res$errorData15 === void 0 ? void 0 : _res$errorData15.message;
|
|
193
158
|
}
|
|
194
|
-
|
|
195
159
|
if (res.data && res.data.message) {
|
|
196
160
|
return res.data.message;
|
|
197
161
|
}
|
|
198
|
-
|
|
199
162
|
return '请求错误';
|
|
200
163
|
}
|
|
201
164
|
/** http 包装类 这里会做一些http的包装 */
|
|
202
|
-
|
|
203
165
|
export var HttpHelper = /*#__PURE__*/function () {
|
|
204
166
|
function HttpHelper(client) {
|
|
205
167
|
var _this = this;
|
|
206
|
-
|
|
207
168
|
_classCallCheck(this, HttpHelper);
|
|
208
|
-
|
|
209
169
|
this.interceptorInit = false;
|
|
210
170
|
this._http = void 0;
|
|
211
171
|
this.source = void 0;
|
|
212
|
-
|
|
213
172
|
this.getInstance = function () {
|
|
214
173
|
return _this._http;
|
|
215
174
|
};
|
|
216
|
-
|
|
217
175
|
if (client) {
|
|
218
176
|
this._http = client;
|
|
219
177
|
} else {
|
|
220
178
|
this._http = httpClient;
|
|
221
179
|
}
|
|
222
180
|
}
|
|
223
|
-
|
|
224
181
|
_createClass(HttpHelper, [{
|
|
225
182
|
key: "get",
|
|
226
183
|
value: function get(url, data, params, options) {
|
|
@@ -260,59 +217,48 @@ export var HttpHelper = /*#__PURE__*/function () {
|
|
|
260
217
|
key: "fetch",
|
|
261
218
|
value: function fetch(url, options) {
|
|
262
219
|
var _this2 = this,
|
|
263
|
-
|
|
264
|
-
|
|
220
|
+
_options;
|
|
265
221
|
// 延迟初始化中间件
|
|
266
222
|
if (this.interceptorInit === false) {
|
|
267
223
|
// setupCancelInterceptors(this._http);
|
|
268
224
|
if (getConfig().msgpack) {
|
|
269
225
|
setupMsgPackInterceptors(this._http);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
226
|
+
}
|
|
227
|
+
// 初始化注册的拦截器
|
|
273
228
|
if ((interceptors === null || interceptors === void 0 ? void 0 : interceptors.length) && this._http.isInit !== true) {
|
|
274
229
|
interceptors.forEach(function (p) {
|
|
275
230
|
p(_this2._http);
|
|
276
231
|
});
|
|
277
232
|
}
|
|
278
|
-
|
|
279
233
|
this._http.isInit = true;
|
|
280
234
|
this.interceptorInit = true;
|
|
281
235
|
}
|
|
282
|
-
|
|
283
236
|
if (!((_options = options) === null || _options === void 0 ? void 0 : _options.cancelToken)) {
|
|
284
237
|
options = _objectSpread(_objectSpread({}, options || {}), {}, {
|
|
285
238
|
cancelToken: new axios.CancelToken(function (c) {
|
|
286
239
|
var _options2;
|
|
287
|
-
|
|
288
240
|
if ((_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.cancelSource) {
|
|
289
241
|
options.cancelSource(c);
|
|
290
242
|
}
|
|
291
|
-
|
|
292
243
|
_this2.source = c;
|
|
293
244
|
})
|
|
294
245
|
});
|
|
295
246
|
}
|
|
296
|
-
|
|
297
247
|
return new Promise(function (resolve, reject) {
|
|
298
248
|
var _options3, _options4;
|
|
299
|
-
|
|
300
249
|
if (!options) {
|
|
301
250
|
options = {
|
|
302
251
|
method: 'get'
|
|
303
252
|
};
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
253
|
+
}
|
|
254
|
+
// 如果命中缓存 直接返回
|
|
307
255
|
if (((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.cache) !== false) {
|
|
308
256
|
var cache = httpCache.Get(url, options);
|
|
309
|
-
|
|
310
257
|
if (cache !== null) {
|
|
311
258
|
resolve(cache);
|
|
312
259
|
return;
|
|
313
260
|
}
|
|
314
261
|
}
|
|
315
|
-
|
|
316
262
|
if (options.method === 'POST' || options.method === 'PUT' || options.method === 'DELETE') {
|
|
317
263
|
if (!(options.body instanceof FormData)) {
|
|
318
264
|
options.headers = _objectSpread({
|
|
@@ -325,21 +271,19 @@ export var HttpHelper = /*#__PURE__*/function () {
|
|
|
325
271
|
}, options.headers);
|
|
326
272
|
}
|
|
327
273
|
}
|
|
328
|
-
|
|
329
274
|
options.headers = _objectSpread({
|
|
330
275
|
// 'Content-Encoding': 'gzip',
|
|
331
276
|
// 'Accept-Encoding': 'gzip',
|
|
332
277
|
'Cache-Control': 'no-cache',
|
|
333
278
|
Pragma: 'no-cache'
|
|
334
|
-
}, options.headers);
|
|
335
|
-
|
|
279
|
+
}, options.headers);
|
|
280
|
+
//转换参数到query上并且增加时间戳 去除请求缓存
|
|
336
281
|
if (options.params !== null && options.params !== undefined) {
|
|
337
282
|
options.params['_t'] = new Date();
|
|
338
283
|
} else {
|
|
339
284
|
options.params = {};
|
|
340
285
|
options.params['_t'] = new Date();
|
|
341
286
|
}
|
|
342
|
-
|
|
343
287
|
_this2._http.request(_objectSpread(_objectSpread(_objectSpread({}, defaultOptions), {}, {
|
|
344
288
|
timeout: 30 * 1000,
|
|
345
289
|
baseURL: getConfig().baseUrl
|
|
@@ -361,27 +305,23 @@ export var HttpHelper = /*#__PURE__*/function () {
|
|
|
361
305
|
if (data.errorData) {
|
|
362
306
|
resolve(data);
|
|
363
307
|
}
|
|
364
|
-
|
|
365
308
|
if (data && data.data) {
|
|
366
309
|
// 只缓存正常的数据
|
|
367
310
|
if (data.data.successed === true) {
|
|
368
311
|
httpCache.Add(url, options, data.data);
|
|
369
312
|
}
|
|
370
|
-
|
|
371
313
|
resolve(data.data);
|
|
372
314
|
} else {
|
|
373
315
|
throw new Error(data === null || data === void 0 ? void 0 : data.data);
|
|
374
316
|
}
|
|
375
317
|
}).catch(function (e) {
|
|
376
318
|
var _e$response2, _e$response$data$erro, _e$response3, _e$response3$data, _e$response4;
|
|
377
|
-
|
|
378
319
|
// console.log('open erre1', e);
|
|
379
320
|
resolve(new BaseResData(null, false, e.message, e === null || e === void 0 ? void 0 : (_e$response2 = e.response) === null || _e$response2 === void 0 ? void 0 : _e$response2.status, (_e$response$data$erro = e === null || e === void 0 ? void 0 : (_e$response3 = e.response) === null || _e$response3 === void 0 ? void 0 : (_e$response3$data = _e$response3.data) === null || _e$response3$data === void 0 ? void 0 : _e$response3$data.error) !== null && _e$response$data$erro !== void 0 ? _e$response$data$erro : e === null || e === void 0 ? void 0 : (_e$response4 = e.response) === null || _e$response4 === void 0 ? void 0 : _e$response4.data, e === null || e === void 0 ? void 0 : e.response));
|
|
380
321
|
});
|
|
381
322
|
});
|
|
382
323
|
}
|
|
383
324
|
}]);
|
|
384
|
-
|
|
385
325
|
return HttpHelper;
|
|
386
326
|
}();
|
|
387
327
|
var interceptors = [];
|
|
@@ -10,17 +10,14 @@ export function setupMsgPackInterceptors(httpClient) {
|
|
|
10
10
|
Accept: 'application/msgpack',
|
|
11
11
|
'Content-Type': 'application/msgpack'
|
|
12
12
|
});
|
|
13
|
-
|
|
14
13
|
config.transformResponse = function (data) {
|
|
15
14
|
try {
|
|
16
15
|
if ((config === null || config === void 0 ? void 0 : config.responseType) === 'arraybuffer') {
|
|
17
16
|
return data;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
if (data === null || data === undefined || data.length === 0 || data.byteLength === 0) {
|
|
21
19
|
return null;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
var res = decode(data);
|
|
25
22
|
return res;
|
|
26
23
|
} catch (e) {
|
|
@@ -28,7 +25,6 @@ export function setupMsgPackInterceptors(httpClient) {
|
|
|
28
25
|
return null;
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
|
-
|
|
32
28
|
return config;
|
|
33
29
|
});
|
|
34
30
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
// 这里fork了一份msgpack5的源码 为了解决 后台返回DateTime.min时候 会报错
|
|
3
4
|
import bl from 'bl';
|
|
4
5
|
import { Buffer } from 'safe-buffer';
|
|
5
6
|
import streams from './lib/streams';
|
|
6
7
|
import { buildDecode } from './lib/decoder';
|
|
7
8
|
import { buildEncode } from './lib/encoder';
|
|
8
9
|
import { IncompleteBufferError } from './lib/helpers';
|
|
9
|
-
|
|
10
10
|
var DateCodec = require('./lib/codecs/DateCodec');
|
|
11
|
-
|
|
12
11
|
function msgpack(options) {
|
|
13
12
|
var encodingTypes = [];
|
|
14
13
|
var decodingTypes = new Map();
|
|
@@ -20,11 +19,9 @@ function msgpack(options) {
|
|
|
20
19
|
disableTimestampEncoding: false
|
|
21
20
|
};
|
|
22
21
|
decodingTypes.set(DateCodec.type, DateCodec.decode);
|
|
23
|
-
|
|
24
22
|
if (!options.disableTimestampEncoding) {
|
|
25
23
|
encodingTypes.push(DateCodec);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
function registerEncoder(check, encode) {
|
|
29
26
|
assert(check, 'must have an encode function');
|
|
30
27
|
assert(encode, 'must have an encode function');
|
|
@@ -34,24 +31,20 @@ function msgpack(options) {
|
|
|
34
31
|
});
|
|
35
32
|
return this;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
function registerDecoder(type, decode) {
|
|
39
35
|
assert(type >= 0, 'must have a non-negative type');
|
|
40
36
|
assert(decode, 'must have a decode function');
|
|
41
37
|
decodingTypes.set(type, decode);
|
|
42
38
|
return this;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
function register(type, constructor, encode, decode) {
|
|
46
41
|
assert(constructor, 'must have a constructor');
|
|
47
42
|
assert(encode, 'must have an encode function');
|
|
48
43
|
assert(type >= 0, 'must have a non-negative type');
|
|
49
44
|
assert(decode, 'must have a decode function');
|
|
50
|
-
|
|
51
45
|
function check(obj) {
|
|
52
46
|
return obj instanceof constructor;
|
|
53
47
|
}
|
|
54
|
-
|
|
55
48
|
function reEncode(obj) {
|
|
56
49
|
var buf = bl();
|
|
57
50
|
var header = Buffer.allocUnsafe(1);
|
|
@@ -60,12 +53,10 @@ function msgpack(options) {
|
|
|
60
53
|
buf.append(encode(obj));
|
|
61
54
|
return buf;
|
|
62
55
|
}
|
|
63
|
-
|
|
64
56
|
this.registerEncoder(check, reEncode);
|
|
65
57
|
this.registerDecoder(type, decode);
|
|
66
58
|
return this;
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
return {
|
|
70
61
|
encode: buildEncode(encodingTypes, options),
|
|
71
62
|
decode: buildDecode(decodingTypes),
|
|
@@ -80,5 +71,4 @@ function msgpack(options) {
|
|
|
80
71
|
IncompleteBufferError: IncompleteBufferError
|
|
81
72
|
};
|
|
82
73
|
}
|
|
83
|
-
|
|
84
74
|
export default msgpack;
|