xydata-tools 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -437,7 +437,8 @@ export var logout = /*#__PURE__*/function () {
437
437
  * }
438
438
  */
439
439
  export var handleUnauthorized = function handleUnauthorized(envData) {
440
- var actualLoginType = envData.login_type || envData.aaaLogin !== undefined ? envData.aaaLogin ? 'AAA' : 'SSO' : 'BOTH';
440
+ // 这里兼容以前的aaaLogin属性
441
+ var actualLoginType = envData.login_type || (envData.aaaLogin !== undefined ? envData.aaaLogin ? 'AAA' : 'SSO' : 'BOTH');
441
442
  if (actualLoginType === 'BOTH') {
442
443
  var redirectUrl = getSessionStorage('sso_redirect_url');
443
444
  actualLoginType = redirectUrl ? 'SSO' : 'AAA';
@@ -37,24 +37,34 @@ var buildHeaders = function buildHeaders() {
37
37
  */
38
38
  var safeParseJSON = /*#__PURE__*/function () {
39
39
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(response) {
40
+ var text;
40
41
  return _regeneratorRuntime().wrap(function _callee$(_context) {
41
42
  while (1) switch (_context.prev = _context.next) {
42
43
  case 0:
43
44
  _context.prev = 0;
44
45
  _context.next = 3;
45
- return response.json();
46
+ return response.text();
46
47
  case 3:
47
- return _context.abrupt("return", _context.sent);
48
- case 6:
49
- _context.prev = 6;
50
- _context.t0 = _context["catch"](0);
51
- console.error('JSON 解析失败:', _context.t0);
48
+ text = _context.sent;
49
+ _context.prev = 4;
50
+ return _context.abrupt("return", JSON.parse(text));
51
+ case 8:
52
+ _context.prev = 8;
53
+ _context.t0 = _context["catch"](4);
54
+ return _context.abrupt("return", text);
55
+ case 11:
56
+ _context.next = 17;
57
+ break;
58
+ case 13:
59
+ _context.prev = 13;
60
+ _context.t1 = _context["catch"](0);
61
+ console.error('响应解析失败:', _context.t1);
52
62
  return _context.abrupt("return", null);
53
- case 10:
63
+ case 17:
54
64
  case "end":
55
65
  return _context.stop();
56
66
  }
57
- }, _callee, null, [[0, 6]]);
67
+ }, _callee, null, [[0, 13], [4, 8]]);
58
68
  }));
59
69
  return function safeParseJSON(_x) {
60
70
  return _ref.apply(this, arguments);
@@ -193,28 +203,54 @@ export default function doRequest(_x3, _x4, _x5, _x6) {
193
203
  return _doRequest.apply(this, arguments);
194
204
  }
195
205
  function _doRequest() {
196
- _doRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url, method, data, params) {
206
+ _doRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url, method, data, params) {
197
207
  var options,
198
208
  headers,
199
- _args3 = arguments;
200
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
201
- while (1) switch (_context3.prev = _context3.next) {
209
+ _args4 = arguments;
210
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
211
+ while (1) switch (_context4.prev = _context4.next) {
202
212
  case 0:
203
- options = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
213
+ options = _args4.length > 4 && _args4[4] !== undefined ? _args4[4] : {};
204
214
  headers = buildHeaders();
205
- return _context3.abrupt("return", request(url, _objectSpread({
215
+ return _context4.abrupt("return", request(url, _objectSpread({
206
216
  method: method,
207
217
  params: params,
208
218
  data: data,
209
219
  headers: _objectSpread(_objectSpread({}, headers), options.headers),
210
220
  getResponse: true,
221
+ parseResponse: false,
222
+ // 禁用自动解析,手动处理
211
223
  skipErrorHandler: true
212
- }, options)).then(handleSuccessResponse).catch(handleErrorResponse));
224
+ }, options)).then( /*#__PURE__*/function () {
225
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
226
+ var response, data;
227
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
228
+ while (1) switch (_context3.prev = _context3.next) {
229
+ case 0:
230
+ response = _ref4.response;
231
+ _context3.next = 3;
232
+ return safeParseJSON(response.clone());
233
+ case 3:
234
+ data = _context3.sent;
235
+ return _context3.abrupt("return", {
236
+ data: data,
237
+ response: response
238
+ });
239
+ case 5:
240
+ case "end":
241
+ return _context3.stop();
242
+ }
243
+ }, _callee3);
244
+ }));
245
+ return function (_x7) {
246
+ return _ref5.apply(this, arguments);
247
+ };
248
+ }()).then(handleSuccessResponse).catch(handleErrorResponse));
213
249
  case 3:
214
250
  case "end":
215
- return _context3.stop();
251
+ return _context4.stop();
216
252
  }
217
- }, _callee3);
253
+ }, _callee4);
218
254
  }));
219
255
  return _doRequest.apply(this, arguments);
220
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xydata-tools",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "xydata tools",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",