coolcare-lite-scada-component 4.1.0 → 4.1.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.
Files changed (96) hide show
  1. package/es/app.js +23 -0
  2. package/es/components/BoxShadowPicker/index.less.d.ts +9 -9
  3. package/es/components/ColorPicker/util.js +4 -4
  4. package/es/components/DialogHistory/index.css +22 -0
  5. package/es/components/DialogHistory/index.js +388 -79
  6. package/es/components/DialogImagePicker/GroupPanel/index.js +1 -12
  7. package/es/components/ECharts/index.js +31 -23
  8. package/es/components/FormBindPoint/FreedomScene.js +181 -11
  9. package/es/components/FormBindPoint/ProductionOrDeviceScene.js +12 -5
  10. package/es/components/FormBindPoint/index.js +6 -0
  11. package/es/components/Icon/index.js +1 -1
  12. package/es/components/IconFont/index.js +6 -0
  13. package/es/components/ImageUploader/index.js +8 -7
  14. package/es/components/ModalChangePointValue.js +272 -0
  15. package/es/components/ModalChoosePoint/index.js +53 -16
  16. package/es/components/PointSelect/DeviceIndicatorTable.js +111 -0
  17. package/es/components/PointSelect/IndicatorSelect.js +182 -0
  18. package/es/constant.js +2 -2
  19. package/es/element/BorderBox/util/typings.d.ts +9 -9
  20. package/es/element/Decoration/util/typings.d.ts +9 -9
  21. package/es/element/EleFan/Component.js +1 -1
  22. package/es/element/EleFanBySvg/index.js +3 -3
  23. package/es/element/EleImage/index.js +1 -1
  24. package/es/element/ElePointImage/Component.js +30 -41
  25. package/es/element/ElePointImage/index.js +1 -1
  26. package/es/element/ElePointValue/Component.js +117 -17
  27. package/es/element/ElePointValue/PropsSet/StatisticsPropsSet/index.js +6 -0
  28. package/es/element/ElePointValue/index.css +11 -0
  29. package/es/element/ElePointValue/index.js +6 -0
  30. package/es/element/EleShine/Component.js +133 -23
  31. package/es/element/EleShine/PropsSet/OtherPropsSet/index.js +27 -34
  32. package/es/element/EleShine/PropsSet/PointAlarmTool.js +99 -0
  33. package/es/element/EleShine/PropsSet/index.js +9 -1
  34. package/es/element/EleShine/index.js +2 -1
  35. package/es/element/EleState/index.js +1 -1
  36. package/es/element/EleSwitch/Component.js +2 -12
  37. package/es/element/PipeNodes/NodeBL/index.js +1 -1
  38. package/es/element/PipeNodes/NodeBR/index.js +1 -1
  39. package/es/element/PipeNodes/NodeBottom/index.js +1 -1
  40. package/es/element/PipeNodes/NodeCenter/index.js +1 -1
  41. package/es/element/PipeNodes/NodeHorizontal/index.js +1 -1
  42. package/es/element/PipeNodes/NodeLeft/index.js +1 -1
  43. package/es/element/PipeNodes/NodeRight/index.js +1 -1
  44. package/es/element/PipeNodes/NodeTL/index.js +1 -1
  45. package/es/element/PipeNodes/NodeTR/index.js +1 -1
  46. package/es/element/PipeNodes/NodeTop/index.js +1 -1
  47. package/es/element/PipeNodes/NodeVertical/index.js +1 -1
  48. package/es/element/PointCard/PointListCard/Component.js +3 -2
  49. package/es/element/PointCard/PointListCard/index.js +1 -0
  50. package/es/element/type.d.ts +4 -6
  51. package/es/element/utils/getValueByExpression.js +3 -0
  52. package/es/element/utils/handleEleEvent.js +11 -1
  53. package/es/element/utils/pointWrite.js +4 -5
  54. package/es/hooks/usePointWatch.js +1 -1
  55. package/es/models/useEditor.js +14 -8
  56. package/es/pages/display/Player/index.js +444 -123
  57. package/es/pages/display/index.js +2 -2
  58. package/es/pages/document.ejs +1 -1
  59. package/es/pages/editor/PanelLeft/BasicShapeList/listData.js +8 -8
  60. package/es/pages/editor/PanelLeft/BorderBoxEleList/index.less.d.ts +7 -7
  61. package/es/pages/editor/PanelLeft/DecorationEleList/index.less.d.ts +7 -7
  62. package/es/pages/editor/PanelLeft/GroupManageDialog/index.js +4 -4
  63. package/es/pages/editor/PanelLeft/ImgGroup/index.js +1 -12
  64. package/es/pages/editor/PanelLeft/MetaEleList/listData.js +14 -14
  65. package/es/pages/editor/PanelLeft/PipeEleList/listData.js +11 -11
  66. package/es/pages/editor/PanelLeft/PointCardEleList/listData.js +6 -6
  67. package/es/pages/editor/PanelLeft/RecommendEleList/listData.js +4 -4
  68. package/es/pages/editor/PanelLeft/index.js +3 -3
  69. package/es/pages/editor/PanelRight/components/FormLayer/index.js +3 -1
  70. package/es/pages/editor/PanelRight/index.less.d.ts +7 -7
  71. package/es/pages/editor/PanelTop/HotKeyDescribe/index.js +1 -1
  72. package/es/pages/editor/PanelTop/Save/index.js +120 -67
  73. package/es/pages/editor/index.js +223 -135
  74. package/es/pages/editor/utils/scadaChangeLog.js +237 -0
  75. package/es/services/common/Uploader.js +1 -1
  76. package/es/services/common/typings.d.ts +15 -15
  77. package/es/services/energy/index.js +56 -0
  78. package/es/services/gateway/Device.js +22 -0
  79. package/es/services/gateway/Point.js +46 -25
  80. package/es/services/gateway/typings.d.ts +3 -0
  81. package/es/services/master/typings.d.ts +362 -362
  82. package/es/services/product/typings.d.ts +1045 -1045
  83. package/es/services/project/typings.d.ts +1609 -1609
  84. package/es/services/request.js +126 -13
  85. package/es/shims.x6.d.ts +15 -15
  86. package/es/typings.d.ts +12 -0
  87. package/es/utils/auth.js +6 -2
  88. package/es/utils/cssStyle.js +4 -4
  89. package/es/utils/dataURItoBlob.js +25 -0
  90. package/es/utils/date.js +7 -0
  91. package/es/utils/decomposeMatrix.js +5 -5
  92. package/es/utils/events.js +3 -3
  93. package/es/utils/index.js +34 -34
  94. package/es/utils/pointValueFormat.js +3 -3
  95. package/package.json +16 -15
  96. package/es/elementCss.css +0 -19
