dcim-topology2d 1.0.3 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/chart-diagram/src/echarts/index.js +3 -6
  2. package/core/index.d.ts +1 -0
  3. package/core/index.js +1 -0
  4. package/core/src/activeLayer.d.ts +2 -10
  5. package/core/src/activeLayer.js +42 -41
  6. package/core/src/animateLayer.d.ts +3 -7
  7. package/core/src/animateLayer.js +10 -12
  8. package/core/src/calling.d.ts +1 -4
  9. package/core/src/calling.js +38 -41
  10. package/core/src/canvas.d.ts +1 -6
  11. package/core/src/canvas.js +17 -18
  12. package/core/src/common.d.ts +5 -5
  13. package/core/src/common.js +147 -110
  14. package/core/src/core.d.ts +3 -4
  15. package/core/src/core.js +222 -251
  16. package/core/src/divLayer.d.ts +2 -7
  17. package/core/src/divLayer.js +25 -25
  18. package/core/src/healps/changeData.d.ts +1 -1
  19. package/core/src/healps/changeData.js +31 -11
  20. package/core/src/hoverLayer.d.ts +2 -9
  21. package/core/src/hoverLayer.js +31 -34
  22. package/core/src/models/index.d.ts +0 -1
  23. package/core/src/models/index.js +0 -1
  24. package/core/src/offscreen.d.ts +1 -4
  25. package/core/src/offscreen.js +10 -8
  26. package/core/src/options.js +1 -0
  27. package/core/src/preview.d.ts +1 -13
  28. package/core/src/preview.js +26 -27
  29. package/core/src/renderLayer.d.ts +1 -3
  30. package/core/src/renderLayer.js +26 -31
  31. package/core/src/store/common.d.ts +9 -0
  32. package/core/src/store/common.js +5 -0
  33. package/core/src/store/data.d.ts +126 -0
  34. package/core/src/store/data.js +80 -0
  35. package/core/src/store/index.d.ts +2 -0
  36. package/core/src/store/index.js +2 -0
  37. package/core/src/utils/conversion.d.ts +7 -0
  38. package/core/src/utils/conversion.js +54 -0
  39. package/core/src/utils/dom.d.ts +4 -3
  40. package/core/src/utils/dom.js +2 -0
  41. package/package.json +1 -1
  42. package/core/src/models/data.d.ts +0 -26
  43. package/core/src/models/data.js +0 -77
  44. package/core/src/models/data.js.map +0 -1
  45. package/core/src/mqtt.d.ts +0 -14
  46. package/core/src/mqtt.js +0 -82
  47. package/core/src/mqtt.js.map +0 -1
  48. package/core/src/socket.d.ts +0 -10
  49. package/core/src/socket.js +0 -51
  50. package/core/src/socket.js.map +0 -1
@@ -13,51 +13,50 @@ var __extends = (this && this.__extends) || (function () {
13
13
  })();
14
14
  import { Store } from 'le5le-store';
15
15
  import { Layer } from './layer';
