zmdms-utils 0.0.87 → 0.0.89
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/dist/es/request.d.ts +5 -0
- package/dist/es/request.js +14 -1
- package/package.json +1 -1
- package/src/request.ts +20 -0
package/dist/es/request.d.ts
CHANGED
|
@@ -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 };
|
package/dist/es/request.js
CHANGED
|
@@ -92,10 +92,23 @@ 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 &&
|
|
106
|
+
(data === null || data === void 0 ? void 0 : data.code) !== 201 &&
|
|
107
|
+
(data === null || data === void 0 ? void 0 : data.success) === false) {
|
|
108
|
+
// 详细信息 再开发模式开启 之后上到别的环境会去掉
|
|
109
|
+
(_b = this.modalConfirm) === null || _b === void 0 ? void 0 : _b.call(this, "".concat((data === null || data === void 0 ? void 0 : data.msg) || "请求异常"));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
99
112
|
if (!config.isEasyMessage) {
|
|
100
113
|
return response;
|
|
101
114
|
}
|
package/package.json
CHANGED
package/src/request.ts
CHANGED
|
@@ -131,6 +131,21 @@ 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 &&
|
|
142
|
+
data?.code !== 201 &&
|
|
143
|
+
data?.success === false
|
|
144
|
+
) {
|
|
145
|
+
// 详细信息 再开发模式开启 之后上到别的环境会去掉
|
|
146
|
+
this.modalConfirm?.(`${data?.msg || "请求异常"}`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
134
149
|
if (!(config as any).isEasyMessage) {
|
|
135
150
|
return response;
|
|
136
151
|
}
|
|
@@ -432,4 +447,9 @@ export interface IOtherOptions {
|
|
|
432
447
|
) => InternalAxiosRequestConfig<any>;
|
|
433
448
|
/** 响应器自定义 */
|
|
434
449
|
interceptorsResponseHandle?: () => void;
|
|
450
|
+
/**
|
|
451
|
+
* 是否对于接口返回200状态码的 但是 data.code非200或201的情况 也提示异常
|
|
452
|
+
* 这个要配合(独立接口的) isErrorMessage 一起使用
|
|
453
|
+
*/
|
|
454
|
+
isStatusSuccessCodeError?: boolean;
|
|
435
455
|
}
|