@@ -3,7 +3,7 @@ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try {
3
3
  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); }
4
4
  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); }); }; }
5
5
  import React from "react";
6
- import { useEffect, useRef } from 'react';
6
+ import { useCallback, useEffect, useRef } from 'react';
7
7
  import { useModel, Helmet } from 'umi';
8
8
  import { message } from 'antd';
9
9
  import { GetDeviceConfiguration } from "../../services/gateway/Device";
@@ -11,17 +11,18 @@ import { GetCompanyConfigurationPage } from "../../services/gateway/CompanyConfi
11
11
  import { useQuery } from "../../hooks";
12
12
  import GraphCore from "../../graph/graphCore";
13
13
  import { defaultDeviceMobileSize, defaultDevicePCSize } from "../../constant";
14
+ import { buildScadaConfigSnapshot, captureScadaScreenshot, setScadaConfigSnapshotToStorage } from "./utils/scadaChangeLog";
14
15
  import Palette from "./Palette";
15
16
  import PanelTop from "./PanelTop";
16
17
  import PanelLeft from "./PanelLeft";
17
18
  import PanelRight from "./PanelRight";
18
19
  import styles from "./index.css";
19
20
 
20
- // 注册工具 Tools [https://x6.antv.vision/zh/docs/tutorial/intermediate/tools]
21
+ // 濞夈劌鍞藉銉ュ徔 Tools [https://x6.antv.vision/zh/docs/tutorial/intermediate/tools]
21
22
  import "../../graph/tools/registerX6Tool";
22
- // 注册自定义 node
23
+ // 濞夈劌鍞介懛顏勭暰娑?node
23
24
  import "../../element/register";
24
- // 注册自定义 edge
25
+ // 濞夈劌鍞介懛顏勭暰娑?edge
25
26
  import "../../edge/register";
