zmdms-utils 0.0.55 → 0.0.57
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/baseUrl.d.ts +1 -0
- package/dist/es/baseUrl.js +8 -0
- package/dist/es/request.d.ts +4 -0
- package/dist/es/request.js +14 -12
- package/package.json +1 -1
- package/src/baseUrl.ts +10 -0
- package/src/request.ts +8 -2
package/dist/es/baseUrl.d.ts
CHANGED
package/dist/es/baseUrl.js
CHANGED
|
@@ -29,12 +29,20 @@ function getBaseUrl(processObj) {
|
|
|
29
29
|
stage: processObj.REACT_APP_OUTHR_API_STAGE || "http://10.100.234.36:18886",
|
|
30
30
|
prod: processObj.REACT_APP_OUTHR_API_PROD || "http://10.100.235.73:18886",
|
|
31
31
|
};
|
|
32
|
+
// 退出登录地址
|
|
33
|
+
var logoutUrl = {
|
|
34
|
+
dev: processObj.REACT_APP_LOGOUT_DEV || "/login",
|
|
35
|
+
test: processObj.REACT_APP_LOGOUT_TEST || "/login",
|
|
36
|
+
stage: processObj.REACT_APP_LOGOUT_STAGE || "http://testportal.cncico.com:8099/",
|
|
37
|
+
prod: processObj.REACT_APP_LOGOUT_PROD || "http://newportal.cncico.com/",
|
|
38
|
+
};
|
|
32
39
|
var currentKey = ENV.toLowerCase() || "prod";
|
|
33
40
|
return {
|
|
34
41
|
API_URL: apiBaseUrlObj[currentKey] || apiBaseUrlObj["prod"],
|
|
35
42
|
CICOMS_API_URL: cicomsApiBaseUrlObj[currentKey] || cicomsApiBaseUrlObj["prod"],
|
|
36
43
|
FILE_URL: fileBaseUrlObj[currentKey] || fileBaseUrlObj["prod"],
|
|
37
44
|
OUTHR_DOMAIN: outHrDomain[currentKey] || outHrDomain["prod"],
|
|
45
|
+
LOGOUT_URL: logoutUrl[currentKey] || logoutUrl["prod"],
|
|
38
46
|
};
|
|
39
47
|
}
|
|
40
48
|
|
package/dist/es/request.d.ts
CHANGED
package/dist/es/request.js
CHANGED
|
@@ -117,16 +117,18 @@ var AxiosRequest = /** @class */ (function () {
|
|
|
117
117
|
// 响应错误处理
|
|
118
118
|
AxiosRequest.prototype.responseError = function (error) {
|
|
119
119
|
var _this = this;
|
|
120
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
120
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
121
121
|
if (error === void 0) { error = {}; }
|
|
122
122
|
var response = error.response;
|
|
123
|
+
// 登录过期是否自己处理
|
|
124
|
+
var isHandleLoginExpiration = (_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.isHandleLoginExpiration;
|
|
123
125
|
// 处理token失效
|
|
124
126
|
// TODO: 刷新token逻辑
|
|
125
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 401) {
|
|
127
|
+
if ((response === null || response === void 0 ? void 0 : response.status) === 401 && !isHandleLoginExpiration) {
|
|
126
128
|
removeToken();
|
|
127
129
|
if (!this.isExpired) {
|
|
128
130
|
this.isExpired = true;
|
|
129
|
-
(
|
|
131
|
+
(_b = this.messageWarning) === null || _b === void 0 ? void 0 : _b.call(this, "登录过期", 3.5, function () {
|
|
130
132
|
_this.isExpired = false;
|
|
131
133
|
});
|
|
132
134
|
this.logoutHandle(response.status);
|
|
@@ -134,11 +136,11 @@ var AxiosRequest = /** @class */ (function () {
|
|
|
134
136
|
return;
|
|
135
137
|
}
|
|
136
138
|
// 处理被挤下线逻辑
|
|
137
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 501) {
|
|
139
|
+
if ((response === null || response === void 0 ? void 0 : response.status) === 501 && !isHandleLoginExpiration) {
|
|
138
140
|
removeToken();
|
|
139
141
|
if (!this.isOffline) {
|
|
140
142
|
this.isOffline = true;
|
|
141
|
-
(
|
|
143
|
+
(_c = this.messageWarning) === null || _c === void 0 ? void 0 : _c.call(this, "你的账号已在其他地方登录!", 3.5, function () {
|
|
142
144
|
_this.isOffline = false;
|
|
143
145
|
});
|
|
144
146
|
this.logoutHandle(response.status);
|
|
@@ -149,7 +151,7 @@ var AxiosRequest = /** @class */ (function () {
|
|
|
149
151
|
if ((response === null || response === void 0 ? void 0 : response.status) === 404) {
|
|
150
152
|
if (!this.isNotFound) {
|
|
151
153
|
this.isNotFound = true;
|
|
152
|
-
(
|
|
154
|
+
(_d = this.messageWarning) === null || _d === void 0 ? void 0 : _d.call(this, "\u63A5\u53E3\uFF1A".concat(response.config.url, " \u672A\u627E\u5230\uFF01"), 3.5, function () {
|
|
153
155
|
_this.isNotFound = false;
|
|
154
156
|
});
|
|
155
157
|
}
|
|
@@ -157,24 +159,24 @@ var AxiosRequest = /** @class */ (function () {
|
|
|
157
159
|
}
|
|
158
160
|
// 处理接口超时逻辑
|
|
159
161
|
if (this.isTimeoutConfirm &&
|
|
160
|
-
((
|
|
162
|
+
((_g = (_f = (_e = error === null || error === void 0 ? void 0 : error.config) === null || _e === void 0 ? void 0 : _e.method) === null || _f === void 0 ? void 0 : _f.toUpperCase) === null || _g === void 0 ? void 0 : _g.call(_f)) === "POST" &&
|
|
161
163
|
!response &&
|
|
162
164
|
error.code === "ECONNABORTED" &&
|
|
163
|
-
((
|
|
165
|
+
((_j = (_h = error.message) === null || _h === void 0 ? void 0 : _h.indexOf) === null || _j === void 0 ? void 0 : _j.call(_h, "".concat(error.config.timeout, "ms"))) !== -1) {
|
|
164
166
|
if (!this.isTimeout) {
|
|
165
167
|
this.isTimeout = true;
|
|
166
|
-
(
|
|
168
|
+
(_k = this.modalConfirm) === null || _k === void 0 ? void 0 : _k.call(this, "".concat(this.isTimeoutConfirmStr
|
|
167
169
|
? this.isTimeoutConfirmStr
|
|
168
|
-
: "请求超时,请稍后再试,或联系相关人员确认后处理!", "\n \u63A5\u53E3\u5730\u5740: ").concat((
|
|
170
|
+
: "请求超时,请稍后再试,或联系相关人员确认后处理!", "\n \u63A5\u53E3\u5730\u5740: ").concat((_l = error === null || error === void 0 ? void 0 : error.config) === null || _l === void 0 ? void 0 : _l.url, "\n \u8BF7\u6C42\u65B9\u5F0F: ").concat((_m = error === null || error === void 0 ? void 0 : error.config) === null || _m === void 0 ? void 0 : _m.method, "\n \u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4: ").concat(((_o = error === null || error === void 0 ? void 0 : error.config) === null || _o === void 0 ? void 0 : _o.timeout) / 1000, "\u79D2\n "), function () {
|
|
169
171
|
_this.isTimeout = false;
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
174
|
return;
|
|
173
175
|
}
|
|
174
176
|
// 提示业务错误
|
|
175
|
-
if ((
|
|
177
|
+
if ((_p = error === null || error === void 0 ? void 0 : error.config) === null || _p === void 0 ? void 0 : _p.isErrorMessage) {
|
|
176
178
|
// 详细信息 再开发模式开启 之后上到别的环境会去掉
|
|
177
|
-
(
|
|
179
|
+
(_q = this.modalConfirm) === null || _q === void 0 ? void 0 : _q.call(this, "".concat(((_s = (_r = error === null || error === void 0 ? void 0 : error.response) === null || _r === void 0 ? void 0 : _r.data) === null || _s === void 0 ? void 0 : _s.msg) || (error === null || error === void 0 ? void 0 : error.msg) || "服务器异常"));
|
|
178
180
|
// 接口地址: ${error?.config?.url}
|
|
179
181
|
// 响应状态码: ${error?.response?.status}
|
|
180
182
|
// 请求方式: ${error?.config?.method}
|
package/package.json
CHANGED
package/src/baseUrl.ts
CHANGED
|
@@ -35,6 +35,15 @@ export function getBaseUrl(processObj: any) {
|
|
|
35
35
|
prod: processObj.REACT_APP_OUTHR_API_PROD || "http://10.100.235.73:18886",
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
// 退出登录地址
|
|
39
|
+
const logoutUrl: any = {
|
|
40
|
+
dev: processObj.REACT_APP_LOGOUT_DEV || "/login",
|
|
41
|
+
test: processObj.REACT_APP_LOGOUT_TEST || "/login",
|
|
42
|
+
stage:
|
|
43
|
+
processObj.REACT_APP_LOGOUT_STAGE || "http://testportal.cncico.com:8099/",
|
|
44
|
+
prod: processObj.REACT_APP_LOGOUT_PROD || "http://newportal.cncico.com/",
|
|
45
|
+
};
|
|
46
|
+
|
|
38
47
|
const currentKey = ENV.toLowerCase() || "prod";
|
|
39
48
|
|
|
40
49
|
return {
|
|
@@ -43,5 +52,6 @@ export function getBaseUrl(processObj: any) {
|
|
|
43
52
|
cicomsApiBaseUrlObj[currentKey] || cicomsApiBaseUrlObj["prod"],
|
|
44
53
|
FILE_URL: fileBaseUrlObj[currentKey] || fileBaseUrlObj["prod"],
|
|
45
54
|
OUTHR_DOMAIN: outHrDomain[currentKey] || outHrDomain["prod"],
|
|
55
|
+
LOGOUT_URL: logoutUrl[currentKey] || logoutUrl["prod"],
|
|
46
56
|
};
|
|
47
57
|
}
|
package/src/request.ts
CHANGED
|
@@ -152,9 +152,11 @@ export class AxiosRequest {
|
|
|
152
152
|
// 响应错误处理
|
|
153
153
|
private responseError(error: any = {}) {
|
|
154
154
|
const { response } = error;
|
|
155
|
+
// 登录过期是否自己处理
|
|
156
|
+
const isHandleLoginExpiration = error?.config?.isHandleLoginExpiration;
|
|
155
157
|
// 处理token失效
|
|
156
158
|
// TODO: 刷新token逻辑
|
|
157
|
-
if (response?.status === 401) {
|
|
159
|
+
if (response?.status === 401 && !isHandleLoginExpiration) {
|
|
158
160
|
removeToken();
|
|
159
161
|
if (!this.isExpired) {
|
|
160
162
|
this.isExpired = true;
|
|
@@ -166,7 +168,7 @@ export class AxiosRequest {
|
|
|
166
168
|
return;
|
|
167
169
|
}
|
|
168
170
|
// 处理被挤下线逻辑
|
|
169
|
-
if (response?.status === 501) {
|
|
171
|
+
if (response?.status === 501 && !isHandleLoginExpiration) {
|
|
170
172
|
removeToken();
|
|
171
173
|
if (!this.isOffline) {
|
|
172
174
|
this.isOffline = true;
|
|
@@ -360,6 +362,10 @@ export interface IOptions extends AxiosRequestConfig {
|
|
|
360
362
|
* 实例返回信息 简化处理
|
|
361
363
|
*/
|
|
362
364
|
isEasyMessage?: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* 登录过期是否交给自己处理
|
|
367
|
+
*/
|
|
368
|
+
isHandleLoginExpiration?: boolean;
|
|
363
369
|
}
|
|
364
370
|
|
|
365
371
|
export interface IOtherOptions {
|