zmdms-utils 0.0.87 → 0.0.88

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.
@@ -82,6 +82,11 @@ interface IOtherOptions {
82
82
  interceptorsRequestConfig?: (config: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any>;
83
83
  /** 响应器自定义 */
84
84
  interceptorsResponseHandle?: () => void;
85
+ /**
86
+ * 是否对于接口返回200状态码的 但是 data.code非200或201的情况 也提示异常
87
+ * 这个要配合(独立接口的) isErrorMessage 一起使用
88
+ */
89
+ isStatusSuccessCodeError?: boolean;
85
90
  }
86
91
 
87
92
  export { AxiosRequest, IOptions, IOtherOptions };
@@ -92,10 +92,21 @@ var AxiosRequest = /** @class */ (function () {
92
92
  };
93
93
  // 响应成功处理
94
94
  AxiosRequest.prototype.responseSuccess = function (response) {
95
- var _a;
95
+ var _a, _b;
96
96
  var config = response.config, status = response.status, data = response.data;
97
97
  // 对返回数据进行解密后 返回给客户端
98
98
  if ((_a = response.config) === null || _a === void 0 ? void 0 : _a.isCrypto) ;
99
+ // 提示业务错误
100
+ if (this.otherOptions.isStatusSuccessCodeError &&
101
+ (config === null || config === void 0 ? void 0 : config.isErrorMessage) &&
102
+ status === 200 &&
103
+ data &&
104
+ typeof data === "object" &&
105
+ ((data === null || data === void 0 ? void 0 : data.code) !== 200 || (data === null || data === void 0 ? void 0 : data.code) !== 201)) {
106
+ // 详细信息 再开发模式开启 之后上到别的环境会去掉
107
+ (_b = this.modalConfirm) === null || _b === void 0 ? void 0 : _b.call(this, "".concat((data === null || data === void 0 ? void 0 : data.msg) || "请求异常"));
108
+ return;
109
+ }
99
110
  if (!config.isEasyMessage) {
100
111
  return response;
101
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.87",
3
+ "version": "0.0.88",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/request.ts CHANGED
@@ -131,6 +131,19 @@ export class AxiosRequest {
131
131
  // 对返回数据进行解密后 返回给客户端
132
132
  if ((response.config as any)?.isCrypto) {
133
133
  }
134
+ // 提示业务错误
135
+ if (
136
+ this.otherOptions.isStatusSuccessCodeError &&
137
+ (config as any)?.isErrorMessage &&
138
+ status === 200 &&
139
+ data &&
140
+ typeof data === "object" &&
141
+ (data?.code !== 200 || data?.code !== 201)
142
+ ) {
143
+ // 详细信息 再开发模式开启 之后上到别的环境会去掉
144
+ this.modalConfirm?.(`${data?.msg || "请求异常"}`);
145
+ return;
146
+ }
134
147
  if (!(config as any).isEasyMessage) {
135
148
  return response;
136
149
  }
@@ -432,4 +445,9 @@ export interface IOtherOptions {
432
445
  ) => InternalAxiosRequestConfig<any>;
433
446
  /** 响应器自定义 */
434
447
  interceptorsResponseHandle?: () => void;
448
+ /**
449
+ * 是否对于接口返回200状态码的 但是 data.code非200或201的情况 也提示异常
450
+ * 这个要配合(独立接口的) isErrorMessage 一起使用
451
+ */
452
+ isStatusSuccessCodeError?: boolean;
435
453
  }