16
+ import { commonStore } from './store'
16
17
  var Canvas = /** @class */ (function (_super) {
17
18
  __extends(Canvas, _super);
18
- function Canvas(parentElem, options, TID) {
19
- if (options === void 0) { options = {}; }
19
+ function Canvas(TID) {
20
20
  var _this = _super.call(this, TID) || this;
21
- _this.parentElem = parentElem;
22
- _this.options = options;
23
21
  _this.canvas = document.createElement('canvas');
24
- _this.width = parentElem.clientWidth;
25
- _this.height = parentElem.clientHeight;
26
- _this.data = Store.get(_this.generateStoreKey('topology-data'));
22
+ _this.width = commonStore[TID].parentElem.clientWidth;
23
+ _this.height = commonStore[TID].parentElem.clientHeight;
27
24
  _this.canvas.style.position = 'absolute';
28
25
  _this.canvas.style.left = '0';
29
26
  _this.canvas.style.top = '0';
30
27
  _this.canvas.style.outline = 'none';
31
28
  if (!Canvas.dpiRatio) {
32
- if (!options.extDpiRatio && options.extDpiRatio !== 0) {
29
+ if (!commonStore[TID].options.extDpiRatio && commonStore[TID].options.extDpiRatio !== 0) {
33
30
  if (window.devicePixelRatio > 1) {
34
- options.extDpiRatio = 0.25;
31
+ commonStore[TID].options.extDpiRatio = 0.25;
35
32
  }
36
33
  else {
37
- options.extDpiRatio = 0;
34
+ commonStore[TID].options.extDpiRatio = 0;
38
35
  }
39
36
  }
40
- Canvas.dpiRatio = window.devicePixelRatio + options.extDpiRatio;
37
+ Canvas.dpiRatio = window.devicePixelRatio + commonStore[TID].options.extDpiRatio;
41
38
  }
42
39
  return _this;
43
40
  }
44
41
  Canvas.prototype.resize = function (size) {
45
42
  if (size) {
46
- this.width = size.width | 0;
43
+ this.width = size.width | 0;
47
44
  this.height = size.height | 0;
48
45
  }
49
46
  else {
50
- if (this.options.width && this.options.width !== 'auto') {
51
- this.width = this.options.width;
47
+ const TID = this.TID;
48
+ if(!commonStore[TID] || !commonStore[TID].options) return;
49
+ if (commonStore[TID].options.width && commonStore[TID].options.width !== 'auto') {
50
+ this.width = commonStore[TID].options.width;
52
51
  }
53
52
  else {
54
- this.width = this.parentElem.clientWidth;
53
+ this.width = commonStore[TID].parentElem.clientWidth;
55
54
  }
56
- if (this.options.height && this.options.height !== 'auto') {
57
- this.height = this.options.height;
55
+ if (commonStore[TID].options.height && commonStore[TID].options.height !== 'auto') {
56
+ this.height = commonStore[TID].options.height;
58
57
  }
59
58
  else {
60
- this.height = this.parentElem.clientHeight;
59
+ this.height = commonStore[TID].parentElem.clientHeight;
61
60
  }
62
61
  }
63
62
  this.canvas.style.width = this.width + 'px';
@@ -4,9 +4,9 @@ import { DivLayer } from './divLayer';
4
4
  import { AnimateLayer } from './animateLayer';
5
5
  import { RenderLayer } from './renderLayer';
6
6
  import { Offscreen } from './offscreen';
7
- import {Line, Node, Pen, Point, Rect, TopologyData} from './models';
7
+ import {Line, Node, Pen, Point, Rect} from './models';
8
8
  import {Padding, Options} from './options';
9
- import { Socket } from './socket';
9
+ import { visualization2DStore } from './store'
10
10
  declare enum MoveInType {
11
11
  None = 0,
12
12
  Line = 1,
@@ -21,8 +21,7 @@ declare enum MoveInType {
21
21
  }
22
22
  export declare class Common {
23
23
  //constructor(parent: HTMLElement, options: Options);
24
- options: Options;
25
- data: TopologyData;
24
+ store: visualization2DStore;
26
25
  moveInType: MoveInType;
27
26
  id: String;
28
27
  parentElem: HTMLElement;
@@ -33,7 +32,6 @@ export declare class Common {
33
32
  input: HTMLTextAreaElement;
34
33
  tipMarkdown: HTMLElement;
35
34
  tipElem: HTMLElement;
36
- socket: Socket;
37
35
  private subcribe;
38
36
  private subcribeRender;
39
37
  private subcribeImage;
@@ -58,6 +56,8 @@ export declare class Common {
58
56
  y: number;
59
57
  restore?: boolean;
60
58
  };
59
+ renderTimer: number;
60
+ lastRender: number;
61
61
  lastTranlated: {
62
62
  x: number;
63
63
  y: number;
@@ -3,11 +3,10 @@ import {DivLayer} from './divLayer';
3
3
  import {AnimateLayer} from './animateLayer';
4
4
  import {RenderLayer} from './renderLayer';
5
5
  import {Offscreen} from './offscreen';
6
- import {Socket} from './socket';
7
- import {Line, Node, Pen, Point, TopologyData, EventAction} from './models';
6
+ import {Line, Node, Point, EventAction} from './models';
8
7
  import {setConfItemNode} from './healps';
9
- import {s8, formatPadding, getRect, previewType} from './utils';
10
- import {DefalutOptions} from './options';
8
+ import {s8, formatPadding, getRect} from './utils';
9
+ import { useStore, clearStore } from './store'
11
10
  import {POLL} from './poll';
12
11
  import axios from 'axios';
13
12
  import * as mqtt from './mqtt.min';
@@ -29,28 +28,33 @@ var Common = /** @class */ (function () {
29
28
  function Common(parent, options) {
30
29
  var _this = this;
31
30
  _this.moveInType = MoveInType;
31
+ this.mqttDataSouse = axios.CancelToken.source();
32
32
  this.mouseDown = null;
33
+ this.renderTimer = 0;
34
+ this.lastRender = 0;
35
+ this.id = s8();
36
+ this.store = useStore(this.id);
33
37
  if (typeof parent === 'string') {
34
- this.parentElem = document.getElementById(parent);
38
+ this.store.parentElem = document.getElementById(parent);
35
39
  } else {
36
- this.parentElem = parent;
40
+ this.store.parentElem = parent;
37
41
  }
38
42
  if (!options) {
39
43
  options = {};
40
44
  }
41
- this.parentElem.style.position = 'relative';
42
- this.parentElem.style.overflow = 'auto';
43
- var font = Object.assign({}, DefalutOptions.font, options.font);
44
- options.font = font;
45
- this.options = Object.assign({}, DefalutOptions, options);
46
- this.data = new TopologyData();
47
- this.id = s8();
48
- Store.set(this.generateStoreKey('topology-data'), this.data);
45
+ this.store.parentElem.style.position = 'relative';
46
+ this.store.parentElem.style.overflow = 'auto';
47
+ //var font = Object.assign({}, DefalutOptions.font, options.font);
48
+ //options.font = font;
49
+ // this.options = Object.assign({}, DefalutOptions, options);
50
+ Object.assign(this.store.options, options);
51
+ this.store.options.interval = 50;
52
+ //Store.set(this.generateStoreKey('topology-data'), this.data);
49
53
  var id = this.id;
50
- this.animateLayer = new AnimateLayer(this.options, id);
51
- this.offscreen = new Offscreen(this.parentElem, this.options, id);
52
- this.canvas = new RenderLayer(this.parentElem, this.options, id);
53
- this.divLayer = new DivLayer(this.parentElem, this.options, id);
54
+ this.animateLayer = new AnimateLayer(id);
55
+ this.offscreen = new Offscreen(id);
56
+ this.canvas = new RenderLayer(id);
57
+ this.divLayer = new DivLayer(id);
54
58
  this.divLayer.canvas.tabIndex = 0;
55
59
  this.divLayer.canvas.ondblclick = this.ondblclick;
56
60
  this.divLayer.canvas.onblur = function () {
@@ -109,7 +113,6 @@ var Common = /** @class */ (function () {
109
113
  };
110
114
  this.openCount = 0;
111
115
  this.timmerByTopology = null;
112
- this.ratioCord = null;
113
116
  this.lastTranlated = {x: 0, y: 0};
114
117
  this.moveIn = {
115
118
  type: 'None',
@@ -136,7 +139,6 @@ var Common = /** @class */ (function () {
136
139
  this.tip = '';
137
140
  this.rendering = false;
138
141
  this.isFullScreen = false;
139
- this.socket = null;
140
142
  this.inputObj = null;
141
143
  this.input = document.createElement('textarea');
142
144
  this.input.style.position = 'absolute';
@@ -147,11 +149,11 @@ var Common = /** @class */ (function () {
147
149
  this.input.style.outline = 'none';
148
150
  this.input.style.border = '1px solid #cdcdcd';
149
151
  this.input.style.resize = 'none';
150
- this.parentElem.appendChild(this.input);
152
+ this.store.parentElem.appendChild(this.input);
151
153
  this.paginationPageListBox = document.createElement('ul');
152
154
  this.pagenationPageInput = document.createElement('input');
153
155
  this.tablePaginationPageStyle();
154
- this.parentElem.appendChild(this.paginationPageListBox);
156
+ this.store.parentElem.appendChild(this.paginationPageListBox);
155
157
  // 列表数据选取
156
158
  this.paginationPageListNode = function (ev) {
157
159
  const node = _this.moveIn.activeNode;
@@ -175,33 +177,27 @@ var Common = /** @class */ (function () {
175
177
  }
176
178
 
177
179
  Common.prototype.conversionData = function (obj) {
178
- this.parentElem.scrollLeft = 0;
179
- this.parentElem.scrollTop = 0;
180
- this.canvas.clearBkImg();
181
- this.divLayer.clear();
180
+ this.clear();
182
181
  let data = JSON.parse(JSON.stringify(obj));
183
182
  if (!data) {
184
183
  data = {pens: []};
185
184
  }
186
- Object.assign(this.data, data);
185
+ Object.assign(this.store.data, data);
186
+ this.store.data.pens = [];
187
187
  this.setBKImageRect();
188
- this.ratioCord = {
189
- ratio: 1,
190
- scaleX: 1,
191
- scaleY: 1
192
- };
193
188
  this.openCount = 0
194
- this.data.pens = [];
195
189
  // for old data.
196
190
  if (data.nodes) {
197
191
  for (var _i = 0, _a = data.nodes; _i < _a.length; _i++) {
198
192
  var item = new Node(_a[_i]);
199
- this.data.pens.push(item);
193
+ this.store.data.pens.push(item);
194
+ this.store.pens[item.id] = item;
200
195
  this.setSwitchTabData(item, _i);
201
196
  }
202
197
  for (var _b = 0, _c = data.lines; _b < _c.length; _b++) {
203
- var item = _c[_b];
204
- this.data.pens.push(new Line(item));
198
+ var item = new Line(_c[_b]);
199
+ this.store.data.pens.push(item);
200
+ this.store.pens[item.id] = item;
205
201
  }
206
202
  }
207
203
  // end.
@@ -210,23 +206,33 @@ var Common = /** @class */ (function () {
210
206
  var item = _e[_d];
211
207
  if (!item.from) {
212
208
  var node = new Node(item);
213
- this.data.pens.push(node);
209
+ this.store.data.pens.push(node);
210
+ this.store.pens[item.id] = node;
214
211
  this.setSwitchTabData(node, _d);
215
212
  } else {
216
- this.data.pens.push(new Line(item));
213
+ const linNode = new Line(item);
214
+ this.store.data.pens.push(linNode);
215
+ this.store.pens[item.id] = linNode;
217
216
  }
218
217
  }
219
218
  }
220
219
  };
220
+ Common.prototype.clear = function (del){
221
+ clearStore(this.store, del);
222
+ this.canvas.clearBkImg();
223
+ this.divLayer.clear();
224
+ this.store.parentElem.scrollLeft = 0;
225
+ this.store.parentElem.scrollTop = 0;
226
+ };
221
227
  Common.prototype.setBKImageRect = function () {
222
- if (this.data.bkImageRect) {
223
- this.data.bkImageRect.x = this.data.bkImageRect.x ? Number(this.data.bkImageRect.x) : 0;
224
- this.data.bkImageRect.y = this.data.bkImageRect.y ? Number(this.data.bkImageRect.y) : 0;
225
- this.data.bkImageRect.width = this.data.bkImageRect.width ? Number(this.data.bkImageRect.width) : this.canvas.width;
226
- this.data.bkImageRect.height = this.data.bkImageRect.height ? Number(this.data.bkImageRect.height) : this.canvas.height;
227
- this.data.bkImageRect.center = {
228
- x: this.data.bkImageRect.x + this.data.bkImageRect.width / 2,
229
- y: this.data.bkImageRect.y + this.data.bkImageRect.height / 2
228
+ if (this.store.data.bkImageRect) {
229
+ this.store.data.bkImageRect.x = this.store.data.bkImageRect.x ? Number(this.store.data.bkImageRect.x) : 0;
230
+ this.store.data.bkImageRect.y = this.store.data.bkImageRect.y ? Number(this.store.data.bkImageRect.y) : 0;
231
+ this.store.data.bkImageRect.width = this.store.data.bkImageRect.width ? Number(this.store.data.bkImageRect.width) : this.canvas.width;
232
+ this.store.data.bkImageRect.height = this.store.data.bkImageRect.height ? Number(this.store.data.bkImageRect.height) : this.canvas.height;
233
+ this.store.data.bkImageRect.center = {
234
+ x: this.store.data.bkImageRect.x + this.store.data.bkImageRect.width / 2,
235
+ y: this.store.data.bkImageRect.y + this.store.data.bkImageRect.height / 2
230
236
  }
231
237
  }
232
238
  };
@@ -262,20 +268,40 @@ var Common = /** @class */ (function () {
262
268
  }
263
269
  };
264
270
  Common.prototype.canvasResize = function (size) {
265
- this.canvas.resize(size);
266
- //this.canvas.bkImgRectResize(size);
267
- this.offscreen.resize(size);
268
- this.divLayer.resize(size);
271
+ try {
272
+ this.canvas.resize(size);
273
+ //this.canvas.bkImgRectResize(size);
274
+ this.offscreen.resize(size);
275
+ this.divLayer.resize(size);
276
+ }catch (err) {
277
+ //console.log('resize-----', err)
278
+ }
269
279
  };
270
280
  // Render or redraw
271
281
  Common.prototype.render = function (noFocus) {
272
- if (this.rendering) {
273
- return this;
282
+ try {
283
+ const _this = this;
284
+ const now = performance.now();
285
+ if (now - _this.lastRender < _this.store.options.interval && !noFocus) {
286
+ if (_this.renderTimer) {
287
+ cancelAnimationFrame(_this.renderTimer);
288
+ }
289
+ _this.renderTimer = requestAnimationFrame(_this.render);
290
+
291
+ return;
292
+ }
293
+ this.renderTimer = 0;
294
+ this.lastRender = now;
295
+ if (this.rendering) {
296
+ return this;
297
+ }
298
+ this.rendering = true;
299
+ this.offscreen.render();
300
+ this.canvas.render();
301
+ this.rendering = false;
302
+ }catch (e) {
303
+ //console.log(e)
274
304
  }
275
- this.rendering = true;
276
- this.offscreen.render();
277
- this.canvas.render();
278
- this.rendering = false;
279
305
  };
280
306
  Common.prototype.generateStoreKey = function (key) {
281
307
  return this.id + "-" + key;
@@ -358,7 +384,7 @@ var Common = /** @class */ (function () {
358
384
  this.pagenationPageInput.style.left = node.paginationData.targetPageLocal.x + 'px';
359
385
  this.pagenationPageInput.style.top = node.paginationData.targetPageLocal.y + 'px';
360
386
  this.pagenationPageInput.style.height = node.rect.height + 'px';
361
- this.parentElem.appendChild(this.pagenationPageInput);
387
+ this.store.parentElem.appendChild(this.pagenationPageInput);
362
388
  };
363
389
  // 展开分页列表
364
390
  Common.prototype.spreadPageListHandle = function (node, e) {
@@ -426,8 +452,8 @@ var Common = /** @class */ (function () {
426
452
  // 如果存在按钮组节点数据
427
453
  if (changeNode[node.id]) {
428
454
  for (let switchNode of Object.values(changeNode)) {
429
- if (this.data.pens[switchNode.tagOrder]) {
430
- this.data.pens[switchNode.tagOrder].activeImgeIndex = switchNode.id !== node.id;
455
+ if (this.store.data.pens[switchNode.tagOrder]) {
456
+ this.store.data.pens[switchNode.tagOrder].activeImgeIndex = switchNode.id !== node.id;
431
457
  }
432
458
  }
433
459
  }
@@ -446,23 +472,23 @@ var Common = /** @class */ (function () {
446
472
  Common.prototype.s8 = function () {
447
473
  return s8()
448
474
  };
449
- Common.prototype.openSocket = function (url) {
450
- this.closeSocket();
451
- if (url || this.data.websocket) {
452
- this.socket = new Socket(url || this.data.websocket, this.data);
453
- }
454
- };
455
- Common.prototype.closeSocket = function () {
456
- if (this.socket) {
457
- this.socket.close();
458
- }
459
- };
475
+ // Common.prototype.openSocket = function (url) {
476
+ // this.closeSocket();
477
+ // if (url || this.store.data.websocket) {
478
+ // this.socket = new Socket(url || this.store.data.websocket, this.store.data);
479
+ // }
480
+ // };
481
+ // Common.prototype.closeSocket = function () {
482
+ // if (this.socket) {
483
+ // this.socket.close();
484
+ // }
485
+ // };
460
486
  Common.prototype.openMqtt = function (url, options) {
461
487
  this.closeMqtt();
462
- if (url || this.data.mqttUrl) {
463
- url = url || this.data.mqttUrl;
464
- const mqttTopics = this.initData && this.initData.mqttTopics ? this.initData.mqttTopics : this.data.mqttTopics;
465
- options = options || this.data.mqttOptions
488
+ if (url || this.store.data.mqttUrl) {
489
+ url = url || this.store.data.mqttUrl;
490
+ const mqttTopics = this.initData && this.initData.mqttTopics ? this.initData.mqttTopics : this.store.data.mqttTopics;
491
+ options = options || this.store.data.mqttOptions
466
492
  let topics = mqttTopics
467
493
  this.isEnd = false;
468
494
  // let num = 0; // 记录推送的次数,用于判单丢失情况
@@ -470,7 +496,7 @@ var Common = /** @class */ (function () {
470
496
  var _this = this;
471
497
  this.mqttClient.on('message', function (topic, message) {
472
498
  //console.log('openMqtt11===================', topic, message)
473
- if (!_this.data.pens.length || !topic || topic != _this.data.mqttTopics) {
499
+ if (!_this.store.data.pens.length || !topic || topic != _this.store.data.mqttTopics) {
474
500
  return;
475
501
  }
476
502
  if (!this.isEnd) {
@@ -484,7 +510,7 @@ var Common = /** @class */ (function () {
484
510
  };
485
511
  Common.prototype.openPoll = function (message, val) {
486
512
  if (message) {
487
- this.poll = new POLL(this.data, message, val);
513
+ this.poll = new POLL(this.store.data, message, val);
488
514
  }
489
515
  };
490
516
  Common.prototype.clearInterValAll = function () {
@@ -512,10 +538,10 @@ var Common = /** @class */ (function () {
512
538
  this.inputObj = null;
513
539
  };
514
540
  Common.prototype.showInput = function (item) {
515
- if (this.data.locked ||
541
+ if (this.store.data.locked ||
516
542
  item.locked ||
517
543
  item.hideInput ||
518
- this.options.hideInput) {
544
+ this.store.options.hideInput) {
519
545
  return;
520
546
  }
521
547
  this.inputObj = item;
@@ -534,9 +560,9 @@ var Common = /** @class */ (function () {
534
560
  this.input.focus();
535
561
  };
536
562
  Common.prototype.getRect = function (pens) {
537
- if (!this.data) return;
563
+ if (!this.store || !this.store.data) return;
538
564
  if (!pens) {
539
- pens = this.data.pens;
565
+ pens = this.store.data.pens;
540
566
  }
541
567
  return getRect(pens);
542
568
  };
@@ -554,7 +580,7 @@ var Common = /** @class */ (function () {
554
580
  }
555
581
  var offsetX = x - this.lastTranlated.x;
556
582
  var offsetY = y - this.lastTranlated.y;
557
- for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
583
+ for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
558
584
  var item = _a[_i];
559
585
  item.translate(offsetX, offsetY);
560
586
  }
@@ -573,7 +599,7 @@ var Common = /** @class */ (function () {
573
599
  var viewCenter = this.getViewCenter(padding);
574
600
  var center = rect.center;
575
601
  this.translate(viewCenter.x - center.x, viewCenter.y - center.y);
576
- var parentElem = this.canvas.parentElem;
602
+ var parentElem = this.store.parentElem;
577
603
  var x = (parentElem.scrollWidth - parentElem.offsetWidth) / 2;
578
604
  var y = (parentElem.scrollHeight - parentElem.offsetHeight) / 2;
579
605
  parentElem.scrollTo(x, y);
@@ -584,7 +610,7 @@ var Common = /** @class */ (function () {
584
610
  return !(rect.width === 99999 || rect.height === 99999);
585
611
  };
586
612
  Common.prototype.getViewCenter = function (viewPadding) {
587
- var padding = formatPadding(viewPadding || this.options.viewPadding);
613
+ var padding = formatPadding(viewPadding || this.store.options.viewPadding);
588
614
  var _a = this.canvas, width = _a.width, height = _a.height;
589
615
  return {
590
616
  x: (width - padding[1] - padding[3]) / 2 + padding[3],
@@ -648,7 +674,7 @@ var Common = /** @class */ (function () {
648
674
  }
649
675
  var tipMarkdownMarginLeft = count * 3 + 11
650
676
 
651
- var parentRect = this.parentElem.getBoundingClientRect();
677
+ var parentRect = this.store.parentElem.getBoundingClientRect();
652
678
  var elemRect = elem.getBoundingClientRect();
653
679
  var x = parentRect.left + dataRect.x;
654
680
  var y = pos.y + parentRect.top;
@@ -656,8 +682,8 @@ var Common = /** @class */ (function () {
656
682
  x = x + dataRect.width / 2 - tipMarkdownMarginLeft
657
683
  y = parentRect.top + dataRect.ey - dataRect.height - 46
658
684
  }
659
- x -= this.parentElem.scrollLeft;
660
- y -= this.parentElem.scrollTop;
685
+ x -= this.store.parentElem.scrollLeft;
686
+ y -= this.store.parentElem.scrollTop;
661
687
  if (x < 0) {
662
688
  x = 0;
663
689
  }
@@ -689,10 +715,11 @@ var Common = /** @class */ (function () {
689
715
  this.tip = '';
690
716
  };
691
717
  Common.prototype.dispatch = function (event, data) {
692
- if (this.options.on) {
693
- this.options.on(event, data);
718
+ if(!this.store || !this.store.options) return;
719
+ if (this.store.options.on) {
720
+ this.store.options.on(event, data);
694
721
  }
695
- if (event === 'node' && data.name == 'tablePagination' && this.options.type !== 'topology') {
722
+ if (event === 'node' && data.name == 'tablePagination' && this.store.options.type !== 'topology') {
696
723
  const tableNodes = Store.get('FORM:tableData').data.tableNodes[data.paginationData.bindFromTableId];
697
724
  const pageSize = data.paginationData.pageSize;
698
725
  const offset = (parseInt(data.paginationData.pageNumber) - 1) * pageSize;
@@ -718,7 +745,7 @@ var Common = /** @class */ (function () {
718
745
  }
719
746
  this.initType = type
720
747
  this.initData = data
721
- const canvasData = data ? data : this.data
748
+ const canvasData = data ? data : this.store.data
722
749
  //this.topologyDetailData = initData
723
750
  const url = canvasData.mqttUrl
724
751
  // if(url && url.indexOf('://') > -1){
@@ -758,7 +785,7 @@ var Common = /** @class */ (function () {
758
785
  };
759
786
  Common.prototype.initTagParams = async function (eventType) {
760
787
  this.clearTagParams(eventType)
761
- const pensData = this.data.pens
788
+ const pensData = this.store.data.pens
762
789
  let tagParams = this.getTagParams(pensData, eventType);
763
790
  // 详情页面,即URL配置了资产id的页面
764
791
  let assetId = this.getUrlParams('assetId')
@@ -772,7 +799,7 @@ var Common = /** @class */ (function () {
772
799
  if (this.assetPoperties) {
773
800
  // 更新画布上固定的资产详情对应的值
774
801
  //const canvasPens = this.pathRewrite ? canvasData.pens : this.canvas.data.pens
775
- this.renderForAssetPoperties(this.canvas.data.pens);
802
+ this.renderForAssetPoperties(pensData);
776
803
  }
777
804
  }
778
805
  };
@@ -846,18 +873,18 @@ var Common = /** @class */ (function () {
846
873
  }
847
874
  };
848
875
  Common.prototype.getMqttData = async function (tagParams, panelData) {
849
- let ret = {};
876
+ let ret = null;
850
877
  let data = {};
851
878
  let path = '';
852
879
  let assetData = null;
853
880
  let pathRewrite = this.pathRewrite;
854
- let canvasData = JSON.parse(JSON.stringify(this.canvas.data));
855
- let mqttTopics = this.data.mqttTopics;
881
+ let canvasData = JSON.parse(JSON.stringify(this.store.data));
882
+ let mqttTopics = this.store.data.mqttTopics;
856
883
  let tagParamsData = tagParams;
857
884
  let detailJson = null;
858
885
  Store.set('TIMEOUT:currentPage', `locationPath${this.s8()}`);
859
886
  if (panelData) {
860
- this.data.mqttTopics = mqttTopics
887
+ this.store.data.mqttTopics = mqttTopics
861
888
  pathRewrite = panelData.pathRewrite;
862
889
  canvasData = JSON.parse(JSON.stringify(panelData.data));
863
890
  mqttTopics = panelData.mqttTopics;
@@ -893,7 +920,14 @@ var Common = /** @class */ (function () {
893
920
  this.theData = data
894
921
  }
895
922
  let drawedData = null
896
- ret = await axios.post(path, data);
923
+ data.cancelToken = this.mqttDataSouse.token;
924
+ ret = await axios.post(path, data).catch(function(th) {
925
+ if(axios.isCancel(th)) {
926
+ console.log('请求取消了----', th.message);
927
+ } else {
928
+ console.log('请求失败----')
929
+ }
930
+ });
897
931
  if (ret.data && ret.data.data) {
898
932
  if (assetData) ret.data.data.asset = assetData
899
933
  drawedData = this.mqttDataDrawing(canvasData, ret.data.data, detailJson)
@@ -920,7 +954,7 @@ var Common = /** @class */ (function () {
920
954
  // console.log('收到消息', syncData)
921
955
  Store.set('mqtt:responseData', syncData);
922
956
  data.pens.map((item) => {
923
- if (item.children != undefined) {
957
+ if (item.children && item.children.length) {
924
958
  item.children.map((_item) => {
925
959
  item.defaultFillStyle = item.fillStyle;
926
960
  item.defaultFontColor = item.font.color;
@@ -1069,11 +1103,11 @@ var Common = /** @class */ (function () {
1069
1103
  }
1070
1104
  };
1071
1105
  Common.prototype.onMqttContent = async function (tagParams) {
1072
- if (!this.initType) this.data.mqttTopics = 'mqtt-' + s8();
1106
+ if (!this.initType) this.store.data.mqttTopics = 'mqtt-' + s8();
1073
1107
  // 告知MQTT属性中数据的集合
1074
1108
  const ret = !this.initType ? await this.getMqttData(tagParams) : this.initType;
1075
1109
  if (ret) {
1076
- let mqttUrlStr = this.data.mqttUrl, mqttOption = this.data.mqttOptions
1110
+ let mqttUrlStr = this.store.data.mqttUrl, mqttOption = this.store.data.mqttOptions
1077
1111
  if (this.initData) {
1078
1112
  const {mqttUrl, mqttOptions} = this.initData
1079
1113
  mqttUrlStr = mqttUrl
@@ -1089,8 +1123,8 @@ var Common = /** @class */ (function () {
1089
1123
  const index = eventType[4] ? eventType[4] : ''
1090
1124
  // const url = 'pollUrl'+index;
1091
1125
  // const second = 'pollSecond'+index;
1092
- const pollUrl = this.data['pollUrl' + index]
1093
- const pollSecond = this.data['pollSecond' + index]
1126
+ const pollUrl = this.store.data['pollUrl' + index]
1127
+ const pollSecond = this.store.data['pollSecond' + index]
1094
1128
  this.onpollStop(eventType);
1095
1129
  if (pollUrl && pollSecond) {
1096
1130
  this.renderForPoll(tagParams, pollUrl, eventType);
@@ -1137,7 +1171,7 @@ var Common = /** @class */ (function () {
1137
1171
  this.getMqttData(this.tagParams.Mqtt);
1138
1172
  };
1139
1173
  Common.prototype.doMqttDrow = function (ret) {
1140
- let canvasData = this.canvas.data;
1174
+ let canvasData = this.store.data;
1141
1175
  ret = JSON.parse(ret);
1142
1176
  // console.log('处理消息')
1143
1177
  // console.log('this.canvas.data',this.canvas.data)
@@ -1155,11 +1189,11 @@ var Common = /** @class */ (function () {
1155
1189
  Common.prototype.hidePenVal = function (pen, val) {
1156
1190
  const tags = pen.tags
1157
1191
  const obj = val ? JSON.parse(val) : {}
1158
- const visibleRange = obj.visibleRange
1159
- const visibleFnRange = obj.visibleFnRange
1160
- const visibleValue = obj.visibleValue
1161
- const hiddenRange = obj.hiddenRange
1162
- const tabsValue = obj.tabsValue
1192
+ const visibleRange = obj.visibleRange ? obj.visibleRange.trim() : ''
1193
+ const visibleFnRange = obj.visibleFnRange ? obj.visibleFnRange.trim() : ''
1194
+ const visibleValue = obj.visibleValue ? obj.visibleValue.trim() : ''
1195
+ const hiddenRange = obj.hiddenRange ? obj.hiddenRange.trim() : ''
1196
+ const tabsValue = obj.tabsValue ? obj.tabsValue.trim() : ''
1163
1197
  if (tags.length > 0) {
1164
1198
  if (visibleRange == '1') {
1165
1199
  if (this.openCount % 2 == 0) {
@@ -1200,10 +1234,13 @@ var Common = /** @class */ (function () {
1200
1234
  this.render();
1201
1235
  };
1202
1236
  Common.prototype.destroyStatic = function () {
1237
+ this.mqttDataSouse.cancel();
1238
+ this.clear('destroy');
1203
1239
  this.clearInterValAll();
1204
- this.closeSocket();
1240
+ //this.closeSocket();
1205
1241
  this.closeMqtt();
1206
1242
  this.closePoll();
1243
+ cancelAnimationFrame(this.renderTimer);
1207
1244
  this.subcribe.unsubscribe();
1208
1245
  this.subcribeRender.unsubscribe();
1209
1246
  this.subcribeImage.unsubscribe();
@@ -1217,7 +1254,7 @@ var Common = /** @class */ (function () {
1217
1254
  this.canvas = null;
1218
1255
  this.offscreen.destroy();
1219
1256
  this.offscreen = null;
1220
- this.data = null;
1257
+ this.store.parentElem = null;
1221
1258
  Store.set('form:tableData', null);
1222
1259
  Store.set('TIMEOUT:currentPage', `empty${this.s8()}`);
1223
1260
  Store.set('FORM:tableData', {
@@ -1,19 +1,18 @@
1
1
  // @ts-ignore
2
2
  import { EventType, Handler } from 'mitt';
3
3
  import {Options, Padding} from './options';
4
- import { Pen, Node, Point, Line, TopologyData } from './models';
4
+ import { Pen, Node, Point, Line } from './models';
5
5
  import { HoverLayer } from './hoverLayer';
6
6
  import { ActiveLayer } from './activeLayer';
7
- import { DivLayer } from './divLayer';
8
7
  import { Rect } from './models';
9
8
  import {Common} from './common';
10
9
  interface ICaches {
11
10
  index: number;
12
- list: TopologyData[];
11
+ list: [];
13
12
  }
14
13
  export declare class Topology extends Common{
15
14
  constructor(parent: string | HTMLElement, options?: Options);
16
- clipboard: TopologyData;
15
+ clipboard: {};
17
16
  caches: ICaches;
18
17
  private subcribeAnimateMoved;
19
18
  private subcribeMediaEnd;