@bchr/bchr-front-lib 0.4.4 → 0.5.1-alpha-20241221
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/lib/base/layout/ActionButton.js +705 -0
- package/lib/base/utils/AppKits.js +96 -0
- package/lib/base/utils/Arrays.js +37 -0
- package/lib/base/utils/CNKits.js +227 -0
- package/lib/base/utils/CharReplaceUtils.js +111 -0
- package/lib/base/utils/DES24JS.js +58 -0
- package/lib/base/utils/DateTimes.js +163 -0
- package/lib/base/utils/FormDatas.js +109 -0
- package/lib/base/utils/LangTypes.js +173 -0
- package/lib/base/utils/Objects.js +60 -0
- package/lib/base/utils/Randoms.js +146 -0
- package/lib/base/utils/Strings.js +154 -0
- package/lib/base/utils/TreeDataUtils.js +165 -0
- package/lib/base/utils/Values.js +181 -0
- package/lib/base/utils/index.js +45 -0
- package/lib/services/http.js +1102 -0
- package/lib/style/ExtCustomKendo.less +1063 -935
- package/package.json +6 -2
- package/src/base/layout/ActionButton.js +628 -0
- package/src/base/utils/AppKits.js +62 -0
- package/src/base/utils/Arrays.js +29 -0
- package/src/base/utils/CNKits.js +236 -0
- package/src/base/utils/CharReplaceUtils.js +99 -0
- package/src/base/utils/DES24JS.js +54 -0
- package/src/base/utils/DateTimes.js +136 -0
- package/src/base/utils/FormDatas.js +103 -0
- package/src/base/utils/LangTypes.js +202 -0
- package/src/base/utils/Objects.js +48 -0
- package/src/base/utils/Randoms.js +142 -0
- package/src/base/utils/Strings.js +147 -0
- package/src/base/utils/TreeDataUtils.js +128 -0
- package/src/base/utils/Values.js +196 -0
- package/src/base/utils/index.js +15 -0
- package/src/services/http.js +1075 -0
- package/src/style/ExtCustomKendo.less +1063 -935
|
@@ -0,0 +1,1102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
|
|
10
|
+
var _queryString = _interopRequireDefault(require("query-string"));
|
|
11
|
+
|
|
12
|
+
var _utils = require("../base/utils");
|
|
13
|
+
|
|
14
|
+
var _fileSaver = require("file-saver");
|
|
15
|
+
|
|
16
|
+
var _AppKits = require("../base/utils/AppKits");
|
|
17
|
+
|
|
18
|
+
var _antd = require("antd");
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireDefault(require("react"));
|
|
21
|
+
|
|
22
|
+
var _this = void 0;
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
+
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
+
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
|
|
32
|
+
var http = {
|
|
33
|
+
isUseDefaultExceptionHandler: function isUseDefaultExceptionHandler() {
|
|
34
|
+
return false;
|
|
35
|
+
},
|
|
36
|
+
getRequestContextPath: function getRequestContextPath(options) {
|
|
37
|
+
if (_lodash["default"].isString(options)) {
|
|
38
|
+
var requestURL = options;
|
|
39
|
+
|
|
40
|
+
if (requestURL.toLowerCase().startsWith("http")) {
|
|
41
|
+
return requestURL;
|
|
42
|
+
} else if (requestURL.startsWith(AppConfig.BackServiceRpcPrefix)) {
|
|
43
|
+
// like "/d/module_code/function_let_code/method1
|
|
44
|
+
var requestContextPathParts = requestURL.split("/");
|
|
45
|
+
|
|
46
|
+
if (requestContextPathParts.length >= 4) {
|
|
47
|
+
return requestContextPathParts.slice(0, 4).join("/");
|
|
48
|
+
} else {
|
|
49
|
+
return requestURL;
|
|
50
|
+
}
|
|
51
|
+
} else if (requestURL.startsWith("/")) {
|
|
52
|
+
return requestURL;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var SERVICE_HOST_NAME = AppConfig.BackServiceHostAddress;
|
|
57
|
+
var SERVICE_CONTEXT_PATH = AppConfig.BackServiceContextPath;
|
|
58
|
+
var BACK_SERVICE_RPC_PREFIX = AppConfig.BackServiceRpcPrefix;
|
|
59
|
+
var ajaxBasePath = null;
|
|
60
|
+
|
|
61
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
62
|
+
ajaxBasePath = options.ajaxBasePath;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (_utils.Values.isBlankString(ajaxBasePath)) {
|
|
66
|
+
ajaxBasePath = this.requestContextPath;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (_utils.Values.isBlankString(ajaxBasePath)) {
|
|
70
|
+
var locationHash = window.location.hash;
|
|
71
|
+
|
|
72
|
+
if (!locationHash || locationHash === "#") {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
locationHash = locationHash.substring(1);
|
|
77
|
+
|
|
78
|
+
if (!locationHash) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var _requestContextPathParts = locationHash.split('/');
|
|
83
|
+
|
|
84
|
+
if (_requestContextPathParts.length >= 3) {
|
|
85
|
+
ajaxBasePath = _requestContextPathParts.slice(0, 3).join("/");
|
|
86
|
+
} else {
|
|
87
|
+
ajaxBasePath = locationHash;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var requestContextPath = SERVICE_HOST_NAME + SERVICE_CONTEXT_PATH + BACK_SERVICE_RPC_PREFIX + ajaxBasePath;
|
|
92
|
+
|
|
93
|
+
if (!requestContextPath.endsWith("/")) {
|
|
94
|
+
requestContextPath = requestContextPath + "/";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return requestContextPath;
|
|
98
|
+
},
|
|
99
|
+
getRequestPath: function getRequestPath(options) {
|
|
100
|
+
var rpcMethodName = null;
|
|
101
|
+
var ajaxOptions = {};
|
|
102
|
+
|
|
103
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
104
|
+
rpcMethodName = options.rpcMethodName;
|
|
105
|
+
ajaxOptions = _objectSpread({}, options);
|
|
106
|
+
} else if (_lodash["default"].isString(options)) {
|
|
107
|
+
var requestURL = options;
|
|
108
|
+
|
|
109
|
+
if (requestURL.toLowerCase().startsWith("http")) {
|
|
110
|
+
return requestURL;
|
|
111
|
+
} else if (requestURL.toLowerCase().startsWith("/")) {
|
|
112
|
+
return requestURL;
|
|
113
|
+
} else {
|
|
114
|
+
rpcMethodName = options;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
throw new Error("Invalid arguments value [" + options + "] for http#getRequestPath");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!rpcMethodName) {
|
|
121
|
+
rpcMethodName = "";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (ajaxOptions.url) {
|
|
125
|
+
return ajaxOptions.url;
|
|
126
|
+
} else {
|
|
127
|
+
var requestContextPath = this.getRequestContextPath(options);
|
|
128
|
+
return requestContextPath + rpcMethodName;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
getFunctionLetUIPathFromLocationString: function getFunctionLetUIPathFromLocationString(locationString) {
|
|
132
|
+
if (locationString == null || locationString === "") {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var index1 = locationString.indexOf("#");
|
|
137
|
+
|
|
138
|
+
if (index1 === -1) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var locationHash = locationString.substring(index1);
|
|
143
|
+
var index2 = locationHash.indexOf("?");
|
|
144
|
+
|
|
145
|
+
if (index2 === -1) {
|
|
146
|
+
return locationHash;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return locationHash.substring(0, index2);
|
|
150
|
+
},
|
|
151
|
+
getFunctionLetUIContextPathFromLocationString: function getFunctionLetUIContextPathFromLocationString(locationString) {
|
|
152
|
+
var functionLetUIPath = this.getFunctionLetUIPathFromLocationString(locationString);
|
|
153
|
+
|
|
154
|
+
if (functionLetUIPath == null) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (functionLetUIPath.endsWith("/")) {
|
|
159
|
+
return functionLetUIPath;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var index1 = functionLetUIPath.lastIndexOf("/");
|
|
163
|
+
|
|
164
|
+
if (index1 == -1) {
|
|
165
|
+
return functionLetUIPath;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return functionLetUIPath.substring(0, index1 + 1);
|
|
169
|
+
},
|
|
170
|
+
getViewNameFromLocationHash: function getViewNameFromLocationHash() {
|
|
171
|
+
var currentHash = window.location.hash;
|
|
172
|
+
|
|
173
|
+
if (!currentHash) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
var pureHashLocation = currentHash;
|
|
178
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
179
|
+
|
|
180
|
+
if (p1 > 0) {
|
|
181
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (pureHashLocation.endsWith("/")) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
189
|
+
|
|
190
|
+
if (p2 > 0) {
|
|
191
|
+
return pureHashLocation.substring(p2 + 1);
|
|
192
|
+
} else {
|
|
193
|
+
return pureHashLocation.substring(1);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
getParameterValue: function getParameterValue(paramName) {
|
|
197
|
+
if (!paramName) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
var hash = window.location.hash;
|
|
202
|
+
|
|
203
|
+
if (!hash) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var index = hash.indexOf("?");
|
|
208
|
+
|
|
209
|
+
if (index < 0) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var search = hash.substring(index + 1);
|
|
214
|
+
|
|
215
|
+
var paramObject = _queryString["default"].parse(search);
|
|
216
|
+
|
|
217
|
+
if (!paramObject) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return paramObject[paramName];
|
|
222
|
+
},
|
|
223
|
+
getParameterObject: function getParameterObject() {
|
|
224
|
+
var hash = window.location.hash;
|
|
225
|
+
|
|
226
|
+
if (!hash) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var index = hash.indexOf("?");
|
|
231
|
+
|
|
232
|
+
if (index < 0) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
var search = hash.substring(index + 1);
|
|
237
|
+
|
|
238
|
+
var paramObject = _queryString["default"].parse(search);
|
|
239
|
+
|
|
240
|
+
for (var _len = arguments.length, paramNames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
241
|
+
paramNames[_key] = arguments[_key];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!Array.isArray(paramNames)) {
|
|
245
|
+
return paramObject;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
var _paramObject = {};
|
|
249
|
+
|
|
250
|
+
for (var i = 0, len = paramNames.length; i < len; i++) {
|
|
251
|
+
var param = paramNames[i];
|
|
252
|
+
_paramObject[param] = paramObject[param];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return _paramObject;
|
|
256
|
+
},
|
|
257
|
+
encodeObject2ParameterString2: function encodeObject2ParameterString2(object) {
|
|
258
|
+
if (!_lodash["default"].isPlainObject(object)) {
|
|
259
|
+
return "";
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return "?" + _queryString["default"].stringify(object);
|
|
263
|
+
},
|
|
264
|
+
encodeObject2ParameterString: function encodeObject2ParameterString(object) {
|
|
265
|
+
if (!_lodash["default"].isPlainObject(object)) {
|
|
266
|
+
return "";
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return _queryString["default"].stringify(object);
|
|
270
|
+
},
|
|
271
|
+
redirectToFunctionLet: function redirectToFunctionLet(functionLetRouterPath, parameterObject) {
|
|
272
|
+
this.redirectTo("#" + functionLetRouterPath, parameterObject);
|
|
273
|
+
},
|
|
274
|
+
redirectTo: function redirectTo(targetLocation, parameterObject) {
|
|
275
|
+
if (targetLocation === null || targetLocation === void 0) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (_utils.Values.isBlankString(targetLocation)) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
var location = targetLocation;
|
|
284
|
+
|
|
285
|
+
if (_lodash["default"].isPlainObject(parameterObject)) {
|
|
286
|
+
location = location + this.encodeObject2ParameterString2(parameterObject);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var lowerCaseLocation = location.toLowerCase();
|
|
290
|
+
|
|
291
|
+
if (lowerCaseLocation.startsWith("http://") || lowerCaseLocation.startsWith("https://") || lowerCaseLocation.startsWith("/")) {
|
|
292
|
+
window.location = location;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (location.startsWith("#")) {
|
|
296
|
+
window.location.hash = location;
|
|
297
|
+
} else if (location.startsWith("./")) {
|
|
298
|
+
var currentHash = window.location.hash;
|
|
299
|
+
|
|
300
|
+
if (!currentHash) {
|
|
301
|
+
window.location = location;
|
|
302
|
+
} else if (currentHash === "#/") {
|
|
303
|
+
window.location.hash = "#" + location.substring(1);
|
|
304
|
+
} else {
|
|
305
|
+
var pureHashLocation = currentHash;
|
|
306
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
307
|
+
|
|
308
|
+
if (p1 > 0) {
|
|
309
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
313
|
+
|
|
314
|
+
if (p2 > 0) {
|
|
315
|
+
window.location.hash = pureHashLocation.substring(0, p2 + 1) + location.substring(2);
|
|
316
|
+
} else {
|
|
317
|
+
window.location.hash = "#" + location.substring(1);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
} else if (location.indexOf("../") >= 0) {
|
|
321
|
+
var _currentHash = window.location.hash;
|
|
322
|
+
|
|
323
|
+
if (!_currentHash) {
|
|
324
|
+
window.location = location;
|
|
325
|
+
} else {
|
|
326
|
+
_antd.message.error("Not support the location pattern:" + location);
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
var _currentHash2 = window.location.hash;
|
|
330
|
+
|
|
331
|
+
if (!_currentHash2) {
|
|
332
|
+
window.location = location;
|
|
333
|
+
} else {
|
|
334
|
+
var _pureHashLocation = _currentHash2;
|
|
335
|
+
|
|
336
|
+
var _p = _pureHashLocation.indexOf("?");
|
|
337
|
+
|
|
338
|
+
if (_p > 0) {
|
|
339
|
+
_pureHashLocation = _pureHashLocation.substring(0, _p);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
var _p2 = _pureHashLocation.lastIndexOf("/");
|
|
343
|
+
|
|
344
|
+
if (_p2 > 0) {
|
|
345
|
+
window.location.hash = _pureHashLocation.substring(0, _p2 + 1) + location;
|
|
346
|
+
} else {
|
|
347
|
+
window.location.hash = "#/" + location;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
goBack: function goBack() {
|
|
353
|
+
var currentHash = window.location.hash;
|
|
354
|
+
|
|
355
|
+
if (currentHash == null || currentHash.length == 0 || currentHash == "#/" || currentHash == "#") {
|
|
356
|
+
window.history.go(-1);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
var pureHashLocation = currentHash;
|
|
361
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
362
|
+
|
|
363
|
+
if (p1 > 0) {
|
|
364
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
368
|
+
var hash = "";
|
|
369
|
+
|
|
370
|
+
if (p2 > 0) {
|
|
371
|
+
window.location.hash = pureHashLocation.substring(0, p2 + 1);
|
|
372
|
+
return;
|
|
373
|
+
} else {
|
|
374
|
+
window.history.go(-1);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
getFullURL: function getFullURL(targetLocation, parameterObject) {
|
|
379
|
+
if (targetLocation === null || targetLocation === void 0) {
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (_utils.Values.isBlankString(targetLocation)) {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
var location = targetLocation;
|
|
388
|
+
|
|
389
|
+
if (_lodash["default"].isPlainObject(parameterObject)) {
|
|
390
|
+
location = location + this.encodeObject2ParameterString2(parameterObject);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var lowerCaseLocation = location.toLowerCase();
|
|
394
|
+
|
|
395
|
+
if (lowerCaseLocation.startsWith("http://") || lowerCaseLocation.startsWith("https://") || lowerCaseLocation.startsWith("/")) {
|
|
396
|
+
return location;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (location.startsWith("#")) {
|
|
400
|
+
return window.location.origin + window.location.pathname + location;
|
|
401
|
+
} else if (location.startsWith("./")) {
|
|
402
|
+
var currentHash = window.location.hash;
|
|
403
|
+
|
|
404
|
+
if (_utils.Values.isBlankString(currentHash)) {
|
|
405
|
+
var currentPathname = window.location.pathname;
|
|
406
|
+
var idx = currentHash.lastIndexOf("/");
|
|
407
|
+
|
|
408
|
+
if (idx >= 0) {
|
|
409
|
+
return window.location.origin + currentPathname.substring(0, idx + 1) + location.substring(2);
|
|
410
|
+
} else {
|
|
411
|
+
return window.location.origin + location.substring(1);
|
|
412
|
+
}
|
|
413
|
+
} else if (currentHash === "#/") {
|
|
414
|
+
return window.location.origin + window.location.pathname + "#" + location.substring(1);
|
|
415
|
+
} else {
|
|
416
|
+
var pureHashLocation = currentHash;
|
|
417
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
418
|
+
|
|
419
|
+
if (p1 > 0) {
|
|
420
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
424
|
+
var hash = "";
|
|
425
|
+
|
|
426
|
+
if (p2 > 0) {
|
|
427
|
+
hash = pureHashLocation.substring(0, p2 + 1) + location.substring(2);
|
|
428
|
+
} else {
|
|
429
|
+
hash = "#" + location.substring(1);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return window.location.origin + window.location.pathname + hash;
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
var _currentHash3 = window.location.hash;
|
|
436
|
+
|
|
437
|
+
if (_utils.Values.isBlankString(_currentHash3)) {
|
|
438
|
+
var _currentPathname = window.location.pathname;
|
|
439
|
+
|
|
440
|
+
var _idx = _currentHash3.lastIndexOf("/");
|
|
441
|
+
|
|
442
|
+
if (_idx >= 0) {
|
|
443
|
+
return window.location.origin + _currentPathname.substring(0, _idx + 1) + location;
|
|
444
|
+
} else {
|
|
445
|
+
return window.location.origin + "/" + location;
|
|
446
|
+
}
|
|
447
|
+
} else {
|
|
448
|
+
var _pureHashLocation2 = _currentHash3;
|
|
449
|
+
|
|
450
|
+
var _p3 = _pureHashLocation2.indexOf("?");
|
|
451
|
+
|
|
452
|
+
if (_p3 > 0) {
|
|
453
|
+
_pureHashLocation2 = _pureHashLocation2.substring(0, _p3);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
var _p4 = _pureHashLocation2.lastIndexOf("/");
|
|
457
|
+
|
|
458
|
+
var _hash = "";
|
|
459
|
+
|
|
460
|
+
if (_p4 > 0) {
|
|
461
|
+
_hash = _pureHashLocation2.substring(0, _p4 + 1) + location;
|
|
462
|
+
} else {
|
|
463
|
+
_hash = "#/" + location;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return window.location.origin + window.location.pathname + _hash;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
isInView: function isInView(viewName) {
|
|
471
|
+
if (!_lodash["default"].isString(viewName)) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
var currentView = this.getViewNameFromLocationHash();
|
|
476
|
+
|
|
477
|
+
if (!currentView) {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return viewName.toLowerCase() === currentView.toLowerCase();
|
|
482
|
+
},
|
|
483
|
+
switchMainView: function switchMainView(parameterObject) {
|
|
484
|
+
if (_this.isInView("main_view")) {
|
|
485
|
+
_this.redirectTo("main_view2", parameterObject);
|
|
486
|
+
} else if (_this.isInView("main_view2")) {
|
|
487
|
+
_this.redirectTo("main_view", parameterObject);
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
post: function post(options, jsonObject, mockData) {
|
|
491
|
+
var ajaxOptions = {};
|
|
492
|
+
var failedDealFunction = this.dealAjaxException;
|
|
493
|
+
|
|
494
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
495
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
496
|
+
failedDealFunction = options.fail;
|
|
497
|
+
delete options.fail;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
ajaxOptions = _objectSpread({}, options);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
try {
|
|
504
|
+
this.__checkJSONObjectSecurity(jsonObject);
|
|
505
|
+
} catch (e) {
|
|
506
|
+
var promise = new Promise(function (resolve, reject) {
|
|
507
|
+
return reject(e);
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
511
|
+
return promise["catch"](failedDealFunction);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return promise;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (jsonObject) {
|
|
518
|
+
ajaxOptions.data = jsonObject;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (ajaxOptions.rpcMethodName) {
|
|
522
|
+
delete ajaxOptions.rpcMethodName;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
ajaxOptions.type = "post";
|
|
526
|
+
ajaxOptions.dataType = "json";
|
|
527
|
+
|
|
528
|
+
if (!ajaxOptions.url) {
|
|
529
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
if (this.isValidMockData(mockData)) {
|
|
533
|
+
var _promise = this.__postForMock(mockData);
|
|
534
|
+
|
|
535
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
536
|
+
return _promise["catch"](failedDealFunction);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return _promise;
|
|
540
|
+
} else {
|
|
541
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
542
|
+
|
|
543
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
544
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
545
|
+
} else {
|
|
546
|
+
return this.__toStdPromise(deferred);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
__postForMock: function __postForMock(mockData) {
|
|
551
|
+
var waitTime = mockData.waitTime ? mockData.waitTime : 600;
|
|
552
|
+
return new Promise(function (resolve, reject) {
|
|
553
|
+
setTimeout(function () {
|
|
554
|
+
if (mockData.success === false) {
|
|
555
|
+
return reject(new Error(mockData.message ? mockData.message : "请求数据发生异常"));
|
|
556
|
+
} else {
|
|
557
|
+
var resultData = mockData.data ? mockData.data : mockData;
|
|
558
|
+
return resolve(resultData);
|
|
559
|
+
}
|
|
560
|
+
}, waitTime);
|
|
561
|
+
});
|
|
562
|
+
},
|
|
563
|
+
postJSONWithNotCareSecurity: function postJSONWithNotCareSecurity(options, jsonObject, mockData) {
|
|
564
|
+
var ajaxOptions = {};
|
|
565
|
+
var failedDealFunction = this.dealAjaxException;
|
|
566
|
+
|
|
567
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
568
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
569
|
+
failedDealFunction = options.fail;
|
|
570
|
+
delete options.fail;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
ajaxOptions = _objectSpread({}, options);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (ajaxOptions.rpcMethodName) {
|
|
577
|
+
delete ajaxOptions.rpcMethodName;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
581
|
+
jsonObject = ajaxOptions.data;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (jsonObject) {
|
|
585
|
+
ajaxOptions.data = jsonObject;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if (ajaxOptions.data) {
|
|
589
|
+
ajaxOptions.data = JSON.stringify(ajaxOptions.data);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
ajaxOptions.type = "post";
|
|
593
|
+
ajaxOptions.dataType = "json";
|
|
594
|
+
ajaxOptions.contentType = "application/json; charset=utf-8";
|
|
595
|
+
|
|
596
|
+
if (!ajaxOptions.url) {
|
|
597
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
if (this.isValidMockData(mockData)) {
|
|
601
|
+
var promise = this.__postJSONForMock(mockData);
|
|
602
|
+
|
|
603
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
604
|
+
return promise["catch"](failedDealFunction);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return promise;
|
|
608
|
+
} else {
|
|
609
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
610
|
+
|
|
611
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
612
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
613
|
+
} else {
|
|
614
|
+
return this.__toStdPromise(deferred);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
postJSON: function postJSON(options, jsonObject, mockData) {
|
|
619
|
+
var ajaxOptions = {};
|
|
620
|
+
var failedDealFunction = this.dealAjaxException;
|
|
621
|
+
|
|
622
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
623
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
624
|
+
failedDealFunction = options.fail;
|
|
625
|
+
delete options.fail;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
ajaxOptions = _objectSpread({}, options);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
632
|
+
jsonObject = ajaxOptions.data;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
try {
|
|
636
|
+
this.__checkJSONObjectSecurity(jsonObject);
|
|
637
|
+
} catch (e) {
|
|
638
|
+
var promise = new Promise(function (resolve, reject) {
|
|
639
|
+
return reject(e);
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
643
|
+
return promise["catch"](failedDealFunction);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
return promise;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return this.postJSONWithNotCareSecurity(options, jsonObject, mockData);
|
|
650
|
+
},
|
|
651
|
+
postJSONAllowHTML: function postJSONAllowHTML(options, jsonObject, mockData) {
|
|
652
|
+
var ajaxOptions = {};
|
|
653
|
+
var failedDealFunction = this.dealAjaxException;
|
|
654
|
+
|
|
655
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
656
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
657
|
+
failedDealFunction = options.fail;
|
|
658
|
+
delete options.fail;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
ajaxOptions = _objectSpread({}, options);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
665
|
+
jsonObject = ajaxOptions.data;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
try {
|
|
669
|
+
this.__checkJSONObjectContainsScriptTag(jsonObject);
|
|
670
|
+
} catch (e) {
|
|
671
|
+
var promise = new Promise(function (resolve, reject) {
|
|
672
|
+
return reject(e);
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
676
|
+
return promise["catch"](failedDealFunction);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
return promise;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return this.postJSONWithNotCareSecurity(options, jsonObject, mockData);
|
|
683
|
+
},
|
|
684
|
+
__checkJSONObjectContainsScriptTag: function __checkJSONObjectContainsScriptTag(jsonObject) {
|
|
685
|
+
if (!jsonObject) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (_lodash["default"].isString(jsonObject)) {
|
|
690
|
+
this.__checkStringContainsScriptTag(jsonObject);
|
|
691
|
+
} else if (Array.isArray(jsonObject)) {
|
|
692
|
+
var len = jsonObject.length;
|
|
693
|
+
|
|
694
|
+
if (len === 0) {
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
for (var i = 0; i < len; i++) {
|
|
699
|
+
this.__checkJSONObjectContainsScriptTag(jsonObject[i]);
|
|
700
|
+
}
|
|
701
|
+
} else if (_lodash["default"].isPlainObject(jsonObject)) {
|
|
702
|
+
for (var p in jsonObject) {
|
|
703
|
+
this.__checkJSONObjectContainsScriptTag(jsonObject[p]);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return;
|
|
708
|
+
},
|
|
709
|
+
__checkStringContainsScriptTag: function __checkStringContainsScriptTag(str) {
|
|
710
|
+
if (!str || str.length < 3) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
var containsHTML = /<(noframes|noscript|object|script|video).*?<\/\2>/i.test(str);
|
|
715
|
+
|
|
716
|
+
if (containsHTML) {
|
|
717
|
+
throw new Error("不安全的输入,请检查!");
|
|
718
|
+
}
|
|
719
|
+
},
|
|
720
|
+
__checkJSONObjectSecurity: function __checkJSONObjectSecurity(jsonObject) {
|
|
721
|
+
if (!jsonObject) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (_lodash["default"].isString(jsonObject)) {
|
|
726
|
+
this.__checkStringIfSecurity(jsonObject);
|
|
727
|
+
} else if (Array.isArray(jsonObject)) {
|
|
728
|
+
var len = jsonObject.length;
|
|
729
|
+
|
|
730
|
+
if (len === 0) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
for (var i = 0; i < len; i++) {
|
|
735
|
+
this.__checkJSONObjectSecurity(jsonObject[i]);
|
|
736
|
+
}
|
|
737
|
+
} else if (_lodash["default"].isPlainObject(jsonObject)) {
|
|
738
|
+
for (var p in jsonObject) {
|
|
739
|
+
this.__checkJSONObjectSecurity(jsonObject[p]);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
return;
|
|
744
|
+
},
|
|
745
|
+
__checkStringIfSecurity: function __checkStringIfSecurity(str) {
|
|
746
|
+
if (!str || str.length < 3) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
var containsHTML = /<(br|basefont|hr|input|source|frame|param|area|meta|!--|col|link|option|base|img|wbr|!DOCTYPE).*?>|<(a|abbr|acronym|address|applet|article|aside|audio|b|bdi|bdo|big|blockquote|body|button|canvas|caption|center|cite|code|colgroup|command|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frameset|head|header|hgroup|h1|h2|h3|h4|h5|h6|html|i|iframe|ins|kbd|keygen|label|legend|li|map|mark|menu|meter|nav|noframes|noscript|object|ol|optgroup|output|p|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video).*?<\/\2>/i.test(str);
|
|
751
|
+
|
|
752
|
+
if (containsHTML) {
|
|
753
|
+
throw new Error("不安全的输入,请检查!");
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
__postJSONForMock: function __postJSONForMock(mockData) {
|
|
757
|
+
var waitTime = mockData.waitTime ? mockData.waitTime : 300;
|
|
758
|
+
return new Promise(function (resolve, reject) {
|
|
759
|
+
setTimeout(function () {
|
|
760
|
+
if (mockData.success === false) {
|
|
761
|
+
return reject(new Error(mockData.message ? mockData.message : "请求数据发生异常"));
|
|
762
|
+
} else {
|
|
763
|
+
var resultData = mockData.data ? mockData.data : mockData;
|
|
764
|
+
return resolve(resultData);
|
|
765
|
+
}
|
|
766
|
+
}, waitTime);
|
|
767
|
+
});
|
|
768
|
+
},
|
|
769
|
+
getJSON: function getJSON(options, paramObject, mockData) {
|
|
770
|
+
var ajaxOptions = {};
|
|
771
|
+
var failedDealFunction = this.dealAjaxException;
|
|
772
|
+
|
|
773
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
774
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
775
|
+
failedDealFunction = options.fail;
|
|
776
|
+
delete options.fail;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
ajaxOptions = _objectSpread({}, options);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
ajaxOptions.type = "get";
|
|
783
|
+
ajaxOptions.dataType = "json";
|
|
784
|
+
|
|
785
|
+
if (_lodash["default"].isPlainObject(paramObject)) {
|
|
786
|
+
ajaxOptions.data = paramObject;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
if (!ajaxOptions.data) {
|
|
790
|
+
ajaxOptions.data = {};
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
if (!ajaxOptions.data.euts) {
|
|
794
|
+
ajaxOptions.data.euts = new Date().getTime();
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if (!ajaxOptions.url) {
|
|
798
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (this.isValidMockData(mockData)) {
|
|
802
|
+
var promise = this.__getJSONForMock(mockData);
|
|
803
|
+
|
|
804
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
805
|
+
return promise["catch"](failedDealFunction);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
return promise;
|
|
809
|
+
} else {
|
|
810
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
811
|
+
|
|
812
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
813
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
814
|
+
} else {
|
|
815
|
+
return this.__toStdPromise(deferred);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
isValidMockData: function isValidMockData(mockData) {
|
|
820
|
+
if (mockData === null || mockData === void 0) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
return _lodash["default"].isPlainObject(mockData);
|
|
825
|
+
},
|
|
826
|
+
__getJSONForMock: function __getJSONForMock(mockData) {
|
|
827
|
+
var waitTime = mockData.waitTime ? mockData.waitTime : 600;
|
|
828
|
+
return new Promise(function (resolve, reject) {
|
|
829
|
+
setTimeout(function () {
|
|
830
|
+
if (mockData.success === false) {
|
|
831
|
+
return reject(new Error(mockData.message ? mockData.message : "请求数据发生异常"));
|
|
832
|
+
} else {
|
|
833
|
+
var resultData = mockData.data ? mockData.data : mockData;
|
|
834
|
+
return resolve(resultData);
|
|
835
|
+
}
|
|
836
|
+
}, waitTime);
|
|
837
|
+
});
|
|
838
|
+
},
|
|
839
|
+
requestStaticHTMLTemplate: function requestStaticHTMLTemplate(staticTemplateFilePath) {
|
|
840
|
+
var deferred = window.$.ajax({
|
|
841
|
+
url: staticTemplateFilePath,
|
|
842
|
+
dataType: "html"
|
|
843
|
+
});
|
|
844
|
+
var failedDealFunction = this.dealAjaxException;
|
|
845
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
846
|
+
},
|
|
847
|
+
downloadFileByPostJSON: function downloadFileByPostJSON(options, jsonObject, saveFileName) {
|
|
848
|
+
var ajaxOptions = {};
|
|
849
|
+
var failedDealFunction = this.dealAjaxException;
|
|
850
|
+
|
|
851
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
852
|
+
if (_lodash["default"].isFunction(options.fail)) {
|
|
853
|
+
failedDealFunction = options.fail;
|
|
854
|
+
delete options.fail;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
ajaxOptions = _objectSpread({}, options);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
if (_lodash["default"].isPlainObject(ajaxOptions.data)) {
|
|
861
|
+
jsonObject = ajaxOptions.data;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
try {
|
|
865
|
+
this.__checkJSONObjectSecurity(jsonObject);
|
|
866
|
+
} catch (e) {
|
|
867
|
+
var promise = new Promise(function (resolve, reject) {
|
|
868
|
+
return reject(e);
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
872
|
+
return promise["catch"](failedDealFunction);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
return promise;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
if (jsonObject) {
|
|
879
|
+
ajaxOptions.data = jsonObject;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
if (ajaxOptions.rpcMethodName) {
|
|
883
|
+
delete ajaxOptions.rpcMethodName;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
ajaxOptions.type = "post";
|
|
887
|
+
ajaxOptions.dataType = "*";
|
|
888
|
+
|
|
889
|
+
if (!ajaxOptions.data) {
|
|
890
|
+
ajaxOptions.data = {};
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (!ajaxOptions.data.euts) {
|
|
894
|
+
ajaxOptions.data.euts = new Date().getTime();
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
if (!ajaxOptions.url) {
|
|
898
|
+
ajaxOptions.url = this.getRequestPath(options);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
ajaxOptions.xhrFields = {
|
|
902
|
+
responseType: "blob"
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
ajaxOptions.success = function (result, request, xhr) {
|
|
906
|
+
var fileName = "下载文件-" + new Date().getTime();
|
|
907
|
+
|
|
908
|
+
if (_lodash["default"].isString(saveFileName) && saveFileName.length > 0) {
|
|
909
|
+
fileName = saveFileName;
|
|
910
|
+
} else {
|
|
911
|
+
var contentDisposition = xhr.getResponseHeader('Content-Disposition');
|
|
912
|
+
|
|
913
|
+
if (contentDisposition && contentDisposition.split) {
|
|
914
|
+
var parts = contentDisposition.split(';');
|
|
915
|
+
|
|
916
|
+
if (parts.length >= 1) {
|
|
917
|
+
var fileInfo = parts[1];
|
|
918
|
+
var fileInfoArray = fileInfo.split('=');
|
|
919
|
+
|
|
920
|
+
if (fileInfoArray.length >= 1) {
|
|
921
|
+
fileName = fileInfoArray[1];
|
|
922
|
+
fileName = decodeURIComponent(fileName);
|
|
923
|
+
fileName = fileName.replaceAll("\"", "");
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
var type = xhr.getResponseHeader("content-type");
|
|
930
|
+
|
|
931
|
+
if (!type) {
|
|
932
|
+
type = "application/octet-stream";
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
var blob = new Blob([result], {
|
|
936
|
+
type: type
|
|
937
|
+
});
|
|
938
|
+
(0, _fileSaver.saveAs)(blob, fileName);
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
ajaxOptions.error = function (error) {
|
|
942
|
+
console.log('ajaxOptions :', error);
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
var deferred = window.$.ajax(ajaxOptions);
|
|
946
|
+
|
|
947
|
+
if (this.isUseDefaultExceptionHandler()) {
|
|
948
|
+
return this.__toStdPromise(deferred, failedDealFunction);
|
|
949
|
+
} else {
|
|
950
|
+
return this.__toStdPromise(deferred);
|
|
951
|
+
}
|
|
952
|
+
},
|
|
953
|
+
createRequestURL: function createRequestURL(requestURL, params) {
|
|
954
|
+
var lastRequestURL = this.getRequestPath(requestURL);
|
|
955
|
+
|
|
956
|
+
if (!params) {
|
|
957
|
+
return lastRequestURL;
|
|
958
|
+
} else if (_lodash["default"].isString(params)) {
|
|
959
|
+
if (requestURL.includes('?')) {
|
|
960
|
+
var requestURLData = _queryString["default"].parseUrl(requestURL);
|
|
961
|
+
|
|
962
|
+
if (JSON.stringify(requestURLData.query) === '{}') {
|
|
963
|
+
return "".concat(requestURL).concat(params);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
return "".concat(requestURL, "&").concat(params);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
return "".concat(requestURL, "?").concat(params);
|
|
970
|
+
} else if (_lodash["default"].isPlainObject(params)) {
|
|
971
|
+
if (requestURL.includes('?')) {
|
|
972
|
+
var _requestURLData = _queryString["default"].parseUrl(requestURL);
|
|
973
|
+
|
|
974
|
+
if (JSON.stringify(_requestURLData.query) === '{}') {
|
|
975
|
+
return "".concat(requestURL).concat(this.encodeObject2ParameterString(params));
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
return "".concat(requestURL, "&").concat(this.encodeObject2ParameterString(params));
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
return "".concat(requestURL, "?").concat(this.encodeObject2ParameterString(params));
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* !important! <br/>
|
|
987
|
+
* DoNot use this pointer in this function body.
|
|
988
|
+
*/
|
|
989
|
+
dealAjaxException: function dealAjaxException(httpExceptionResponse) {
|
|
990
|
+
var errorID = "[ClientTraceID=" + new Date().getTime() + "] ";
|
|
991
|
+
var errorMsg = null;
|
|
992
|
+
|
|
993
|
+
if (_lodash["default"].isString(httpExceptionResponse)) {
|
|
994
|
+
errorMsg = httpExceptionResponse;
|
|
995
|
+
|
|
996
|
+
_antd.message.error(errorMsg);
|
|
997
|
+
} else if (httpExceptionResponse && (httpExceptionResponse.responseJSON || httpExceptionResponse.response)) {
|
|
998
|
+
var responseJSON = httpExceptionResponse.responseJSON || (_utils.Strings.isNotBlankString(httpExceptionResponse.response) ? JSON.parse(httpExceptionResponse.response) : httpExceptionResponse.response);
|
|
999
|
+
var responseJSONData = responseJSON.resultData || responseJSON.data;
|
|
1000
|
+
var statusCode = responseJSON.statusCode;
|
|
1001
|
+
|
|
1002
|
+
if (statusCode && statusCode > 40000 && statusCode < 50000) {
|
|
1003
|
+
errorMsg = responseJSON.msg || responseJSON.message;
|
|
1004
|
+
|
|
1005
|
+
_antd.message.error(errorMsg);
|
|
1006
|
+
|
|
1007
|
+
console.error(errorID + "Http request error:" + errorMsg, httpExceptionResponse);
|
|
1008
|
+
|
|
1009
|
+
if ((0, _AppKits.isNeedForceRedirect)()) {
|
|
1010
|
+
setTimeout(function () {
|
|
1011
|
+
(0, _AppKits.forceRedirectToForError)();
|
|
1012
|
+
}, 300);
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
return httpExceptionResponse;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
if (_utils.Values.isNotEmptyArray(responseJSONData)) {
|
|
1019
|
+
var msgItemList = responseJSONData.map(function (msgItem) {
|
|
1020
|
+
return /*#__PURE__*/_react["default"].createElement("li", null, msgItem);
|
|
1021
|
+
});
|
|
1022
|
+
var durationSeconds = responseJSONData.length * 1;
|
|
1023
|
+
durationSeconds = durationSeconds < 3 ? 3 : durationSeconds;
|
|
1024
|
+
var multiLineOpts = {
|
|
1025
|
+
content: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", null, responseJSON.msg), /*#__PURE__*/_react["default"].createElement("ol", {
|
|
1026
|
+
style: {
|
|
1027
|
+
marginTop: 8,
|
|
1028
|
+
paddingLeft: 0
|
|
1029
|
+
}
|
|
1030
|
+
}, msgItemList)),
|
|
1031
|
+
duration: durationSeconds
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
_antd.message.error(multiLineOpts);
|
|
1035
|
+
} else {
|
|
1036
|
+
if (responseJSON.error) {
|
|
1037
|
+
if (_utils.Values.isNotBlankString(responseJSON.error.msg)) {
|
|
1038
|
+
errorMsg = responseJSON.error.msg;
|
|
1039
|
+
} else if (_utils.Values.isNotBlankString(responseJSON.error.message)) {
|
|
1040
|
+
errorMsg = responseJSON.error.message;
|
|
1041
|
+
} else if (_utils.Values.isNotBlankString(responseJSON.error)) {
|
|
1042
|
+
errorMsg = responseJSON.error;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
if (_utils.Values.isNotBlankString(errorMsg)) {
|
|
1046
|
+
_antd.message.error(errorMsg);
|
|
1047
|
+
}
|
|
1048
|
+
} else {
|
|
1049
|
+
errorMsg = responseJSON.msg || responseJSON.message || responseJSON.err;
|
|
1050
|
+
|
|
1051
|
+
if (_utils.Values.isNotBlankString(errorMsg)) {
|
|
1052
|
+
_antd.message.error(errorMsg);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
console.error(errorID + "Http request error:" + errorMsg, httpExceptionResponse);
|
|
1058
|
+
return httpExceptionResponse;
|
|
1059
|
+
} else if (_utils.Values.isNotBlankString(httpExceptionResponse.message)) {
|
|
1060
|
+
_antd.message.error(httpExceptionResponse.message);
|
|
1061
|
+
} else if (httpExceptionResponse.status === 502) {
|
|
1062
|
+
_antd.message.error("[502]服务正在重启,请稍后重试");
|
|
1063
|
+
} else if (httpExceptionResponse.status === 200) {
|
|
1064
|
+
_antd.message.error("[200]Http状态码为200,但是出错,可能的原因是数据格式转换异常,请排查。");
|
|
1065
|
+
} else if (httpExceptionResponse.status === 404) {
|
|
1066
|
+
var contentType = httpExceptionResponse.getResponseHeader("Content-Type");
|
|
1067
|
+
|
|
1068
|
+
if (_utils.Values.isNotBlankString(contentType) && !contentType.toLowerCase().startsWith("application/json")) {
|
|
1069
|
+
// because the request is always to for backend service
|
|
1070
|
+
// but when failed, we always return json;
|
|
1071
|
+
// when not json, that is always the backend service not available (not start);
|
|
1072
|
+
_antd.message.error("[404] Not Found, 可能是后端服务尚未启动.");
|
|
1073
|
+
|
|
1074
|
+
if ((0, _AppKits.isNeedForceRedirect)()) {
|
|
1075
|
+
setTimeout(function () {
|
|
1076
|
+
(0, _AppKits.forceRedirectToForError)();
|
|
1077
|
+
}, 300);
|
|
1078
|
+
}
|
|
1079
|
+
} else {
|
|
1080
|
+
_antd.message.error("[404] Not Found(所请求的资源不存在)");
|
|
1081
|
+
}
|
|
1082
|
+
} else if (httpExceptionResponse.status === 0 || httpExceptionResponse.readyState === 0) {
|
|
1083
|
+
_antd.message.error("应用服务链路不通:请联系管理员检查应用服务是否已启动.");
|
|
1084
|
+
} else if (httpExceptionResponse.status && httpExceptionResponse.statusText) {
|
|
1085
|
+
var errorTip = "[" + httpExceptionResponse.status + "] " + httpExceptionResponse.statusText;
|
|
1086
|
+
|
|
1087
|
+
_antd.message.error(errorTip);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
console.error(errorID + "Maybe Http request error or Unresolved promise message:", httpExceptionResponse);
|
|
1091
|
+
return httpExceptionResponse;
|
|
1092
|
+
},
|
|
1093
|
+
__toStdPromise: function __toStdPromise(deferred, failedDealFunction) {
|
|
1094
|
+
if (failedDealFunction === null || failedDealFunction === void 0) {
|
|
1095
|
+
return Promise.resolve(deferred);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
return Promise.resolve(deferred)["catch"](failedDealFunction);
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
var _default = http;
|
|
1102
|
+
exports["default"] = _default;
|