26
27
  export default (function () {
27
28
  var paletteWrapRef = useRef(null);
@@ -31,13 +32,41 @@ export default (function () {
31
32
  graphCoreRef: model.graphCoreRef,
32
33
  setScene: model.setScene,
33
34
  setPageConfig: model.setPageConfig,
34
- fetchUserDeviceList: model.fetchUserDeviceList
35
+ fetchUserDeviceList: model.fetchUserDeviceList,
36
+ setInitialScadaConfigSnapshot: model.setInitialScadaConfigSnapshot
35
37
  };
36
38
  }),
37
39
  graphCoreRef = _useModel.graphCoreRef,
38
40
  setScene = _useModel.setScene,
39
41
  setPageConfig = _useModel.setPageConfig,
40
- fetchUserDeviceList = _useModel.fetchUserDeviceList;
42
+ fetchUserDeviceList = _useModel.fetchUserDeviceList,
43
+ setInitialScadaConfigSnapshot = _useModel.setInitialScadaConfigSnapshot;
44
+ var cacheScadaConfig = useCallback(/*#__PURE__*/function () {
45
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(pageConfigValue) {
46
+ var _graphCoreRef$current;
47
+ var graph, snapshot, _t, _t2, _t3;
48
+ return _regenerator().w(function (_context) {
49
+ while (1) switch (_context.n) {
50
+ case 0:
51
+ graph = (_graphCoreRef$current = graphCoreRef.current) === null || _graphCoreRef$current === void 0 ? void 0 : _graphCoreRef$current.graph;
52
+ _t = buildScadaConfigSnapshot;
53
+ _t2 = pageConfigValue || {};
54
+ _t3 = graph;
55
+ _context.n = 1;
56
+ return captureScadaScreenshot(graph);
57
+ case 1:
58
+ snapshot = _t(_t2, _t3, _context.v);
59
+ setInitialScadaConfigSnapshot(JSON.stringify(snapshot));
60
+ setScadaConfigSnapshotToStorage(query, snapshot);
61
+ case 2:
62
+ return _context.a(2);
63
+ }
64
+ }, _callee);
65
+ }));
66
+ return function (_x) {
67
+ return _ref.apply(this, arguments);
68
+ };
69
+ }(), [graphCoreRef, query, setInitialScadaConfigSnapshot]);
41
70
  useEffect(function () {
42
71
  setScene(query.scene);
43
72
  }, [query, setScene]);
@@ -45,43 +74,67 @@ export default (function () {
45
74
  window.scadaMode = 'edit';
46
75
  }, []);
