coolcare-lite-scada-component 1.0.0 → 1.0.2

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 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 3:
48
+ case 4:
46
49
  case "end":
47
50
  return _context.stop();
48
51
  }
@@ -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() {
@@ -84,13 +84,18 @@ 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',
93
- staging: 'https://dev.sinocold.com:30443'
97
+ staging: 'https://dev.sinocold.com:30443',
98
+ generalfushi: 'https://iot.generalfushi.com'
94
99
  };
95
100
  var requestClient = extend({
96
101
  errorHandler: errorHandler
@@ -103,7 +108,7 @@ requestClient.use( /*#__PURE__*/function () {
103
108
  case 0:
104
109
  req = ctx.req;
105
110
  url = req.url;
106
- ctx.req.url = "".concat(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);
107
112
  _context.next = 5;
108
113
  return next();
109
114
  case 5:
package/es/typings.d.ts CHANGED
@@ -8,7 +8,7 @@ interface Window {
8
8
  $emitter: import('mitt').Emitter<any>;
9
9
  }
10
10
 
11
- declare const REACT_APP_ENV: 'dev' | 'prod' | 'staging';
11
+ declare const REACT_APP_ENV: 'dev' | 'prod' | 'staging' | string;
12
12
 
13
13
  /**
14
14
  * 编辑场景
@@ -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
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "coolcare-lite-scada-component",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "scripts": {
5
5
  "start": "umi dev",
6
6
  "build:prod": "UMI_ENV=prod umi build",
7
+ "build:generalfushi": "UMI_ENV=prod REACT_APP_PLATFORM=generalfushi umi build",
7
8
  "build:staging": "UMI_ENV=staging umi build",
8
9
  "build:component": "father build",
9
10
  "postinstall": "umi generate tmp",