ls-pro-common 3.1.12 → 3.1.14
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.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/RecordLog/index.d.ts +5 -1
- package/es/components/RecordLog/index.js +15 -4
- package/es/hooks/useDict.d.ts +6 -5
- package/es/hooks/useGetState.d.ts +5 -2
- package/es/hooks/useGetState.js +7 -9
- package/es/hooks/useSyncState.d.ts +1 -0
- package/es/hooks/useSyncState.js +1 -0
- package/es/http/index.js +46 -17
- package/es/utils/modal.d.ts +6 -6
- package/es/utils/modal.js +19 -13
- package/lib/components/RecordLog/index.d.ts +5 -1
- package/lib/components/RecordLog/index.js +15 -4
- package/lib/hooks/useDict.d.ts +6 -5
- package/lib/hooks/useGetState.d.ts +5 -2
- package/lib/hooks/useGetState.js +7 -9
- package/lib/hooks/useSyncState.d.ts +1 -0
- package/lib/hooks/useSyncState.js +1 -0
- package/lib/http/index.js +46 -17
- package/lib/utils/modal.d.ts +6 -6
- package/lib/utils/modal.js +19 -13
- package/package.json +1 -1
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 } from '../utils';
|
|
5
|
+
import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache } from '../utils';
|
|
6
6
|
//默认超时时间为1分钟
|
|
7
7
|
var request = extend({
|
|
8
8
|
timeout: 60000
|
|
@@ -83,7 +83,12 @@ request.interceptors.request.use(function (url, options) {
|
|
|
83
83
|
// @ts-ignore
|
|
84
84
|
options.headers['x-asm-prefer-tag'] = tag; //灰度发版标识
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
// wms 提示,是否排班标识
|
|
87
|
+
var expireWarnFlag = getCache('expireWarnFlag', true);
|
|
88
|
+
if (expireWarnFlag === '1') {
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
options.headers['expireWarnFlag'] = '1';
|
|
91
|
+
}
|
|
87
92
|
var token = getCookie('token');
|
|
88
93
|
if (token && url.indexOf('noToken=1') === -1) {
|
|
89
94
|
//@ts-ignore
|
|
@@ -118,7 +123,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
118
123
|
userAgent = (_navigator = navigator) === null || _navigator === void 0 ? void 0 : (_navigator$userAgent = _navigator.userAgent) === null || _navigator$userAgent === void 0 ? void 0 : _navigator$userAgent.toLowerCase();
|
|
119
124
|
isMobile = /mobile/i.test(userAgent); // http 状态码错误
|
|
120
125
|
if (!(response.status < 200 || response.status >= 300)) {
|
|
121
|
-
_context.next =
|
|
126
|
+
_context.next = 25;
|
|
122
127
|
break;
|
|
123
128
|
}
|
|
124
129
|
_context.prev = 4;
|
|
@@ -128,7 +133,19 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
128
133
|
data = _context.sent;
|
|
129
134
|
retCode = (_data$flag = data.flag) === null || _data$flag === void 0 ? void 0 : _data$flag.retCode;
|
|
130
135
|
retMsg = (_data$flag2 = data.flag) === null || _data$flag2 === void 0 ? void 0 : _data$flag2.retMsg;
|
|
131
|
-
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode;
|
|
136
|
+
faultCode = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.faultCode; // wms 提示,是否排班标识
|
|
137
|
+
if (!(retCode === '99110')) {
|
|
138
|
+
_context.next = 15;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (!(getCache('expireWarnFlag', true) === '1')) {
|
|
142
|
+
_context.next = 14;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
return _context.abrupt("return", response);
|
|
146
|
+
case 14:
|
|
147
|
+
setCache('expireWarnFlag', '1', true);
|
|
148
|
+
case 15:
|
|
132
149
|
if ((retCode === 'timeout' || retCode === '4011' || retCode === '4013') && !isMobile) {
|
|
133
150
|
if (!getCookie('token')) {
|
|
134
151
|
(window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
|
|
@@ -151,10 +168,10 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
151
168
|
showError(_text || retMsg);
|
|
152
169
|
}
|
|
153
170
|
}
|
|
154
|
-
_context.next =
|
|
171
|
+
_context.next = 23;
|
|
155
172
|
break;
|
|
156
|
-
case
|
|
157
|
-
_context.prev =
|
|
173
|
+
case 18:
|
|
174
|
+
_context.prev = 18;
|
|
158
175
|
_context.t0 = _context["catch"](4);
|
|
159
176
|
_text2 = httpStatus[response.status];
|
|
160
177
|
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
@@ -163,23 +180,35 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
163
180
|
_text2 = '请求的服务被限流';
|
|
164
181
|
}
|
|
165
182
|
showError(_text2 || _context.t0.message || response.statusText);
|
|
166
|
-
case
|
|
167
|
-
_context.next =
|
|
183
|
+
case 23:
|
|
184
|
+
_context.next = 39;
|
|
168
185
|
break;
|
|
169
|
-
case
|
|
186
|
+
case 25:
|
|
170
187
|
if (!(noMsg !== '1')) {
|
|
171
|
-
_context.next =
|
|
188
|
+
_context.next = 39;
|
|
172
189
|
break;
|
|
173
190
|
}
|
|
174
|
-
_context.next =
|
|
191
|
+
_context.next = 28;
|
|
175
192
|
return response.clone().json();
|
|
176
|
-
case
|
|
193
|
+
case 28:
|
|
177
194
|
_data = _context.sent;
|
|
178
195
|
_retCode = (_data === null || _data === void 0 ? void 0 : (_data$flag4 = _data.flag) === null || _data$flag4 === void 0 ? void 0 : _data$flag4.retCode) || '0';
|
|
179
196
|
_retMsg = ((_data$flag5 = _data.flag) === null || _data$flag5 === void 0 ? void 0 : _data$flag5.retMsg) || '请求的服务出错';
|
|
180
197
|
status = (getUrlQuery('apiStatus', options.url) || '0').split(',');
|
|
181
198
|
requestId = (_data$flag6 = _data.flag) === null || _data$flag6 === void 0 ? void 0 : _data$flag6.requestId;
|
|
182
|
-
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
199
|
+
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode; // wms 提示,是否排班标识
|
|
200
|
+
if (!(_retCode === '99110')) {
|
|
201
|
+
_context.next = 38;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
if (!(getCache('expireWarnFlag', true) === '1')) {
|
|
205
|
+
_context.next = 37;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
return _context.abrupt("return", response);
|
|
209
|
+
case 37:
|
|
210
|
+
setCache('expireWarnFlag', '1', true);
|
|
211
|
+
case 38:
|
|
183
212
|
if (_retCode && !status.includes(_retCode)) {
|
|
184
213
|
if ((_retCode === 'timeout' || _retCode === '4011') && !isMobile) {
|
|
185
214
|
if (!getCookie('token')) {
|
|
@@ -195,13 +224,13 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
195
224
|
}
|
|
196
225
|
}
|
|
197
226
|
}
|
|
198
|
-
case
|
|
227
|
+
case 39:
|
|
199
228
|
return _context.abrupt("return", response);
|
|
200
|
-
case
|
|
229
|
+
case 40:
|
|
201
230
|
case "end":
|
|
202
231
|
return _context.stop();
|
|
203
232
|
}
|
|
204
|
-
}, _callee, null, [[4,
|
|
233
|
+
}, _callee, null, [[4, 18]]);
|
|
205
234
|
}));
|
|
206
235
|
return function (_x, _x2) {
|
|
207
236
|
return _ref.apply(this, arguments);
|
package/lib/utils/modal.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ModalFuncProps } from 'antd';
|
|
1
|
+
import { ModalFuncProps, MessageArgsProps } from 'antd';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
/** @name 获取全屏元素 */
|
|
4
4
|
export declare const getFullScreenElement: () => any;
|
|
5
5
|
/** @name 显示错误 */
|
|
6
|
-
export declare const showError: (text: string, duration?: number) => void;
|
|
6
|
+
export declare const showError: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
7
7
|
/** @name 显示警示 */
|
|
8
|
-
export declare const showWarn: (text: string, duration?: number) => void;
|
|
8
|
+
export declare const showWarn: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
9
9
|
/** @name 显示成功 */
|
|
10
|
-
export declare const showSuccess: (text: string, duration?: number) => void;
|
|
10
|
+
export declare const showSuccess: (text: string, duration?: number, opts?: MessageArgsProps | undefined) => void;
|
|
11
11
|
/**
|
|
12
12
|
* 弹框提示
|
|
13
13
|
*
|
|
@@ -17,7 +17,7 @@ export declare const showSuccess: (text: string, duration?: number) => void;
|
|
|
17
17
|
* @param opts 附加参数
|
|
18
18
|
* @returns Promise<Boolean>
|
|
19
19
|
*/
|
|
20
|
-
export declare const showAlert: (text: React.ReactDOM | string, title?: string, type?: 'error' | 'info' | 'success' | 'warn', opts?: ModalFuncProps) => Promise<unknown>;
|
|
20
|
+
export declare const showAlert: (text: React.ReactDOM | string, title?: string, type?: 'error' | 'info' | 'success' | 'warn' | 'confirm', opts?: ModalFuncProps) => Promise<unknown>;
|
|
21
21
|
/**
|
|
22
22
|
* 请求接口出错
|
|
23
23
|
*
|
|
@@ -30,7 +30,7 @@ export declare const httpError: (retMsg?: string | undefined, retCode?: string |
|
|
|
30
30
|
/** 销毁所有弹框 */
|
|
31
31
|
export declare const exitAlert: () => void;
|
|
32
32
|
/** @name 显示确认 */
|
|
33
|
-
export declare const showConfirm: (text: string, title?: string) => Promise<unknown>;
|
|
33
|
+
export declare const showConfirm: (text: string, title?: string, opts?: ModalFuncProps) => Promise<unknown>;
|
|
34
34
|
/**
|
|
35
35
|
* Token过期重新登录
|
|
36
36
|
*
|
package/lib/utils/modal.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "antd/es/spin/style";
|
|
2
2
|
import _Spin from "antd/es/spin";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
3
|
import "antd/es/modal/style";
|
|
5
4
|
import _Modal from "antd/es/modal";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
6
|
import "antd/es/message/style";
|
|
7
7
|
import _message from "antd/es/message";
|
|
8
8
|
import React from "react";
|
|
@@ -25,10 +25,11 @@ export var getFullScreenElement = function getFullScreenElement() {
|
|
|
25
25
|
/** @name 显示错误 */
|
|
26
26
|
export var showError = function showError(text) {
|
|
27
27
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
28
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
28
29
|
if (!text) {
|
|
29
30
|
text = '出错了!!';
|
|
30
31
|
}
|
|
31
|
-
_message.error({
|
|
32
|
+
_message.error(_objectSpread({
|
|
32
33
|
content: text,
|
|
33
34
|
duration: duration,
|
|
34
35
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -51,15 +52,16 @@ export var showError = function showError(text) {
|
|
|
51
52
|
} catch (e) {}
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
});
|
|
55
|
+
}, opts));
|
|
55
56
|
};
|
|
56
57
|
/** @name 显示警示 */
|
|
57
58
|
export var showWarn = function showWarn(text) {
|
|
58
59
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
60
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
59
61
|
if (!text) {
|
|
60
62
|
text = '请注意!';
|
|
61
63
|
}
|
|
62
|
-
_message.warn({
|
|
64
|
+
_message.warn(_objectSpread({
|
|
63
65
|
content: text,
|
|
64
66
|
duration: duration,
|
|
65
67
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -82,15 +84,16 @@ export var showWarn = function showWarn(text) {
|
|
|
82
84
|
} catch (e) {}
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
});
|
|
87
|
+
}, opts));
|
|
86
88
|
};
|
|
87
89
|
/** @name 显示成功 */
|
|
88
90
|
export var showSuccess = function showSuccess(text) {
|
|
89
91
|
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
92
|
+
var opts = arguments.length > 2 ? arguments[2] : undefined;
|
|
90
93
|
if (!text) {
|
|
91
94
|
text = '操作成功!';
|
|
92
95
|
}
|
|
93
|
-
_message.success({
|
|
96
|
+
_message.success(_objectSpread({
|
|
94
97
|
content: text,
|
|
95
98
|
duration: duration,
|
|
96
99
|
getPopupContainer: function getPopupContainer(e) {
|
|
@@ -113,7 +116,7 @@ export var showSuccess = function showSuccess(text) {
|
|
|
113
116
|
} catch (e) {}
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
});
|
|
119
|
+
}, opts));
|
|
117
120
|
};
|
|
118
121
|
/**
|
|
119
122
|
* 弹框提示
|
|
@@ -129,17 +132,18 @@ export var showAlert = function showAlert(text) {
|
|
|
129
132
|
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'error';
|
|
130
133
|
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
131
134
|
return new Promise(function (resolve, reject) {
|
|
132
|
-
_Modal[type](_objectSpread({
|
|
135
|
+
_Modal[type](_objectSpread(_objectSpread({
|
|
133
136
|
content: text,
|
|
134
137
|
title: title,
|
|
135
|
-
getContainer: getFullScreenElement() || document.body
|
|
138
|
+
getContainer: getFullScreenElement() || document.body
|
|
139
|
+
}, opts), {}, {
|
|
136
140
|
onOk: function onOk() {
|
|
137
141
|
resolve(true);
|
|
138
142
|
},
|
|
139
143
|
onCancel: function onCancel() {
|
|
140
144
|
reject(false);
|
|
141
145
|
}
|
|
142
|
-
}
|
|
146
|
+
}));
|
|
143
147
|
});
|
|
144
148
|
};
|
|
145
149
|
/**
|
|
@@ -162,8 +166,9 @@ export var exitAlert = function exitAlert() {
|
|
|
162
166
|
/** @name 显示确认 */
|
|
163
167
|
export var showConfirm = function showConfirm(text) {
|
|
164
168
|
var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '系统提示';
|
|
169
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
165
170
|
return new Promise(function (resolve, reject) {
|
|
166
|
-
_Modal.confirm({
|
|
171
|
+
_Modal.confirm(_objectSpread(_objectSpread({
|
|
167
172
|
title: title,
|
|
168
173
|
content: text,
|
|
169
174
|
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
@@ -172,14 +177,15 @@ export var showConfirm = function showConfirm(text) {
|
|
|
172
177
|
cancelButtonProps: {
|
|
173
178
|
className: 'ant-btn-gray'
|
|
174
179
|
},
|
|
175
|
-
getContainer: getFullScreenElement() || document.body
|
|
180
|
+
getContainer: getFullScreenElement() || document.body
|
|
181
|
+
}, opts), {}, {
|
|
176
182
|
onOk: function onOk() {
|
|
177
183
|
resolve(true);
|
|
178
184
|
},
|
|
179
185
|
onCancel: function onCancel() {
|
|
180
186
|
reject(false);
|
|
181
187
|
}
|
|
182
|
-
});
|
|
188
|
+
}));
|
|
183
189
|
});
|
|
184
190
|
};
|
|
185
191
|
/**
|