ronds-metadata 1.2.10 → 1.2.11

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