ls-pro-common 3.1.14 → 3.1.16
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/common.css +7 -0
- package/dist/common.js +1 -1
- package/dist/common.min.css +7 -0
- package/dist/common.min.js +1 -1
- package/es/components/InputTable.js +2 -0
- package/es/components/Permission.d.ts +2 -0
- package/es/components/Permission.js +1 -1
- package/es/http/index.js +58 -47
- package/es/utils/index.js +2 -1
- package/lib/components/InputTable.js +2 -0
- package/lib/components/Permission.d.ts +2 -0
- package/lib/components/Permission.js +1 -1
- package/lib/http/index.js +58 -47
- package/lib/utils/index.js +2 -1
- package/package.json +1 -1
|
@@ -129,6 +129,8 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
129
129
|
return formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2);
|
|
130
130
|
};
|
|
131
131
|
var setFormValue = function setFormValue(formValue) {
|
|
132
|
+
var _prop$onChange;
|
|
133
|
+
(_prop$onChange = prop.onChange) === null || _prop$onChange === void 0 ? void 0 : _prop$onChange.call(prop, formValue[name]);
|
|
132
134
|
if (rowKey) {
|
|
133
135
|
var _formRef$current3, _formRef$current3$set;
|
|
134
136
|
formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _defineProperty({}, rowKey, formValue));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
var _excluded = ["children", "rightValue"];
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import usePermission from
|
|
4
|
+
import usePermission from '../hooks/usePermission';
|
|
5
5
|
var Permission = function Permission(_ref) {
|
|
6
6
|
var children = _ref.children,
|
|
7
7
|
rightValue = _ref.rightValue,
|
package/es/http/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { extend } from 'umi-request';
|
|
5
|
-
import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache } from '../utils';
|
|
5
|
+
import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache } from '../utils';
|
|
6
6
|
//默认超时时间为1分钟
|
|
7
7
|
var request = extend({
|
|
8
8
|
timeout: 60000
|
|
@@ -14,14 +14,12 @@ var httpStatus = {
|
|
|
14
14
|
503: '请求的服务器异常',
|
|
15
15
|
504: '请求服务超时'
|
|
16
16
|
};
|
|
17
|
-
var browserId = '';
|
|
17
|
+
var browserId = getCache('browserId') || '';
|
|
18
18
|
(function () {
|
|
19
19
|
setTimeout(function () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
} catch (_unused) {}
|
|
20
|
+
getBrowserId().then(function (id) {
|
|
21
|
+
browserId = id;
|
|
22
|
+
});
|
|
25
23
|
}, 0);
|
|
26
24
|
})();
|
|
27
25
|
//是否跨域
|
|
@@ -58,25 +56,29 @@ request.interceptors.request.use(function (url, options) {
|
|
|
58
56
|
// 处理浏览器指纹
|
|
59
57
|
if (browserId) {
|
|
60
58
|
// @ts-ignore
|
|
61
|
-
options.headers
|
|
59
|
+
options.headers.browserId = browserId;
|
|
60
|
+
} else {
|
|
61
|
+
getBrowserId().then(function (id) {
|
|
62
|
+
browserId = id;
|
|
63
|
+
});
|
|
62
64
|
}
|
|
63
65
|
// 处理门店
|
|
64
|
-
var shopNo =
|
|
66
|
+
var shopNo = getCacheSessionFirst('shopNo');
|
|
65
67
|
if (shopNo) {
|
|
66
68
|
// @ts-ignore
|
|
67
|
-
options.headers
|
|
69
|
+
options.headers.shopNo = shopNo;
|
|
68
70
|
}
|
|
69
71
|
// 处理门店
|
|
70
|
-
var shopCode =
|
|
72
|
+
var shopCode = getCacheSessionFirst('shopCode');
|
|
71
73
|
if (shopCode) {
|
|
72
74
|
// @ts-ignore
|
|
73
|
-
options.headers
|
|
75
|
+
options.headers.shopCode = shopCode;
|
|
74
76
|
}
|
|
75
77
|
// 处理仓库
|
|
76
|
-
var storeNo =
|
|
78
|
+
var storeNo = getCacheSessionFirst('storeNo');
|
|
77
79
|
if (storeNo) {
|
|
78
80
|
// @ts-ignore
|
|
79
|
-
options.headers
|
|
81
|
+
options.headers.storeNo = storeNo;
|
|
80
82
|
}
|
|
81
83
|
var tag = getCookie('x-asm-prefer-tag');
|
|
82
84
|
if (tag) {
|
|
@@ -85,14 +87,12 @@ request.interceptors.request.use(function (url, options) {
|
|
|
85
87
|
}
|
|
86
88
|
// wms 提示,是否排班标识
|
|
87
89
|
var expireWarnFlag = getCache('expireWarnFlag', true);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
options.headers['expireWarnFlag'] = '1';
|
|
91
|
-
}
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
|
|
92
92
|
var token = getCookie('token');
|
|
93
93
|
if (token && url.indexOf('noToken=1') === -1) {
|
|
94
94
|
//@ts-ignore
|
|
95
|
-
options.headers
|
|
95
|
+
options.headers.token = token;
|
|
96
96
|
}
|
|
97
97
|
url = url.replace('&noToken=1', '').replace('noToken=1', '');
|
|
98
98
|
var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
|
|
@@ -111,11 +111,12 @@ request.interceptors.request.use(function (url, options) {
|
|
|
111
111
|
options: options
|
|
112
112
|
};
|
|
113
113
|
});
|
|
114
|
+
var ifExpireWarn = false;
|
|
114
115
|
/** 请求返回拦截器,统一处理业务异常 */
|
|
115
116
|
request.interceptors.response.use( /*#__PURE__*/function () {
|
|
116
117
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response, options) {
|
|
117
118
|
var _navigator, _navigator$userAgent;
|
|
118
|
-
var noMsg, userAgent, isMobile, _data$flag, _data$flag2, _data$flag3, data, retCode, retMsg, faultCode, text, _text, _text2, _data$flag4, _data$flag5, _data$flag6, _data$flag7, _data, _retCode, _retMsg, status, requestId, _faultCode;
|
|
119
|
+
var noMsg, userAgent, isMobile, _data$flag, _data$flag2, _data$flag3, data, retCode, retMsg, faultCode, is99110, text, _text, _text2, _data$flag4, _data$flag5, _data$flag6, _data$flag7, _data, _retCode, _retMsg, status, requestId, _faultCode, _is;
|
|
119
120
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
120
121
|
while (1) switch (_context.prev = _context.next) {
|
|
121
122
|
case 0:
|
|
@@ -123,7 +124,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
123
124
|
userAgent = (_navigator = navigator) === null || _navigator === void 0 ? void 0 : (_navigator$userAgent = _navigator.userAgent) === null || _navigator$userAgent === void 0 ? void 0 : _navigator$userAgent.toLowerCase();
|
|
124
125
|
isMobile = /mobile/i.test(userAgent); // http 状态码错误
|
|
125
126
|
if (!(response.status < 200 || response.status >= 300)) {
|
|
126
|
-
_context.next =
|
|
127
|
+
_context.next = 28;
|
|
127
128
|
break;
|
|
128
129
|
}
|
|
129
130
|
_context.prev = 4;
|
|
@@ -133,19 +134,22 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
133
134
|
data = _context.sent;
|
|
134
135
|
retCode = (_data$flag = data.flag) === null || _data$flag === void 0 ? void 0 : _data$flag.retCode;
|
|
135
136
|
retMsg = (_data$flag2 = data.flag) === null || _data$flag2 === void 0 ? void 0 : _data$flag2.retMsg;
|
|
136
|
-
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
137
|
+
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
138
|
+
is99110 = false; // wms 提示,是否排班标识
|
|
137
139
|
if (!(retCode === '99110')) {
|
|
138
|
-
_context.next =
|
|
140
|
+
_context.next = 18;
|
|
139
141
|
break;
|
|
140
142
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
is99110 = true;
|
|
144
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
145
|
+
_context.next = 16;
|
|
143
146
|
break;
|
|
144
147
|
}
|
|
145
148
|
return _context.abrupt("return", response);
|
|
146
|
-
case
|
|
149
|
+
case 16:
|
|
150
|
+
ifExpireWarn = true;
|
|
147
151
|
setCache('expireWarnFlag', '1', true);
|
|
148
|
-
case
|
|
152
|
+
case 18:
|
|
149
153
|
if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013') && !isMobile) {
|
|
150
154
|
if (!getCookie('token')) {
|
|
151
155
|
(window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
|
|
@@ -157,7 +161,9 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
157
161
|
if (retCode === '4012') {
|
|
158
162
|
text = '用户已禁用,无权限进行操作';
|
|
159
163
|
}
|
|
160
|
-
httpError(text || retMsg, retCode, faultCode,
|
|
164
|
+
httpError(text || retMsg, retCode, faultCode, {
|
|
165
|
+
title: is99110 ? '账号到期提醒' : '请求接口出错'
|
|
166
|
+
});
|
|
161
167
|
} else {
|
|
162
168
|
_text = httpStatus[response.status];
|
|
163
169
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -168,10 +174,10 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
168
174
|
showError(_text || retMsg);
|
|
169
175
|
}
|
|
170
176
|
}
|
|
171
|
-
_context.next =
|
|
177
|
+
_context.next = 26;
|
|
172
178
|
break;
|
|
173
|
-
case
|
|
174
|
-
_context.prev =
|
|
179
|
+
case 21:
|
|
180
|
+
_context.prev = 21;
|
|
175
181
|
_context.t0 = _context["catch"](4);
|
|
176
182
|
_text2 = httpStatus[response.status];
|
|
177
183
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -180,35 +186,38 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
180
186
|
_text2 = '请求的服务被限流';
|
|
181
187
|
}
|
|
182
188
|
showError(_text2 || _context.t0.message || response.statusText);
|
|
183
|
-
case
|
|
184
|
-
_context.next =
|
|
189
|
+
case 26:
|
|
190
|
+
_context.next = 45;
|
|
185
191
|
break;
|
|
186
|
-
case
|
|
192
|
+
case 28:
|
|
187
193
|
if (!(noMsg !== '1')) {
|
|
188
|
-
_context.next =
|
|
194
|
+
_context.next = 45;
|
|
189
195
|
break;
|
|
190
196
|
}
|
|
191
|
-
_context.next =
|
|
197
|
+
_context.next = 31;
|
|
192
198
|
return response.clone().json();
|
|
193
|
-
case
|
|
199
|
+
case 31:
|
|
194
200
|
_data = _context.sent;
|
|
195
201
|
_retCode = (_data === null || _data === void 0 ? void 0 : (_data$flag4 = _data.flag) === null || _data$flag4 === void 0 ? void 0 : _data$flag4.retCode) || '0';
|
|
196
202
|
_retMsg = ((_data$flag5 = _data.flag) === null || _data$flag5 === void 0 ? void 0 : _data$flag5.retMsg) || '请求的服务出错';
|
|
197
203
|
status = (getUrlQuery('apiStatus', options.url) || '0').split(',');
|
|
198
204
|
requestId = (_data$flag6 = _data.flag) === null || _data$flag6 === void 0 ? void 0 : _data$flag6.requestId;
|
|
199
|
-
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
205
|
+
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
206
|
+
_is = false; // wms 提示,是否排班标识
|
|
200
207
|
if (!(_retCode === '99110')) {
|
|
201
|
-
_context.next =
|
|
208
|
+
_context.next = 44;
|
|
202
209
|
break;
|
|
203
210
|
}
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
_is = true;
|
|
212
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
213
|
+
_context.next = 42;
|
|
206
214
|
break;
|
|
207
215
|
}
|
|
208
216
|
return _context.abrupt("return", response);
|
|
209
|
-
case
|
|
217
|
+
case 42:
|
|
218
|
+
ifExpireWarn = true;
|
|
210
219
|
setCache('expireWarnFlag', '1', true);
|
|
211
|
-
case
|
|
220
|
+
case 44:
|
|
212
221
|
if (_retCode && !status.includes(_retCode)) {
|
|
213
222
|
if ((_retCode === 'timeout' || _retCode === '4011') && !isMobile) {
|
|
214
223
|
if (!getCookie('token')) {
|
|
@@ -218,19 +227,21 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
218
227
|
}
|
|
219
228
|
} else {
|
|
220
229
|
if (_faultCode) {
|
|
221
|
-
httpError(_retMsg, _retCode, _faultCode,
|
|
230
|
+
httpError(_retMsg, _retCode, _faultCode, {
|
|
231
|
+
title: _is ? '账号到期提醒' : '请求接口出错'
|
|
232
|
+
});
|
|
222
233
|
} else {
|
|
223
234
|
showError(_retMsg);
|
|
224
235
|
}
|
|
225
236
|
}
|
|
226
237
|
}
|
|
227
|
-
case
|
|
238
|
+
case 45:
|
|
228
239
|
return _context.abrupt("return", response);
|
|
229
|
-
case
|
|
240
|
+
case 46:
|
|
230
241
|
case "end":
|
|
231
242
|
return _context.stop();
|
|
232
243
|
}
|
|
233
|
-
}, _callee, null, [[4,
|
|
244
|
+
}, _callee, null, [[4, 21]]);
|
|
234
245
|
}));
|
|
235
246
|
return function (_x, _x2) {
|
|
236
247
|
return _ref.apply(this, arguments);
|
package/es/utils/index.js
CHANGED
|
@@ -91,8 +91,9 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
91
91
|
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('//')) return url;
|
|
92
92
|
// 读取项目的默认网关
|
|
93
93
|
if (!defGateway) {
|
|
94
|
+
var _top;
|
|
94
95
|
// @ts-ignore
|
|
95
|
-
defGateway = window.defaultGateway || '';
|
|
96
|
+
defGateway = window.defaultGateway || ((_top = top) === null || _top === void 0 ? void 0 : _top.window.lsMainGateway) || '';
|
|
96
97
|
}
|
|
97
98
|
// 取网关的顺序, 1.取url里的传参,2.取资源里的网关, 3. 取项目里设置的默认网关
|
|
98
99
|
var gateway = getUrlQuery(gatewayKey) || getResourceProps(gatewayKey) || defGateway;
|
|
@@ -129,6 +129,8 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
129
129
|
return formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2);
|
|
130
130
|
};
|
|
131
131
|
var setFormValue = function setFormValue(formValue) {
|
|
132
|
+
var _prop$onChange;
|
|
133
|
+
(_prop$onChange = prop.onChange) === null || _prop$onChange === void 0 ? void 0 : _prop$onChange.call(prop, formValue[name]);
|
|
132
134
|
if (rowKey) {
|
|
133
135
|
var _formRef$current3, _formRef$current3$set;
|
|
134
136
|
formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _defineProperty({}, rowKey, formValue));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
var _excluded = ["children", "rightValue"];
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import usePermission from
|
|
4
|
+
import usePermission from '../hooks/usePermission';
|
|
5
5
|
var Permission = function Permission(_ref) {
|
|
6
6
|
var children = _ref.children,
|
|
7
7
|
rightValue = _ref.rightValue,
|
package/lib/http/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { extend } from 'umi-request';
|
|
5
|
-
import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache } from '../utils';
|
|
5
|
+
import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache } from '../utils';
|
|
6
6
|
//默认超时时间为1分钟
|
|
7
7
|
var request = extend({
|
|
8
8
|
timeout: 60000
|
|
@@ -14,14 +14,12 @@ var httpStatus = {
|
|
|
14
14
|
503: '请求的服务器异常',
|
|
15
15
|
504: '请求服务超时'
|
|
16
16
|
};
|
|
17
|
-
var browserId = '';
|
|
17
|
+
var browserId = getCache('browserId') || '';
|
|
18
18
|
(function () {
|
|
19
19
|
setTimeout(function () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
} catch (_unused) {}
|
|
20
|
+
getBrowserId().then(function (id) {
|
|
21
|
+
browserId = id;
|
|
22
|
+
});
|
|
25
23
|
}, 0);
|
|
26
24
|
})();
|
|
27
25
|
//是否跨域
|
|
@@ -58,25 +56,29 @@ request.interceptors.request.use(function (url, options) {
|
|
|
58
56
|
// 处理浏览器指纹
|
|
59
57
|
if (browserId) {
|
|
60
58
|
// @ts-ignore
|
|
61
|
-
options.headers
|
|
59
|
+
options.headers.browserId = browserId;
|
|
60
|
+
} else {
|
|
61
|
+
getBrowserId().then(function (id) {
|
|
62
|
+
browserId = id;
|
|
63
|
+
});
|
|
62
64
|
}
|
|
63
65
|
// 处理门店
|
|
64
|
-
var shopNo =
|
|
66
|
+
var shopNo = getCacheSessionFirst('shopNo');
|
|
65
67
|
if (shopNo) {
|
|
66
68
|
// @ts-ignore
|
|
67
|
-
options.headers
|
|
69
|
+
options.headers.shopNo = shopNo;
|
|
68
70
|
}
|
|
69
71
|
// 处理门店
|
|
70
|
-
var shopCode =
|
|
72
|
+
var shopCode = getCacheSessionFirst('shopCode');
|
|
71
73
|
if (shopCode) {
|
|
72
74
|
// @ts-ignore
|
|
73
|
-
options.headers
|
|
75
|
+
options.headers.shopCode = shopCode;
|
|
74
76
|
}
|
|
75
77
|
// 处理仓库
|
|
76
|
-
var storeNo =
|
|
78
|
+
var storeNo = getCacheSessionFirst('storeNo');
|
|
77
79
|
if (storeNo) {
|
|
78
80
|
// @ts-ignore
|
|
79
|
-
options.headers
|
|
81
|
+
options.headers.storeNo = storeNo;
|
|
80
82
|
}
|
|
81
83
|
var tag = getCookie('x-asm-prefer-tag');
|
|
82
84
|
if (tag) {
|
|
@@ -85,14 +87,12 @@ request.interceptors.request.use(function (url, options) {
|
|
|
85
87
|
}
|
|
86
88
|
// wms 提示,是否排班标识
|
|
87
89
|
var expireWarnFlag = getCache('expireWarnFlag', true);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
options.headers['expireWarnFlag'] = '1';
|
|
91
|
-
}
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
|
|
92
92
|
var token = getCookie('token');
|
|
93
93
|
if (token && url.indexOf('noToken=1') === -1) {
|
|
94
94
|
//@ts-ignore
|
|
95
|
-
options.headers
|
|
95
|
+
options.headers.token = token;
|
|
96
96
|
}
|
|
97
97
|
url = url.replace('&noToken=1', '').replace('noToken=1', '');
|
|
98
98
|
var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
|
|
@@ -111,11 +111,12 @@ request.interceptors.request.use(function (url, options) {
|
|
|
111
111
|
options: options
|
|
112
112
|
};
|
|
113
113
|
});
|
|
114
|
+
var ifExpireWarn = false;
|
|
114
115
|
/** 请求返回拦截器,统一处理业务异常 */
|
|
115
116
|
request.interceptors.response.use( /*#__PURE__*/function () {
|
|
116
117
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response, options) {
|
|
117
118
|
var _navigator, _navigator$userAgent;
|
|
118
|
-
var noMsg, userAgent, isMobile, _data$flag, _data$flag2, _data$flag3, data, retCode, retMsg, faultCode, text, _text, _text2, _data$flag4, _data$flag5, _data$flag6, _data$flag7, _data, _retCode, _retMsg, status, requestId, _faultCode;
|
|
119
|
+
var noMsg, userAgent, isMobile, _data$flag, _data$flag2, _data$flag3, data, retCode, retMsg, faultCode, is99110, text, _text, _text2, _data$flag4, _data$flag5, _data$flag6, _data$flag7, _data, _retCode, _retMsg, status, requestId, _faultCode, _is;
|
|
119
120
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
120
121
|
while (1) switch (_context.prev = _context.next) {
|
|
121
122
|
case 0:
|
|
@@ -123,7 +124,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
123
124
|
userAgent = (_navigator = navigator) === null || _navigator === void 0 ? void 0 : (_navigator$userAgent = _navigator.userAgent) === null || _navigator$userAgent === void 0 ? void 0 : _navigator$userAgent.toLowerCase();
|
|
124
125
|
isMobile = /mobile/i.test(userAgent); // http 状态码错误
|
|
125
126
|
if (!(response.status < 200 || response.status >= 300)) {
|
|
126
|
-
_context.next =
|
|
127
|
+
_context.next = 28;
|
|
127
128
|
break;
|
|
128
129
|
}
|
|
129
130
|
_context.prev = 4;
|
|
@@ -133,19 +134,22 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
133
134
|
data = _context.sent;
|
|
134
135
|
retCode = (_data$flag = data.flag) === null || _data$flag === void 0 ? void 0 : _data$flag.retCode;
|
|
135
136
|
retMsg = (_data$flag2 = data.flag) === null || _data$flag2 === void 0 ? void 0 : _data$flag2.retMsg;
|
|
136
|
-
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
137
|
+
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
138
|
+
is99110 = false; // wms 提示,是否排班标识
|
|
137
139
|
if (!(retCode === '99110')) {
|
|
138
|
-
_context.next =
|
|
140
|
+
_context.next = 18;
|
|
139
141
|
break;
|
|
140
142
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
is99110 = true;
|
|
144
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
145
|
+
_context.next = 16;
|
|
143
146
|
break;
|
|
144
147
|
}
|
|
145
148
|
return _context.abrupt("return", response);
|
|
146
|
-
case
|
|
149
|
+
case 16:
|
|
150
|
+
ifExpireWarn = true;
|
|
147
151
|
setCache('expireWarnFlag', '1', true);
|
|
148
|
-
case
|
|
152
|
+
case 18:
|
|
149
153
|
if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013') && !isMobile) {
|
|
150
154
|
if (!getCookie('token')) {
|
|
151
155
|
(window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
|
|
@@ -157,7 +161,9 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
157
161
|
if (retCode === '4012') {
|
|
158
162
|
text = '用户已禁用,无权限进行操作';
|
|
159
163
|
}
|
|
160
|
-
httpError(text || retMsg, retCode, faultCode,
|
|
164
|
+
httpError(text || retMsg, retCode, faultCode, {
|
|
165
|
+
title: is99110 ? '账号到期提醒' : '请求接口出错'
|
|
166
|
+
});
|
|
161
167
|
} else {
|
|
162
168
|
_text = httpStatus[response.status];
|
|
163
169
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -168,10 +174,10 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
168
174
|
showError(_text || retMsg);
|
|
169
175
|
}
|
|
170
176
|
}
|
|
171
|
-
_context.next =
|
|
177
|
+
_context.next = 26;
|
|
172
178
|
break;
|
|
173
|
-
case
|
|
174
|
-
_context.prev =
|
|
179
|
+
case 21:
|
|
180
|
+
_context.prev = 21;
|
|
175
181
|
_context.t0 = _context["catch"](4);
|
|
176
182
|
_text2 = httpStatus[response.status];
|
|
177
183
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -180,35 +186,38 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
180
186
|
_text2 = '请求的服务被限流';
|
|
181
187
|
}
|
|
182
188
|
showError(_text2 || _context.t0.message || response.statusText);
|
|
183
|
-
case
|
|
184
|
-
_context.next =
|
|
189
|
+
case 26:
|
|
190
|
+
_context.next = 45;
|
|
185
191
|
break;
|
|
186
|
-
case
|
|
192
|
+
case 28:
|
|
187
193
|
if (!(noMsg !== '1')) {
|
|
188
|
-
_context.next =
|
|
194
|
+
_context.next = 45;
|
|
189
195
|
break;
|
|
190
196
|
}
|
|
191
|
-
_context.next =
|
|
197
|
+
_context.next = 31;
|
|
192
198
|
return response.clone().json();
|
|
193
|
-
case
|
|
199
|
+
case 31:
|
|
194
200
|
_data = _context.sent;
|
|
195
201
|
_retCode = (_data === null || _data === void 0 ? void 0 : (_data$flag4 = _data.flag) === null || _data$flag4 === void 0 ? void 0 : _data$flag4.retCode) || '0';
|
|
196
202
|
_retMsg = ((_data$flag5 = _data.flag) === null || _data$flag5 === void 0 ? void 0 : _data$flag5.retMsg) || '请求的服务出错';
|
|
197
203
|
status = (getUrlQuery('apiStatus', options.url) || '0').split(',');
|
|
198
204
|
requestId = (_data$flag6 = _data.flag) === null || _data$flag6 === void 0 ? void 0 : _data$flag6.requestId;
|
|
199
|
-
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
205
|
+
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
206
|
+
_is = false; // wms 提示,是否排班标识
|
|
200
207
|
if (!(_retCode === '99110')) {
|
|
201
|
-
_context.next =
|
|
208
|
+
_context.next = 44;
|
|
202
209
|
break;
|
|
203
210
|
}
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
_is = true;
|
|
212
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
213
|
+
_context.next = 42;
|
|
206
214
|
break;
|
|
207
215
|
}
|
|
208
216
|
return _context.abrupt("return", response);
|
|
209
|
-
case
|
|
217
|
+
case 42:
|
|
218
|
+
ifExpireWarn = true;
|
|
210
219
|
setCache('expireWarnFlag', '1', true);
|
|
211
|
-
case
|
|
220
|
+
case 44:
|
|
212
221
|
if (_retCode && !status.includes(_retCode)) {
|
|
213
222
|
if ((_retCode === 'timeout' || _retCode === '4011') && !isMobile) {
|
|
214
223
|
if (!getCookie('token')) {
|
|
@@ -218,19 +227,21 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
218
227
|
}
|
|
219
228
|
} else {
|
|
220
229
|
if (_faultCode) {
|
|
221
|
-
httpError(_retMsg, _retCode, _faultCode,
|
|
230
|
+
httpError(_retMsg, _retCode, _faultCode, {
|
|
231
|
+
title: _is ? '账号到期提醒' : '请求接口出错'
|
|
232
|
+
});
|
|
222
233
|
} else {
|
|
223
234
|
showError(_retMsg);
|
|
224
235
|
}
|
|
225
236
|
}
|
|
226
237
|
}
|
|
227
|
-
case
|
|
238
|
+
case 45:
|
|
228
239
|
return _context.abrupt("return", response);
|
|
229
|
-
case
|
|
240
|
+
case 46:
|
|
230
241
|
case "end":
|
|
231
242
|
return _context.stop();
|
|
232
243
|
}
|
|
233
|
-
}, _callee, null, [[4,
|
|
244
|
+
}, _callee, null, [[4, 21]]);
|
|
234
245
|
}));
|
|
235
246
|
return function (_x, _x2) {
|
|
236
247
|
return _ref.apply(this, arguments);
|
package/lib/utils/index.js
CHANGED
|
@@ -91,8 +91,9 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
91
91
|
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('//')) return url;
|
|
92
92
|
// 读取项目的默认网关
|
|
93
93
|
if (!defGateway) {
|
|
94
|
+
var _top;
|
|
94
95
|
// @ts-ignore
|
|
95
|
-
defGateway = window.defaultGateway || '';
|
|
96
|
+
defGateway = window.defaultGateway || ((_top = top) === null || _top === void 0 ? void 0 : _top.window.lsMainGateway) || '';
|
|
96
97
|
}
|
|
97
98
|
// 取网关的顺序, 1.取url里的传参,2.取资源里的网关, 3. 取项目里设置的默认网关
|
|
98
99
|
var gateway = getUrlQuery(gatewayKey) || getResourceProps(gatewayKey) || defGateway;
|