47
76
  useEffect(function () {
48
- var handler = function handler(e) {
49
- var _graphCoreRef$current;
50
- var graph = (_graphCoreRef$current = graphCoreRef.current) === null || _graphCoreRef$current === void 0 ? void 0 : _graphCoreRef$current.graph;
51
- var data = e.data;
52
- if (data.event === 'response-product-scada-config' && query.scene === 'product') {
53
- if (data.payload) {
54
- var configJSON = JSON.parse(data.payload || '{}');
55
- graph === null || graph === void 0 ? void 0 : graph.fromJSON(configJSON);
56
- // 缩放画布内容,使画布内容充满视口
57
- graph === null || graph === void 0 ? void 0 : graph.zoomToFit({
58
- padding: 20,
59
- // 边距
60
- preserveAspectRatio: true // 是否保持长宽比。
61
- });
62
- setPageConfig(configJSON.pageConfig);
63
- } else {
64
- var _graphCoreRef$current2;
65
- // query.scadaType 0:web 端 1:移动端
66
- var width = query.scadaType === '0' ? defaultDevicePCSize.width : defaultDeviceMobileSize.width;
67
- var height = query.scadaType === '0' ? defaultDevicePCSize.height : defaultDeviceMobileSize.height;
68
- setPageConfig({
69
- dimensions: {
70
- width: width,
71
- height: height
72
- }
73
- });
74
- (_graphCoreRef$current2 = graphCoreRef.current) === null || _graphCoreRef$current2 === void 0 ? void 0 : _graphCoreRef$current2.initScadaContainer(width, height);
75
- }
76
- }
77
- };
77
+ var handler = /*#__PURE__*/function () {
78
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
79
+ var _graphCoreRef$current2;
80
+ var graph, data, configJSON, _graphCoreRef$current3, width, height, initialPageConfig;
81
+ return _regenerator().w(function (_context2) {
82
+ while (1) switch (_context2.n) {
83
+ case 0:
84
+ graph = (_graphCoreRef$current2 = graphCoreRef.current) === null || _graphCoreRef$current2 === void 0 ? void 0 : _graphCoreRef$current2.graph;
85
+ data = e.data;
86
+ if (!(data.event === 'response-product-scada-config' && query.scene === 'product')) {
87
+ _context2.n = 3;
88
+ break;
89
+ }
90
+ if (!data.payload) {
91
+ _context2.n = 2;
92
+ break;
93
+ }
94
+ configJSON = JSON.parse(data.payload || '{}');
95
+ graph === null || graph === void 0 ? void 0 : graph.fromJSON(configJSON);
96
+ // 缂傗晜鏂侀悽璇茬閸愬懎顔愰敍灞煎▏閻㈣绔烽崘鍛啇閸忓懏寮х憴鍡楀經
97
+ graph === null || graph === void 0 ? void 0 : graph.zoomToFit({
98
+ padding: 20,
99
+ // 鏉堢绐?
100
+ preserveAspectRatio: true // 閺勵垰鎯佹穱婵囧瘮闂€鍨啍濮f柣鈧?
101
+ });
102
+ setPageConfig(configJSON.pageConfig);
103
+ _context2.n = 1;
104
+ return cacheScadaConfig(configJSON.pageConfig);
105
+ case 1:
106
+ _context2.n = 3;
107
+ break;
108
+ case 2:
109
+ // query.scadaType 0閿涙eb 缁?1閿涙氨些閸斻劎顏?
110
+ width = query.scadaType === '0' ? defaultDevicePCSize.width : defaultDeviceMobileSize.width;
111
+ height = query.scadaType === '0' ? defaultDevicePCSize.height : defaultDeviceMobileSize.height;
112
+ initialPageConfig = {
113
+ dimensions: {
114
+ width: width,
115
+ height: height
116
+ }
117
+ };
118
+ setPageConfig(initialPageConfig);
119
+ (_graphCoreRef$current3 = graphCoreRef.current) === null || _graphCoreRef$current3 === void 0 ? void 0 : _graphCoreRef$current3.initScadaContainer(width, height);
120
+ _context2.n = 3;
121
+ return cacheScadaConfig(initialPageConfig);
122
+ case 3:
123
+ return _context2.a(2);
124
+ }
125
+ }, _callee2);
126
+ }));
127
+ return function handler(_x2) {
128
+ return _ref2.apply(this, arguments);
129
+ };
130
+ }();
78
131
  window.addEventListener('message', handler);
79
132
  return function () {
80
133
  window.removeEventListener('message', handler);
81
134
  };
82
- }, [query, graphCoreRef, setPageConfig]);
135
+ }, [query, graphCoreRef, setPageConfig, cacheScadaConfig]);
83
136
 
