ls-pro-common 3.1.15 → 3.1.17
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 +4 -0
- package/dist/common.js +1 -1
- package/dist/common.min.css +4 -0
- package/dist/common.min.js +1 -1
- package/es/components/Permission.d.ts +2 -0
- package/es/components/Permission.js +1 -1
- package/es/http/index.js +62 -43
- package/es/utils/index.js +2 -1
- package/lib/components/Permission.d.ts +2 -0
- package/lib/components/Permission.js +1 -1
- package/lib/http/index.js +62 -43
- package/lib/utils/index.js +2 -1
- package/package.json +1 -1
|
@@ -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
|
|
@@ -17,11 +17,9 @@ var httpStatus = {
|
|
|
17
17
|
var 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,35 @@ 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
|
+
if (getCache('browserId')) {
|
|
62
|
+
browserId = getCache('browserId');
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
options.headers.browserId = browserId;
|
|
65
|
+
} else {
|
|
66
|
+
getBrowserId().then(function (id) {
|
|
67
|
+
browserId = id;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
62
70
|
}
|
|
63
71
|
// 处理门店
|
|
64
|
-
var shopNo =
|
|
72
|
+
var shopNo = getCacheSessionFirst('shopNo');
|
|
65
73
|
if (shopNo) {
|
|
66
74
|
// @ts-ignore
|
|
67
|
-
options.headers
|
|
75
|
+
options.headers.shopNo = shopNo;
|
|
68
76
|
}
|
|
69
77
|
// 处理门店
|
|
70
|
-
var shopCode =
|
|
78
|
+
var shopCode = getCacheSessionFirst('shopCode');
|
|
71
79
|
if (shopCode) {
|
|
72
80
|
// @ts-ignore
|
|
73
|
-
options.headers
|
|
81
|
+
options.headers.shopCode = shopCode;
|
|
74
82
|
}
|
|
75
83
|
// 处理仓库
|
|
76
|
-
var storeNo =
|
|
84
|
+
var storeNo = getCacheSessionFirst('storeNo');
|
|
77
85
|
if (storeNo) {
|
|
78
86
|
// @ts-ignore
|
|
79
|
-
options.headers
|
|
87
|
+
options.headers.storeNo = storeNo;
|
|
80
88
|
}
|
|
81
89
|
var tag = getCookie('x-asm-prefer-tag');
|
|
82
90
|
if (tag) {
|
|
@@ -86,11 +94,11 @@ request.interceptors.request.use(function (url, options) {
|
|
|
86
94
|
// wms 提示,是否排班标识
|
|
87
95
|
var expireWarnFlag = getCache('expireWarnFlag', true);
|
|
88
96
|
// @ts-ignore
|
|
89
|
-
options.headers
|
|
97
|
+
options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
|
|
90
98
|
var token = getCookie('token');
|
|
91
99
|
if (token && url.indexOf('noToken=1') === -1) {
|
|
92
100
|
//@ts-ignore
|
|
93
|
-
options.headers
|
|
101
|
+
options.headers.token = token;
|
|
94
102
|
}
|
|
95
103
|
url = url.replace('&noToken=1', '').replace('noToken=1', '');
|
|
96
104
|
var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
|
|
@@ -109,11 +117,12 @@ request.interceptors.request.use(function (url, options) {
|
|
|
109
117
|
options: options
|
|
110
118
|
};
|
|
111
119
|
});
|
|
120
|
+
var ifExpireWarn = false;
|
|
112
121
|
/** 请求返回拦截器,统一处理业务异常 */
|
|
113
122
|
request.interceptors.response.use( /*#__PURE__*/function () {
|
|
114
123
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response, options) {
|
|
115
124
|
var _navigator, _navigator$userAgent;
|
|
116
|
-
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;
|
|
125
|
+
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;
|
|
117
126
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
118
127
|
while (1) switch (_context.prev = _context.next) {
|
|
119
128
|
case 0:
|
|
@@ -121,7 +130,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
121
130
|
userAgent = (_navigator = navigator) === null || _navigator === void 0 ? void 0 : (_navigator$userAgent = _navigator.userAgent) === null || _navigator$userAgent === void 0 ? void 0 : _navigator$userAgent.toLowerCase();
|
|
122
131
|
isMobile = /mobile/i.test(userAgent); // http 状态码错误
|
|
123
132
|
if (!(response.status < 200 || response.status >= 300)) {
|
|
124
|
-
_context.next =
|
|
133
|
+
_context.next = 28;
|
|
125
134
|
break;
|
|
126
135
|
}
|
|
127
136
|
_context.prev = 4;
|
|
@@ -131,19 +140,22 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
131
140
|
data = _context.sent;
|
|
132
141
|
retCode = (_data$flag = data.flag) === null || _data$flag === void 0 ? void 0 : _data$flag.retCode;
|
|
133
142
|
retMsg = (_data$flag2 = data.flag) === null || _data$flag2 === void 0 ? void 0 : _data$flag2.retMsg;
|
|
134
|
-
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
143
|
+
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
144
|
+
is99110 = false; // wms 提示,是否排班标识
|
|
135
145
|
if (!(retCode === '99110')) {
|
|
136
|
-
_context.next =
|
|
146
|
+
_context.next = 18;
|
|
137
147
|
break;
|
|
138
148
|
}
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
is99110 = true;
|
|
150
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
151
|
+
_context.next = 16;
|
|
141
152
|
break;
|
|
142
153
|
}
|
|
143
154
|
return _context.abrupt("return", response);
|
|
144
|
-
case
|
|
155
|
+
case 16:
|
|
156
|
+
ifExpireWarn = true;
|
|
145
157
|
setCache('expireWarnFlag', '1', true);
|
|
146
|
-
case
|
|
158
|
+
case 18:
|
|
147
159
|
if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013') && !isMobile) {
|
|
148
160
|
if (!getCookie('token')) {
|
|
149
161
|
(window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
|
|
@@ -155,7 +167,9 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
155
167
|
if (retCode === '4012') {
|
|
156
168
|
text = '用户已禁用,无权限进行操作';
|
|
157
169
|
}
|
|
158
|
-
httpError(text || retMsg, retCode, faultCode,
|
|
170
|
+
httpError(text || retMsg, retCode, faultCode, {
|
|
171
|
+
title: is99110 ? '账号到期提醒' : '请求接口出错'
|
|
172
|
+
});
|
|
159
173
|
} else {
|
|
160
174
|
_text = httpStatus[response.status];
|
|
161
175
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -166,10 +180,10 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
166
180
|
showError(_text || retMsg);
|
|
167
181
|
}
|
|
168
182
|
}
|
|
169
|
-
_context.next =
|
|
183
|
+
_context.next = 26;
|
|
170
184
|
break;
|
|
171
|
-
case
|
|
172
|
-
_context.prev =
|
|
185
|
+
case 21:
|
|
186
|
+
_context.prev = 21;
|
|
173
187
|
_context.t0 = _context["catch"](4);
|
|
174
188
|
_text2 = httpStatus[response.status];
|
|
175
189
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -178,35 +192,38 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
178
192
|
_text2 = '请求的服务被限流';
|
|
179
193
|
}
|
|
180
194
|
showError(_text2 || _context.t0.message || response.statusText);
|
|
181
|
-
case
|
|
182
|
-
_context.next =
|
|
195
|
+
case 26:
|
|
196
|
+
_context.next = 45;
|
|
183
197
|
break;
|
|
184
|
-
case
|
|
198
|
+
case 28:
|
|
185
199
|
if (!(noMsg !== '1')) {
|
|
186
|
-
_context.next =
|
|
200
|
+
_context.next = 45;
|
|
187
201
|
break;
|
|
188
202
|
}
|
|
189
|
-
_context.next =
|
|
203
|
+
_context.next = 31;
|
|
190
204
|
return response.clone().json();
|
|
191
|
-
case
|
|
205
|
+
case 31:
|
|
192
206
|
_data = _context.sent;
|
|
193
207
|
_retCode = (_data === null || _data === void 0 ? void 0 : (_data$flag4 = _data.flag) === null || _data$flag4 === void 0 ? void 0 : _data$flag4.retCode) || '0';
|
|
194
208
|
_retMsg = ((_data$flag5 = _data.flag) === null || _data$flag5 === void 0 ? void 0 : _data$flag5.retMsg) || '请求的服务出错';
|
|
195
209
|
status = (getUrlQuery('apiStatus', options.url) || '0').split(',');
|
|
196
210
|
requestId = (_data$flag6 = _data.flag) === null || _data$flag6 === void 0 ? void 0 : _data$flag6.requestId;
|
|
197
|
-
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
211
|
+
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
212
|
+
_is = false; // wms 提示,是否排班标识
|
|
198
213
|
if (!(_retCode === '99110')) {
|
|
199
|
-
_context.next =
|
|
214
|
+
_context.next = 44;
|
|
200
215
|
break;
|
|
201
216
|
}
|
|
202
|
-
|
|
203
|
-
|
|
217
|
+
_is = true;
|
|
218
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
219
|
+
_context.next = 42;
|
|
204
220
|
break;
|
|
205
221
|
}
|
|
206
222
|
return _context.abrupt("return", response);
|
|
207
|
-
case
|
|
223
|
+
case 42:
|
|
224
|
+
ifExpireWarn = true;
|
|
208
225
|
setCache('expireWarnFlag', '1', true);
|
|
209
|
-
case
|
|
226
|
+
case 44:
|
|
210
227
|
if (_retCode && !status.includes(_retCode)) {
|
|
211
228
|
if ((_retCode === 'timeout' || _retCode === '4011') && !isMobile) {
|
|
212
229
|
if (!getCookie('token')) {
|
|
@@ -216,19 +233,21 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
216
233
|
}
|
|
217
234
|
} else {
|
|
218
235
|
if (_faultCode) {
|
|
219
|
-
httpError(_retMsg, _retCode, _faultCode,
|
|
236
|
+
httpError(_retMsg, _retCode, _faultCode, {
|
|
237
|
+
title: _is ? '账号到期提醒' : '请求接口出错'
|
|
238
|
+
});
|
|
220
239
|
} else {
|
|
221
240
|
showError(_retMsg);
|
|
222
241
|
}
|
|
223
242
|
}
|
|
224
243
|
}
|
|
225
|
-
case
|
|
244
|
+
case 45:
|
|
226
245
|
return _context.abrupt("return", response);
|
|
227
|
-
case
|
|
246
|
+
case 46:
|
|
228
247
|
case "end":
|
|
229
248
|
return _context.stop();
|
|
230
249
|
}
|
|
231
|
-
}, _callee, null, [[4,
|
|
250
|
+
}, _callee, null, [[4, 21]]);
|
|
232
251
|
}));
|
|
233
252
|
return function (_x, _x2) {
|
|
234
253
|
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;
|
|
@@ -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
|
|
@@ -17,11 +17,9 @@ var httpStatus = {
|
|
|
17
17
|
var 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,35 @@ 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
|
+
if (getCache('browserId')) {
|
|
62
|
+
browserId = getCache('browserId');
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
options.headers.browserId = browserId;
|
|
65
|
+
} else {
|
|
66
|
+
getBrowserId().then(function (id) {
|
|
67
|
+
browserId = id;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
62
70
|
}
|
|
63
71
|
// 处理门店
|
|
64
|
-
var shopNo =
|
|
72
|
+
var shopNo = getCacheSessionFirst('shopNo');
|
|
65
73
|
if (shopNo) {
|
|
66
74
|
// @ts-ignore
|
|
67
|
-
options.headers
|
|
75
|
+
options.headers.shopNo = shopNo;
|
|
68
76
|
}
|
|
69
77
|
// 处理门店
|
|
70
|
-
var shopCode =
|
|
78
|
+
var shopCode = getCacheSessionFirst('shopCode');
|
|
71
79
|
if (shopCode) {
|
|
72
80
|
// @ts-ignore
|
|
73
|
-
options.headers
|
|
81
|
+
options.headers.shopCode = shopCode;
|
|
74
82
|
}
|
|
75
83
|
// 处理仓库
|
|
76
|
-
var storeNo =
|
|
84
|
+
var storeNo = getCacheSessionFirst('storeNo');
|
|
77
85
|
if (storeNo) {
|
|
78
86
|
// @ts-ignore
|
|
79
|
-
options.headers
|
|
87
|
+
options.headers.storeNo = storeNo;
|
|
80
88
|
}
|
|
81
89
|
var tag = getCookie('x-asm-prefer-tag');
|
|
82
90
|
if (tag) {
|
|
@@ -86,11 +94,11 @@ request.interceptors.request.use(function (url, options) {
|
|
|
86
94
|
// wms 提示,是否排班标识
|
|
87
95
|
var expireWarnFlag = getCache('expireWarnFlag', true);
|
|
88
96
|
// @ts-ignore
|
|
89
|
-
options.headers
|
|
97
|
+
options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
|
|
90
98
|
var token = getCookie('token');
|
|
91
99
|
if (token && url.indexOf('noToken=1') === -1) {
|
|
92
100
|
//@ts-ignore
|
|
93
|
-
options.headers
|
|
101
|
+
options.headers.token = token;
|
|
94
102
|
}
|
|
95
103
|
url = url.replace('&noToken=1', '').replace('noToken=1', '');
|
|
96
104
|
var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
|
|
@@ -109,11 +117,12 @@ request.interceptors.request.use(function (url, options) {
|
|
|
109
117
|
options: options
|
|
110
118
|
};
|
|
111
119
|
});
|
|
120
|
+
var ifExpireWarn = false;
|
|
112
121
|
/** 请求返回拦截器,统一处理业务异常 */
|
|
113
122
|
request.interceptors.response.use( /*#__PURE__*/function () {
|
|
114
123
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response, options) {
|
|
115
124
|
var _navigator, _navigator$userAgent;
|
|
116
|
-
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;
|
|
125
|
+
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;
|
|
117
126
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
118
127
|
while (1) switch (_context.prev = _context.next) {
|
|
119
128
|
case 0:
|
|
@@ -121,7 +130,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
121
130
|
userAgent = (_navigator = navigator) === null || _navigator === void 0 ? void 0 : (_navigator$userAgent = _navigator.userAgent) === null || _navigator$userAgent === void 0 ? void 0 : _navigator$userAgent.toLowerCase();
|
|
122
131
|
isMobile = /mobile/i.test(userAgent); // http 状态码错误
|
|
123
132
|
if (!(response.status < 200 || response.status >= 300)) {
|
|
124
|
-
_context.next =
|
|
133
|
+
_context.next = 28;
|
|
125
134
|
break;
|
|
126
135
|
}
|
|
127
136
|
_context.prev = 4;
|
|
@@ -131,19 +140,22 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
131
140
|
data = _context.sent;
|
|
132
141
|
retCode = (_data$flag = data.flag) === null || _data$flag === void 0 ? void 0 : _data$flag.retCode;
|
|
133
142
|
retMsg = (_data$flag2 = data.flag) === null || _data$flag2 === void 0 ? void 0 : _data$flag2.retMsg;
|
|
134
|
-
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
143
|
+
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
144
|
+
is99110 = false; // wms 提示,是否排班标识
|
|
135
145
|
if (!(retCode === '99110')) {
|
|
136
|
-
_context.next =
|
|
146
|
+
_context.next = 18;
|
|
137
147
|
break;
|
|
138
148
|
}
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
is99110 = true;
|
|
150
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
151
|
+
_context.next = 16;
|
|
141
152
|
break;
|
|
142
153
|
}
|
|
143
154
|
return _context.abrupt("return", response);
|
|
144
|
-
case
|
|
155
|
+
case 16:
|
|
156
|
+
ifExpireWarn = true;
|
|
145
157
|
setCache('expireWarnFlag', '1', true);
|
|
146
|
-
case
|
|
158
|
+
case 18:
|
|
147
159
|
if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013') && !isMobile) {
|
|
148
160
|
if (!getCookie('token')) {
|
|
149
161
|
(window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
|
|
@@ -155,7 +167,9 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
155
167
|
if (retCode === '4012') {
|
|
156
168
|
text = '用户已禁用,无权限进行操作';
|
|
157
169
|
}
|
|
158
|
-
httpError(text || retMsg, retCode, faultCode,
|
|
170
|
+
httpError(text || retMsg, retCode, faultCode, {
|
|
171
|
+
title: is99110 ? '账号到期提醒' : '请求接口出错'
|
|
172
|
+
});
|
|
159
173
|
} else {
|
|
160
174
|
_text = httpStatus[response.status];
|
|
161
175
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -166,10 +180,10 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
166
180
|
showError(_text || retMsg);
|
|
167
181
|
}
|
|
168
182
|
}
|
|
169
|
-
_context.next =
|
|
183
|
+
_context.next = 26;
|
|
170
184
|
break;
|
|
171
|
-
case
|
|
172
|
-
_context.prev =
|
|
185
|
+
case 21:
|
|
186
|
+
_context.prev = 21;
|
|
173
187
|
_context.t0 = _context["catch"](4);
|
|
174
188
|
_text2 = httpStatus[response.status];
|
|
175
189
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -178,35 +192,38 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
178
192
|
_text2 = '请求的服务被限流';
|
|
179
193
|
}
|
|
180
194
|
showError(_text2 || _context.t0.message || response.statusText);
|
|
181
|
-
case
|
|
182
|
-
_context.next =
|
|
195
|
+
case 26:
|
|
196
|
+
_context.next = 45;
|
|
183
197
|
break;
|
|
184
|
-
case
|
|
198
|
+
case 28:
|
|
185
199
|
if (!(noMsg !== '1')) {
|
|
186
|
-
_context.next =
|
|
200
|
+
_context.next = 45;
|
|
187
201
|
break;
|
|
188
202
|
}
|
|
189
|
-
_context.next =
|
|
203
|
+
_context.next = 31;
|
|
190
204
|
return response.clone().json();
|
|
191
|
-
case
|
|
205
|
+
case 31:
|
|
192
206
|
_data = _context.sent;
|
|
193
207
|
_retCode = (_data === null || _data === void 0 ? void 0 : (_data$flag4 = _data.flag) === null || _data$flag4 === void 0 ? void 0 : _data$flag4.retCode) || '0';
|
|
194
208
|
_retMsg = ((_data$flag5 = _data.flag) === null || _data$flag5 === void 0 ? void 0 : _data$flag5.retMsg) || '请求的服务出错';
|
|
195
209
|
status = (getUrlQuery('apiStatus', options.url) || '0').split(',');
|
|
196
210
|
requestId = (_data$flag6 = _data.flag) === null || _data$flag6 === void 0 ? void 0 : _data$flag6.requestId;
|
|
197
|
-
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
211
|
+
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
212
|
+
_is = false; // wms 提示,是否排班标识
|
|
198
213
|
if (!(_retCode === '99110')) {
|
|
199
|
-
_context.next =
|
|
214
|
+
_context.next = 44;
|
|
200
215
|
break;
|
|
201
216
|
}
|
|
202
|
-
|
|
203
|
-
|
|
217
|
+
_is = true;
|
|
218
|
+
if (!(getCache('expireWarnFlag', true) === '1' || ifExpireWarn)) {
|
|
219
|
+
_context.next = 42;
|
|
204
220
|
break;
|
|
205
221
|
}
|
|
206
222
|
return _context.abrupt("return", response);
|
|
207
|
-
case
|
|
223
|
+
case 42:
|
|
224
|
+
ifExpireWarn = true;
|
|
208
225
|
setCache('expireWarnFlag', '1', true);
|
|
209
|
-
case
|
|
226
|
+
case 44:
|
|
210
227
|
if (_retCode && !status.includes(_retCode)) {
|
|
211
228
|
if ((_retCode === 'timeout' || _retCode === '4011') && !isMobile) {
|
|
212
229
|
if (!getCookie('token')) {
|
|
@@ -216,19 +233,21 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
216
233
|
}
|
|
217
234
|
} else {
|
|
218
235
|
if (_faultCode) {
|
|
219
|
-
httpError(_retMsg, _retCode, _faultCode,
|
|
236
|
+
httpError(_retMsg, _retCode, _faultCode, {
|
|
237
|
+
title: _is ? '账号到期提醒' : '请求接口出错'
|
|
238
|
+
});
|
|
220
239
|
} else {
|
|
221
240
|
showError(_retMsg);
|
|
222
241
|
}
|
|
223
242
|
}
|
|
224
243
|
}
|
|
225
|
-
case
|
|
244
|
+
case 45:
|
|
226
245
|
return _context.abrupt("return", response);
|
|
227
|
-
case
|
|
246
|
+
case 46:
|
|
228
247
|
case "end":
|
|
229
248
|
return _context.stop();
|
|
230
249
|
}
|
|
231
|
-
}, _callee, null, [[4,
|
|
250
|
+
}, _callee, null, [[4, 21]]);
|
|
232
251
|
}));
|
|
233
252
|
return function (_x, _x2) {
|
|
234
253
|
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;
|