coolcare-lite-scada-component 2.0.33 → 2.0.34
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/es/services/request.js +2 -33
- package/es/utils/auth.js +2 -6
- package/package.json +1 -1
package/es/services/request.js
CHANGED
|
@@ -8,10 +8,10 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
8
8
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
9
9
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
10
10
|
import { extend } from 'umi-request';
|
|
11
|
-
import { notification
|
|
11
|
+
import { notification } from 'antd';
|
|
12
12
|
// eslint-disable-next-line no-unused-vars
|
|
13
13
|
|
|
14
|
-
import { getAccessToken,
|
|
14
|
+
import { getAccessToken, storeToken } from "../utils/auth";
|
|
15
15
|
var codeMessage = {
|
|
16
16
|
200: '服务器成功返回请求的数据。',
|
|
17
17
|
201: '新建或修改数据成功。',
|
|
@@ -46,24 +46,6 @@ var errorHandler = function errorHandler(error) {
|
|
|
46
46
|
statusText = response.statusText,
|
|
47
47
|
url = response.url;
|
|
48
48
|
if (status === 401) {
|
|
49
|
-
if (isShowLoginOverdueModal) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
isShowLoginOverdueModal = true;
|
|
53
|
-
Modal.confirm({
|
|
54
|
-
title: '登录过期',
|
|
55
|
-
maskClosable: false,
|
|
56
|
-
closable: false,
|
|
57
|
-
content: '登录时效已过期,请重新登录',
|
|
58
|
-
okText: '重新登录',
|
|
59
|
-
onOk: function onOk() {
|
|
60
|
-
goLogin();
|
|
61
|
-
isShowLoginOverdueModal = false;
|
|
62
|
-
},
|
|
63
|
-
onCancel: function onCancel() {
|
|
64
|
-
isShowLoginOverdueModal = false;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
49
|
return;
|
|
68
50
|
}
|
|
69
51
|
var errorText = codeMessage[status] || statusText;
|
|
@@ -120,22 +102,9 @@ requestClient.use(/*#__PURE__*/function () {
|
|
|
120
102
|
requestClient.interceptors.request.use(function (url, options) {
|
|
121
103
|
var headers = options.headers;
|
|
122
104
|
var accessToken = getAccessToken();
|
|
123
|
-
var xAccessToken = getXAccessToken();
|
|
124
|
-
if (!xAccessToken) {
|
|
125
|
-
// 如果 x-access-token 没有的话,直接跳转登录页面
|
|
126
|
-
goLogin();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
headers.Authorization = "Bearer ".concat(accessToken);
|
|
131
105
|
|
|
132
106
|
// @ts-ignore
|
|
133
107
|
headers.Authorization = "Bearer ".concat(accessToken);
|
|
134
|
-
if (accessToken && parseAccessToken(accessToken).exp * 1000 < Date.now() + 1 * 60 * 1000) {
|
|
135
|
-
// 如果 access-token 的过期时间 < 当前时间 + 1分钟, 说明 token 快过期了, 传 x-access-token 刷新 token
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
headers['X-Authorization'] = "Bearer ".concat(xAccessToken);
|
|
138
|
-
}
|
|
139
108
|
return {
|
|
140
109
|
url: url,
|
|
141
110
|
options: _objectSpread(_objectSpread({}, options), {}, {
|
package/es/utils/auth.js
CHANGED
|
@@ -43,18 +43,14 @@ export function parseAccessToken(token) {
|
|
|
43
43
|
* @param xAccessToken x-access-token
|
|
44
44
|
*/
|
|
45
45
|
export function storeToken(accessToken, xAccessToken) {
|
|
46
|
-
/** x-access-token 有效时长(单位:天) */
|
|
47
|
-
var xAccessTokenExpires = parseAccessToken(xAccessToken).exp * 1000;
|
|
48
46
|
// 将 access-token 保存到 cookie
|
|
49
47
|
Cookies.set(accessTokenCookieName, accessToken || '', {
|
|
50
|
-
domain:
|
|
51
|
-
expires: new Date(xAccessTokenExpires)
|
|
48
|
+
domain: 'das-sc.brighticecream.com'
|
|
52
49
|
});
|
|
53
50
|
|
|
54
51
|
// 将 x-access-token 保存到 cookie
|
|
55
52
|
Cookies.set(xAccessTokenCookieName, xAccessToken || '', {
|
|
56
|
-
domain:
|
|
57
|
-
expires: new Date(xAccessTokenExpires)
|
|
53
|
+
domain: 'das-sc.brighticecream.com'
|
|
58
54
|
});
|
|
59
55
|
}
|
|
60
56
|
export function storeAccessToken(token) {
|