84
- // 初始化 graph 并获取组态配置
137
+ // 閸掓繂顫愰崠?graph 楠炴儼骞忛崣鏍矋閹線鍘ょ純?
85
138
  useEffect(function () {
86
139
  var canvasDom = document.getElementById('palette-wrap');
87
140
  if (!canvasDom) {
@@ -101,166 +154,201 @@ export default (function () {
101
154
  productVersionId: Number(query.productVersionId)
102
155
  }
103
156
  };
104
- // 向 parent 窗口发送消息,请求组态配置
157
+ // 閸?parent 缁愭褰涢崣鎴︹偓浣圭Х閹垽绱濈拠閿嬬湴缂佸嫭鈧線鍘ょ純?
105
158
  (_window$opener = window.opener) === null || _window$opener === void 0 ? void 0 : _window$opener.postMessage(msg, '*');
106
159
  }
107
160
  if (query.scene === 'device') {
108
161
  var fetchDeviceScadaConfig = /*#__PURE__*/function () {
109
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
110
- var hideMsg, _yield$GetDeviceConfi, success, data, activeScada, configJSON, width, height, _t;
111
- return _regenerator().w(function (_context) {
112
- while (1) switch (_context.p = _context.n) {
162
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
163
+ var hideMsg, _yield$GetDeviceConfi, success, data, activeScada, configJSON, width, height, initialPageConfig, _t4;
164
+ return _regenerator().w(function (_context3) {
165
+ while (1) switch (_context3.p = _context3.n) {
113
166
  case 0:
114
- hideMsg = message.loading('配置获取中');
115
- _context.p = 1;
116
- _context.n = 2;
167
+ hideMsg = message.loading('Loading scada config');
168
+ _context3.p = 1;
169
+ _context3.n = 2;
117
170
  return GetDeviceConfiguration({
118
171
  deviceConfigurationType: Number(query.scadaType),
119
172
  deviceId: Number(query.deviceId)
120
173
  });
121
174
  case 2:
122
- _yield$GetDeviceConfi = _context.v;
175
+ _yield$GetDeviceConfi = _context3.v;
123
176
  success = _yield$GetDeviceConfi.success;
124
177
  data = _yield$GetDeviceConfi.data;
125
178
  if (success) {
126
- _context.n = 3;
179
+ _context3.n = 3;
127
180
  break;
128
181
  }
129
- message.error('组态配置获取失败');
130
- return _context.a(2);
182
+ message.error('Load configuration failed');
183
+ return _context3.a(2);
131
184
  case 3:
132
185
  activeScada = data === null || data === void 0 ? void 0 : data.find(function (v) {
133
186
  return v.deviceConfigurationType === Number(query.scadaType);
134
187
  });
135
- if (activeScada === null || activeScada === void 0 ? void 0 : activeScada.config) {
136
- configJSON = JSON.parse(activeScada.config || '{}');
137
- graphCore.graph.fromJSON(configJSON);
138
- if (configJSON.pageConfig) {
139
- setPageConfig(configJSON.pageConfig);
140
- }
141
- // 缩放画布内容,使画布内容充满视口
142
- graphCore.graph.zoomToFit({
143
- padding: 20,
144
- // 边距
145
- preserveAspectRatio: true // 是否保持长宽比。
146
- });
147
- } else {
148
- // query.scadaType 0:web 端 1:移动端
149
- width = query.scadaType === '0' ? defaultDevicePCSize.width : defaultDeviceMobileSize.width;
150
- height = query.scadaType === '0' ? defaultDevicePCSize.height : defaultDeviceMobileSize.height;
151
- setPageConfig({
152
- dimensions: {
153
- width: width,
154
- height: height
155
- }
156
- });
157
- graphCore.initScadaContainer(width, height);
188
+ if (!(activeScada === null || activeScada === void 0 ? void 0 : activeScada.config)) {
189
+ _context3.n = 5;
190
+ break;
158
191
  }
159
- _context.n = 5;
160
- break;
192
+ configJSON = JSON.parse(activeScada.config || '{}');
193
+ graphCore.graph.fromJSON(configJSON);
194
+ if (configJSON.pageConfig) {
195
+ setPageConfig(configJSON.pageConfig);
196
+ }
197
+ // 缂傗晜鏂侀悽璇茬閸愬懎顔愰敍灞煎▏閻㈣绔烽崘鍛啇閸忓懏寮х憴鍡楀經
198
+ graphCore.graph.zoomToFit({
199
+ padding: 20,
200
+ // 鏉堢绐?
201
+ preserveAspectRatio: true // 閺勵垰鎯佹穱婵囧瘮闂€鍨啍濮f柣鈧?
202
+ });
203
+ _context3.n = 4;
204
+ return cacheScadaConfig(configJSON.pageConfig || {});
161
205
  case 4:
162
- _context.p = 4;
163
- _t = _context.v;
164
- console.error(_t);
165
- message.error('组态配置获取失败');
206
+ _context3.n = 6;
207
+ break;
166
208
  case 5:
167
- _context.p = 5;
168
- hideMsg();
169
- return _context.f(5);
209
+ // query.scadaType 0閿涙eb 缁?1閿涙氨些閸斻劎顏?
210
+ width = query.scadaType === '0' ? defaultDevicePCSize.width : defaultDeviceMobileSize.width;
211
+ height = query.scadaType === '0' ? defaultDevicePCSize.height : defaultDeviceMobileSize.height;
212
+ initialPageConfig = {
213
+ dimensions: {
214
+ width: width,
215
+ height: height
216
+ }
217
+ };
218
+ setPageConfig(initialPageConfig);
219
+ graphCore.initScadaContainer(width, height);
220
+ _context3.n = 6;
221
+ return cacheScadaConfig(initialPageConfig);
170
222
  case 6:
171
- return _context.a(2);
223
+ _context3.n = 8;
224
+ break;
225
+ case 7:
226
+ _context3.p = 7;
227
+ _t4 = _context3.v;
228
+ console.error(_t4);
229
+ message.error('Load configuration failed');
230
+ case 8:
231
+ _context3.p = 8;
232
+ hideMsg();
233
+ return _context3.f(8);
234
+ case 9:
235
+ return _context3.a(2);
172
236
  }
173
- }, _callee, null, [[1, 4, 5, 6]]);
237
+ }, _callee3, null, [[1, 7, 8, 9]]);
174
238
  }));
175
239
  return function fetchDeviceScadaConfig() {
176
- return _ref.apply(this, arguments);
240
+ return _ref3.apply(this, arguments);
177
241
  };
178
242
  }();
179
243
  fetchDeviceScadaConfig();
180
244
  }
181
245
  if (query.scene === 'freedom') {
182
246
  var fetchScadaConfig = /*#__PURE__*/function () {
183
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
184
- var hideMsg, _data$list, _yield$GetCompanyConf, success, data, scadaConfig, configJSON, width, height, _t2;
185
- return _regenerator().w(function (_context2) {
186
- while (1) switch (_context2.p = _context2.n) {
247
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
248
+ var hideMsg, _data$list, _yield$GetCompanyConf, success, data, scadaConfig, _configJSON$cells, configJSON, width, height, initialPageConfig, _t5;
249
+ return _regenerator().w(function (_context4) {
250
+ while (1) switch (_context4.p = _context4.n) {
187
251
  case 0:
188
- hideMsg = message.loading('配置获取中');
189
- _context2.p = 1;
190
- _context2.n = 2;
252
+ hideMsg = message.loading('Loading scada config');
253
+ _context4.p = 1;
254
+ _context4.n = 2;
191
255
  return GetCompanyConfigurationPage({
192
256
  companyConfigurationId: Number(query.scadaId),
193
257
  isGetConfig: true,
194
258
  companyId: Number(query.companyId)
195
259
  });
196
260
  case 2:
197
- _yield$GetCompanyConf = _context2.v;
261
+ _yield$GetCompanyConf = _context4.v;
198
262
  success = _yield$GetCompanyConf.success;
199
263
  data = _yield$GetCompanyConf.data;
200
264
  if (!(!success || !(data === null || data === void 0 ? void 0 : (_data$list = data.list) === null || _data$list === void 0 ? void 0 : _data$list.length))) {
201
- _context2.n = 3;
265
+ _context4.n = 3;
202
266
  break;
203
267
  }
204
- message.error('组态配置获取失败');
205
- return _context2.a(2);
268
+ message.error('Load configuration failed');
269
+ return _context4.a(2);
206
270
  case 3:
207
271
  scadaConfig = data.list[0].config;
208
- if (scadaConfig) {
209
- configJSON = JSON.parse((scadaConfig || '{}').replaceAll('https://coolcare-scada.oss-cn-shanghai.aliyuncs.com/', 'http://192.168.2.12:9000/xiaomai/').replaceAll('https://front-end-assets.oss-cn-shanghai.aliyuncs.com/', 'http://192.168.2.12:9000/xiaomai/'));
210
- graphCore.graph.fromJSON(configJSON);
211
- if (configJSON.pageConfig) {
212
- setPageConfig(configJSON.pageConfig);
213
- }
214
- // 缩放画布内容,使画布内容充满视口
215
- graphCore.graph.zoomToFit({
216
- padding: 20,
217
- // 边距
218
- preserveAspectRatio: true // 是否保持长宽比。
219
- });
220
- } else {
221
- width = 1366;
222
- height = 768;
223
- setPageConfig({
224
- title: query.title,
225
- dimensions: {
226
- width: width,
227
- height: height
272
+ if (!scadaConfig) {
273
+ _context4.n = 5;
274
+ break;
275
+ }
276
+ configJSON = JSON.parse(scadaConfig || '{}'); // 娣囶喖顦查崥搴n伂娣囨繂鐡ㄩ弫鐗堝祦閺冭绱濋崶鐖卻on閺佺増宓佺粔宥呯摠閸?%"閼板苯顕遍懛瀵告畱"%"閺佺増宓佹稉銏犮亼闂傤噣顣?
277
+ if (configJSON === null || configJSON === void 0 ? void 0 : (_configJSON$cells = configJSON.cells) === null || _configJSON$cells === void 0 ? void 0 : _configJSON$cells.length) {
278
+ configJSON === null || configJSON === void 0 ? void 0 : configJSON.cells.forEach(function (item) {
279
+ var _item$attrs, _item$attrs$body, _item$attrs2, _item$attrs2$body, _item$attrs2$body$ref, _item$attrs3, _item$attrs3$body, _item$attrs5, _item$attrs5$body, _item$attrs6, _item$attrs6$body, _item$attrs6$body$ref, _item$attrs7, _item$attrs7$body;
280
+ if ((item === null || item === void 0 ? void 0 : (_item$attrs = item.attrs) === null || _item$attrs === void 0 ? void 0 : (_item$attrs$body = _item$attrs.body) === null || _item$attrs$body === void 0 ? void 0 : _item$attrs$body.refWidth) && (item === null || item === void 0 ? void 0 : (_item$attrs2 = item.attrs) === null || _item$attrs2 === void 0 ? void 0 : (_item$attrs2$body = _item$attrs2.body) === null || _item$attrs2$body === void 0 ? void 0 : (_item$attrs2$body$ref = _item$attrs2$body.refWidth) === null || _item$attrs2$body$ref === void 0 ? void 0 : _item$attrs2$body$ref.indexOf('%')) === -1 && !isNaN(Number(item === null || item === void 0 ? void 0 : (_item$attrs3 = item.attrs) === null || _item$attrs3 === void 0 ? void 0 : (_item$attrs3$body = _item$attrs3.body) === null || _item$attrs3$body === void 0 ? void 0 : _item$attrs3$body.refWidth))) {
281
+ var _item$attrs4, _item$attrs4$body;
282
+ item.attrs.body.refWidth = "".concat(item === null || item === void 0 ? void 0 : (_item$attrs4 = item.attrs) === null || _item$attrs4 === void 0 ? void 0 : (_item$attrs4$body = _item$attrs4.body) === null || _item$attrs4$body === void 0 ? void 0 : _item$attrs4$body.refWidth, "%");
283
+ }
284
+ if ((item === null || item === void 0 ? void 0 : (_item$attrs5 = item.attrs) === null || _item$attrs5 === void 0 ? void 0 : (_item$attrs5$body = _item$attrs5.body) === null || _item$attrs5$body === void 0 ? void 0 : _item$attrs5$body.refHeight) && (item === null || item === void 0 ? void 0 : (_item$attrs6 = item.attrs) === null || _item$attrs6 === void 0 ? void 0 : (_item$attrs6$body = _item$attrs6.body) === null || _item$attrs6$body === void 0 ? void 0 : (_item$attrs6$body$ref = _item$attrs6$body.refHeight) === null || _item$attrs6$body$ref === void 0 ? void 0 : _item$attrs6$body$ref.indexOf('%')) === -1 && !isNaN(Number(item === null || item === void 0 ? void 0 : (_item$attrs7 = item.attrs) === null || _item$attrs7 === void 0 ? void 0 : (_item$attrs7$body = _item$attrs7.body) === null || _item$attrs7$body === void 0 ? void 0 : _item$attrs7$body.refHeight))) {
285
+ var _item$attrs8, _item$attrs8$body;
286
+ item.attrs.body.refHeight = "".concat(item === null || item === void 0 ? void 0 : (_item$attrs8 = item.attrs) === null || _item$attrs8 === void 0 ? void 0 : (_item$attrs8$body = _item$attrs8.body) === null || _item$attrs8$body === void 0 ? void 0 : _item$attrs8$body.refHeight, "%");
228
287
  }
229
288
  });
230
- graphCore.initScadaContainer(width, height);
231
289
  }
232
- _context2.n = 5;
233
- break;
290
+ graphCore.graph.fromJSON(configJSON);
291
+ if (configJSON.pageConfig) {
292
+ setPageConfig(configJSON.pageConfig);
293
+ }
294
+ // 缂傗晜鏂侀悽璇茬閸愬懎顔愰敍灞煎▏閻㈣绔烽崘鍛啇閸忓懏寮х憴鍡楀經
295
+ graphCore.graph.zoomToFit({
296
+ padding: 20,
297
+ // 鏉堢绐?
298
+ preserveAspectRatio: true // 閺勵垰鎯佹穱婵囧瘮闂€鍨啍濮f柣鈧?
299
+ });
300
+ _context4.n = 4;
301
+ return cacheScadaConfig(configJSON.pageConfig || {});
234
302
  case 4:
235
- _context2.p = 4;
236
- _t2 = _context2.v;
237
- console.error(_t2);
238
- message.error('组态配置获取失败');
303
+ _context4.n = 6;
304
+ break;
239
305
  case 5:
240
- _context2.p = 5;
241
- hideMsg();
242
- return _context2.f(5);
306
+ width = 1366;
307
+ height = 768;
308
+ initialPageConfig = {
309
+ title: query.title,
310
+ dimensions: {
311
+ width: width,
312
+ height: height
313
+ }
314
+ };
315
+ setPageConfig(initialPageConfig);
316
+ graphCore.initScadaContainer(width, height);
317
+ _context4.n = 6;
318
+ return cacheScadaConfig(initialPageConfig);
243
319
  case 6:
244
- return _context2.a(2);
320
+ _context4.n = 8;
321
+ break;
322
+ case 7:
323
+ _context4.p = 7;
324
+ _t5 = _context4.v;
325
+ console.error(_t5);
326
+ message.error('Load configuration failed');
327
+ case 8:
328
+ _context4.p = 8;
329
+ hideMsg();
330
+ return _context4.f(8);
331
+ case 9:
332
+ return _context4.a(2);
245
333
  }
246
- }, _callee2, null, [[1, 4, 5, 6]]);
334
+ }, _callee4, null, [[1, 7, 8, 9]]);
247
335
  }));
248
336
  return function fetchScadaConfig() {
249
- return _ref2.apply(this, arguments);
337
+ return _ref4.apply(this, arguments);
250
338
  };
251
339
  }();
252
340
  fetchScadaConfig();
253
341
  }
254
- }, [graphCoreRef, query, setPageConfig]);
342
+ }, [cacheScadaConfig, graphCoreRef, query, setPageConfig]);
255
343
  useEffect(function () {
256
344
  if (process.env.NODE_ENV === 'production') {
257
345
  window.onbeforeunload = function (e) {
258
346
  e = e || window.event;
259
347
  if (e) {
260
- // 兼容IE8和Firefox 4之前的版本
261
- e.returnValue = '确定离开?';
348
+ // Keep the same behavior as before.
349
+ e.returnValue = 'Are you sure you want to leave?';
262
350
  }
263
- return '确定离开?';
351
+ return 'Are you sure you want to leave?';
264
352
  };
265
353
  }
266
354
  return function () {
@@ -268,7 +356,7 @@ export default (function () {
268
356
  };
269
357
  }, []);
270
358
 
271
- // scene 为 freedom 时,获取用户设备列表
359
+ // scene 娑?freedom 閺冭绱濋懢宄板絿閻劍鍩涚拋鎯ь槵閸掓銆?
272
360
  useEffect(function () {
273
361
  if (query.scene !== 'freedom') {
274
362
  return;
@@ -278,7 +366,7 @@ export default (function () {
278
366
  projectId: query.projectId ? Number(query.projectId) : undefined
279
367
  } : undefined);
280
368
  }, [query, fetchUserDeviceList]);
281
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Helmet, null, /*#__PURE__*/React.createElement("title", null, "\u7EC4\u6001 CoolCare")), /*#__PURE__*/React.createElement("div", {
369
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Helmet, null, /*#__PURE__*/React.createElement("title", null, "\u7F02\u4F78\u5AED\u9227?CoolCare")), /*#__PURE__*/React.createElement("div", {
282
370
  className: "".concat(styles.editor)
283
371
  }, /*#__PURE__*/React.createElement("header", {
284
372
  className: styles['header-tools']