ztxkutils 2.10.60 → 2.10.62

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.
@@ -2634,7 +2634,7 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2634
2634
  return Promise.reject(response);
2635
2635
  }
2636
2636
  }, function (error) {
2637
- var _a, _b, _c, _d, _e;
2637
+ var _a, _b, _c, _d, _e, _f;
2638
2638
  // catchPromiseObj = [];
2639
2639
  console.error(error);
2640
2640
  var errRes = error === null || error === void 0 ? void 0 : error.response;
@@ -2649,8 +2649,9 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2649
2649
  });
2650
2650
  });
2651
2651
  /** 如果接口出错了,清理掉这个错误的接口缓存 */
2652
- if (autonomousCatchingPromiseObj[error === null || error === void 0 ? void 0 : error.config.url]) {
2653
- autonomousCatchingPromiseObj[error === null || error === void 0 ? void 0 : error.config.url] = undefined;
2652
+ var autonomousCatchingKey = ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.autonomousKey) || (error === null || error === void 0 ? void 0 : error.config.url);
2653
+ if (autonomousCatchingPromiseObj[autonomousCatchingKey]) {
2654
+ autonomousCatchingPromiseObj[autonomousCatchingKey] = undefined;
2654
2655
  }
2655
2656
  if (item !== -1) {
2656
2657
  catchPromiseObj.splice(item, 1);
@@ -2660,11 +2661,11 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2660
2661
  // 超时异常统一处理,超时的异常没有response值,只能通过toString处理
2661
2662
  if (!errRes && error.toString().indexOf(timeoutNum + "ms") !== -1) {
2662
2663
  if (!isMessage) {
2663
- if (((_b = (_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.method) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === 'POST' &&
2664
+ if (((_c = (_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.method) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === 'POST' &&
2664
2665
  __isTimeoutMessage) {
2665
2666
  isMessage = true;
2666
2667
  Modal.confirm({
2667
- title: "\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF0C\u8BF7\u53BB\u5217\u8868\u786E\u8BA4\u6570\u636E\u662F\u5426\u63D2\u5165\u6210\u529F\uFF0C\u8BF7\u52FF\u91CD\u590D\u63D0\u4EA4\uFF01\n\u63A5\u53E3\u5730\u5740:" + ((_c = error === null || error === void 0 ? void 0 : error.config) === null || _c === void 0 ? void 0 : _c.url) + "\n\u8BF7\u6C42\u65B9\u5F0F:" + ((_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.method) + "\n\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4:" + ((_e = error === null || error === void 0 ? void 0 : error.config) === null || _e === void 0 ? void 0 : _e.timeout),
2668
+ title: "\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF0C\u8BF7\u53BB\u5217\u8868\u786E\u8BA4\u6570\u636E\u662F\u5426\u63D2\u5165\u6210\u529F\uFF0C\u8BF7\u52FF\u91CD\u590D\u63D0\u4EA4\uFF01\n\u63A5\u53E3\u5730\u5740:" + ((_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.url) + "\n\u8BF7\u6C42\u65B9\u5F0F:" + ((_e = error === null || error === void 0 ? void 0 : error.config) === null || _e === void 0 ? void 0 : _e.method) + "\n\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4:" + ((_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.timeout),
2668
2669
  okCancel: false,
2669
2670
  onOk: function () {
2670
2671
  isMessage = false;
@@ -2778,7 +2779,7 @@ function request(myOptions, jumpCallback, otherOptions) {
2778
2779
  setInterceptorsResponse(jumpCallback, otherOptions);
2779
2780
  isFirstSet = true;
2780
2781
  }
2781
- var encryptionType = myOptions.encryptionType, isTimeoutMessage = myOptions.isTimeoutMessage, isForceRequest = myOptions.isForceRequest, _m = myOptions.noCatchUrl, noCatchUrl = _m === void 0 ? [] : _m, isCatch = myOptions.isCatch, mustCatch = myOptions.mustCatch, isAutonomousCatch = myOptions.isAutonomousCatch, _o = myOptions.autonomousCount, autonomousCount = _o === void 0 ? 1 : _o, options = __rest(myOptions, ["encryptionType", "isTimeoutMessage", "isForceRequest", "noCatchUrl", "isCatch", "mustCatch", "isAutonomousCatch", "autonomousCount"]);
2782
+ var encryptionType = myOptions.encryptionType, isTimeoutMessage = myOptions.isTimeoutMessage, isForceRequest = myOptions.isForceRequest, _m = myOptions.noCatchUrl, noCatchUrl = _m === void 0 ? [] : _m, isCatch = myOptions.isCatch, mustCatch = myOptions.mustCatch, isAutonomousCatch = myOptions.isAutonomousCatch, _o = myOptions.autonomousCount, autonomousCount = _o === void 0 ? 1 : _o, autonomousKey = myOptions.autonomousKey, options = __rest(myOptions, ["encryptionType", "isTimeoutMessage", "isForceRequest", "noCatchUrl", "isCatch", "mustCatch", "isAutonomousCatch", "autonomousCount", "autonomousKey"]);
2782
2783
  timeoutNum =
2783
2784
  typeof myOptions.timeout === 'number' ? myOptions.timeout : timeoutNum;
2784
2785
  __isTimeoutMessage = isTimeoutMessage;
@@ -2810,7 +2811,7 @@ function request(myOptions, jumpCallback, otherOptions) {
2810
2811
  options.params = transformObj(options.params);
2811
2812
  }
2812
2813
  // 将传入配置与默认配置混合
2813
- var newOptions = __assign(__assign(__assign({}, defaultOptions), options), { headers: __assign(__assign({}, defaultOptions.headers), options.headers) });
2814
+ var newOptions = __assign(__assign(__assign({}, defaultOptions), options), { autonomousKey: autonomousKey, headers: __assign(__assign({}, defaultOptions.headers), options.headers) });
2814
2815
  // 特殊请求处理
2815
2816
  if (((_e = newOptions.method) === null || _e === void 0 ? void 0 : _e.toUpperCase()) === 'POST' ||
2816
2817
  ((_f = newOptions.method) === null || _f === void 0 ? void 0 : _f.toUpperCase()) === 'PUT' ||
@@ -2856,11 +2857,12 @@ function request(myOptions, jumpCallback, otherOptions) {
2856
2857
  }
2857
2858
  // 自主缓存请求。默认这个缓存只会针对一个url缓存一次请求
2858
2859
  if (isAutonomousCatch) {
2859
- var item = autonomousCatchingPromiseObj[newOptions.url];
2860
+ var autonomousCatchingKey = autonomousKey || newOptions.url;
2861
+ var item = autonomousCatchingPromiseObj[autonomousCatchingKey];
2860
2862
  // 如果当前接口没有缓存 缓存住,并且返回接口结果
2861
2863
  if (!item || !Array.isArray(item)) {
2862
2864
  var result = axios(newOptions);
2863
- autonomousCatchingPromiseObj[newOptions.url] = [
2865
+ autonomousCatchingPromiseObj[autonomousCatchingKey] = [
2864
2866
  {
2865
2867
  params: newOptions.params,
2866
2868
  promiseObj: result,