coolcare-lite-scada-component 1.0.1 → 1.0.3
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/app.js +5 -2
- package/es/element/EleDeviceName/Component.js +1 -1
- package/es/element/EleDeviceState/Component.js +1 -1
- package/es/element/EleDeviceUpdateTime/Component.js +1 -1
- package/es/pages/display/index.js +7 -1
- package/es/services/request.js +5 -1
- package/es/typings.d.ts +21 -0
- package/es/utils/auth.js +3 -0
- package/package.json +1 -1
package/es/app.js
CHANGED
|
@@ -9,7 +9,7 @@ import '@antv/x6-react-shape';
|
|
|
9
9
|
// import 'dayjs/locale/zh-cn';
|
|
10
10
|
|
|
11
11
|
import queryToObject from "./utils/queryToObject";
|
|
12
|
-
import { storeAccessToken } from "./utils/auth";
|
|
12
|
+
import { storeAccessToken, storeXAccessToken } from "./utils/auth";
|
|
13
13
|
|
|
14
14
|
// dayjs.locale('zh-cn');
|
|
15
15
|
|
|
@@ -41,8 +41,11 @@ function _getInitialState() {
|
|
|
41
41
|
if (query.accessToken) {
|
|
42
42
|
storeAccessToken(query.accessToken);
|
|
43
43
|
}
|
|
44
|
+
if (query.xAccessToken) {
|
|
45
|
+
storeXAccessToken(query.xAccessToken);
|
|
46
|
+
}
|
|
44
47
|
return _context.abrupt("return", {});
|
|
45
|
-
case
|
|
48
|
+
case 4:
|
|
46
49
|
case "end":
|
|
47
50
|
return _context.stop();
|
|
48
51
|
}
|
|
@@ -61,7 +61,7 @@ var EleDeviceNameComponent = function EleDeviceNameComponent(_ref) {
|
|
|
61
61
|
console.error(err);
|
|
62
62
|
},
|
|
63
63
|
refreshDeps: [deviceId, fetchAble],
|
|
64
|
-
pollingInterval:
|
|
64
|
+
pollingInterval: 10 * 60 * 1000
|
|
65
65
|
}),
|
|
66
66
|
deviceInfo = _useRequest.data;
|
|
67
67
|
var tooltipTitle = (deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.deviceName) || '设备名称';
|
|
@@ -76,7 +76,7 @@ var EleDeviceStateComponent = function EleDeviceStateComponent(_ref) {
|
|
|
76
76
|
console.error(err);
|
|
77
77
|
},
|
|
78
78
|
refreshDeps: [deviceId, fetchAble],
|
|
79
|
-
pollingInterval:
|
|
79
|
+
pollingInterval: 10 * 60 * 1000
|
|
80
80
|
}),
|
|
81
81
|
deviceInfo = _useRequest.data;
|
|
82
82
|
var tooltipTitle = null;
|
|
@@ -62,7 +62,7 @@ var EleDeviceUpdateTimeComponent = function EleDeviceUpdateTimeComponent(_ref) {
|
|
|
62
62
|
console.error(err);
|
|
63
63
|
},
|
|
64
64
|
refreshDeps: [deviceId, fetchAble],
|
|
65
|
-
pollingInterval:
|
|
65
|
+
pollingInterval: 10 * 60 * 1000
|
|
66
66
|
}),
|
|
67
67
|
deviceInfo = _useRequest.data;
|
|
68
68
|
var tooltipTitle = null;
|
|
@@ -15,10 +15,11 @@ import { queryToObject } from "../../utils";
|
|
|
15
15
|
import { GetProductConfiguration } from "../../services/product/Product";
|
|
16
16
|
import { GetDeviceConfiguration } from "../../services/gateway/Device";
|
|
17
17
|
import { GetCompanyConfigurationPage } from "../../services/gateway/CompanyConfiguration";
|
|
18
|
-
import { setRequestENV } from "../../services/request";
|
|
18
|
+
import { setRequestENV, setRequrl } from "../../services/request";
|
|
19
19
|
import Player from "./Player";
|
|
20
20
|
import ScadaEmpty from "./components/Empty";
|
|
21
21
|
import styles from "./index.css";
|
|
22
|
+
import { storeToken } from "../../utils/auth";
|
|
22
23
|
var Display = function Display(_ref) {
|
|
23
24
|
var query_ = _ref.query_;
|
|
24
25
|
var _useState = useState(),
|
|
@@ -34,6 +35,8 @@ var Display = function Display(_ref) {
|
|
|
34
35
|
if (query_) {
|
|
35
36
|
// 被当成组件使用时(非 iframe ),设置接口请求的 prefix
|
|
36
37
|
setRequestENV((query_ === null || query_ === void 0 ? void 0 : query_.env) || 'prod');
|
|
38
|
+
// 配置请求地址
|
|
39
|
+
setRequrl((query_ === null || query_ === void 0 ? void 0 : query_.reqUrl) || '');
|
|
37
40
|
}
|
|
38
41
|
}, [query_]);
|
|
39
42
|
|
|
@@ -41,6 +44,9 @@ var Display = function Display(_ref) {
|
|
|
41
44
|
useEffect(function () {
|
|
42
45
|
var query = queryRef.current;
|
|
43
46
|
if (!query) return;
|
|
47
|
+
if (query.token && query.xToken) {
|
|
48
|
+
storeToken(query.token, query.xToken);
|
|
49
|
+
}
|
|
44
50
|
if (query.scene === 'product') {
|
|
45
51
|
var fetchProductScadaConfig = /*#__PURE__*/function () {
|
|
46
52
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
package/es/services/request.js
CHANGED
|
@@ -84,9 +84,13 @@ var errorHandler = function errorHandler(error) {
|
|
|
84
84
|
|
|
85
85
|
/** 默认使用打包时的环境,但可以通过下面的 setRequestENV 方法设置(被当成组件使用时,需要调用 setRequestENV 设置) */
|
|
86
86
|
var Request_ENV = 'prod';
|
|
87
|
+
var reqUrl = '';
|
|
87
88
|
export function setRequestENV(env) {
|
|
88
89
|
Request_ENV = env;
|
|
89
90
|
}
|
|
91
|
+
export function setRequrl(val) {
|
|
92
|
+
reqUrl = val;
|
|
93
|
+
}
|
|
90
94
|
var requestPrefixMap = {
|
|
91
95
|
dev: 'https://dev.sinocold.com:30443',
|
|
92
96
|
prod: 'https://iot.sinocold.net',
|
|
@@ -104,7 +108,7 @@ requestClient.use( /*#__PURE__*/function () {
|
|
|
104
108
|
case 0:
|
|
105
109
|
req = ctx.req;
|
|
106
110
|
url = req.url;
|
|
107
|
-
ctx.req.url = "".concat(REACT_APP_PLATFORM && requestPrefixMap[REACT_APP_PLATFORM] ? requestPrefixMap[REACT_APP_PLATFORM] : requestPrefixMap[Request_ENV]).concat(url);
|
|
111
|
+
ctx.req.url = "".concat(reqUrl ? reqUrl : REACT_APP_PLATFORM && requestPrefixMap[REACT_APP_PLATFORM] ? requestPrefixMap[REACT_APP_PLATFORM] : requestPrefixMap[Request_ENV]).concat(url);
|
|
108
112
|
_context.next = 5;
|
|
109
113
|
return next();
|
|
110
114
|
case 5:
|
package/es/typings.d.ts
CHANGED
|
@@ -61,6 +61,9 @@ type PlayerQuery =
|
|
|
61
61
|
| {
|
|
62
62
|
/** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
|
|
63
63
|
env?: 'prod' | 'staging' | 'dev';
|
|
64
|
+
/** 请求地址 */
|
|
65
|
+
reqUrl?: string;
|
|
66
|
+
/** 使用场景 */
|
|
64
67
|
scene: 'product';
|
|
65
68
|
/** scene = 'production' 时传 产品 id */
|
|
66
69
|
productId: string;
|
|
@@ -77,10 +80,17 @@ type PlayerQuery =
|
|
|
77
80
|
* auto: 默认值,等比的情况下,尽量全屏铺满
|
|
78
81
|
*/
|
|
79
82
|
zoomMode?: 'width' | 'auto';
|
|
83
|
+
/** token */
|
|
84
|
+
token?: string;
|
|
85
|
+
/** 刷新token */
|
|
86
|
+
xToken?: string;
|
|
80
87
|
}
|
|
81
88
|
| {
|
|
82
89
|
/** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
|
|
83
90
|
env?: 'prod' | 'staging' | 'dev';
|
|
91
|
+
/** 请求地址 */
|
|
92
|
+
reqUrl?: string;
|
|
93
|
+
/** 使用场景 */
|
|
84
94
|
scene: 'device';
|
|
85
95
|
/** scene = 'device' 时传设备 id */
|
|
86
96
|
deviceId: string;
|
|
@@ -95,10 +105,17 @@ type PlayerQuery =
|
|
|
95
105
|
* auto: 默认值,等比的情况下,尽量全屏铺满
|
|
96
106
|
*/
|
|
97
107
|
zoomMode?: 'width' | 'auto';
|
|
108
|
+
/** token */
|
|
109
|
+
token?: string;
|
|
110
|
+
/** 刷新token */
|
|
111
|
+
xToken?: string;
|
|
98
112
|
}
|
|
99
113
|
| {
|
|
100
114
|
/** 通过输入的环境名 env, 决定接口调用的地址,默认是 prod */
|
|
101
115
|
env?: 'prod' | 'staging' | 'dev';
|
|
116
|
+
/** 请求地址 */
|
|
117
|
+
reqUrl?: string;
|
|
118
|
+
/** 使用场景 */
|
|
102
119
|
scene: 'freedom';
|
|
103
120
|
/** 组态 id */
|
|
104
121
|
scadaId: string;
|
|
@@ -113,6 +130,10 @@ type PlayerQuery =
|
|
|
113
130
|
* auto: 默认值,等比的情况下,尽量全屏铺满
|
|
114
131
|
*/
|
|
115
132
|
zoomMode?: 'width' | 'auto';
|
|
133
|
+
/** token */
|
|
134
|
+
token?: string;
|
|
135
|
+
/** 刷新token */
|
|
136
|
+
xToken?: string;
|
|
116
137
|
};
|
|
117
138
|
|
|
118
139
|
type WindowCommunicateMsg =
|
package/es/utils/auth.js
CHANGED
|
@@ -58,6 +58,9 @@ export function storeToken(accessToken, xAccessToken) {
|
|
|
58
58
|
export function storeAccessToken(token) {
|
|
59
59
|
Cookies.set(accessTokenCookieName, token);
|
|
60
60
|
}
|
|
61
|
+
export function storeXAccessToken(token) {
|
|
62
|
+
Cookies.set(xAccessTokenCookieName, token);
|
|
63
|
+
}
|
|
61
64
|
|
|
62
65
|
/**
|
|
63
66
|
* 从 cookie 获取 access-token
|