@meta2d/core 1.0.64 → 1.0.66
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/package.json +1 -1
- package/src/canvas/canvas.d.ts +2 -0
- package/src/canvas/canvas.js +71 -18
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.js +7 -0
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/core.d.ts +11 -2
- package/src/core.js +294 -211
- package/src/core.js.map +1 -1
- package/src/diagrams/video.js +1 -0
- package/src/diagrams/video.js.map +1 -1
- package/src/dialog/dialog.d.ts +9 -3
- package/src/dialog/dialog.js +79 -6
- package/src/dialog/dialog.js.map +1 -1
- package/src/options.js +2 -1
- package/src/options.js.map +1 -1
- package/src/pen/model.d.ts +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/render.js +44 -21
- package/src/pen/render.js.map +1 -1
- package/src/store/store.d.ts +2 -0
- package/src/store/store.js.map +1 -1
- package/src/utils/url.d.ts +3 -0
- package/src/utils/url.js +63 -0
- package/src/utils/url.js.map +1 -1
package/src/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { commonAnchors, commonPens, cube } from './diagrams';
|
|
2
2
|
import { Canvas } from './canvas';
|
|
3
|
-
import { calcInView, calcTextDrawRect, calcTextLines, calcTextRect, facePen, formatAttrs, getAllChildren, getFromAnchor, getParent, getToAnchor, getWords, LockState, PenType, renderPenRaw, setElemPosition, connectLine, nearestAnchor, setChildValue, isAncestor, isShowChild, CanvasLayer, validationPlugin, setLifeCycleFunc, getAllFollowers, isInteraction, calcWorldAnchors } from './pen';
|
|
3
|
+
import { calcInView, calcTextDrawRect, calcTextLines, calcTextRect, facePen, formatAttrs, getAllChildren, getFromAnchor, getParent, getToAnchor, getWords, LockState, PenType, renderPenRaw, setElemPosition, connectLine, nearestAnchor, setChildValue, isAncestor, isShowChild, CanvasLayer, validationPlugin, setLifeCycleFunc, getAllFollowers, isInteraction, calcWorldAnchors, getGlobalColor, isDomShapes, } from './pen';
|
|
4
4
|
import { rotatePoint } from './point';
|
|
5
5
|
import { clearStore, EditType, globalStore, register, registerAnchors, registerCanvasDraw, useStore, } from './store';
|
|
6
6
|
import { formatPadding, loadCss, s8, valueInArray, valueInRange, } from './utils';
|
|
@@ -13,7 +13,7 @@ import pkg from '../package.json';
|
|
|
13
13
|
import { lockedError } from './utils/error';
|
|
14
14
|
import { Scroll } from './scroll';
|
|
15
15
|
import { getter } from './utils/object';
|
|
16
|
-
import { queryURLParams } from './utils/url';
|
|
16
|
+
import { getCookie, getMeta2dData, queryURLParams } from './utils/url';
|
|
17
17
|
import { HotkeyType } from './data';
|
|
18
18
|
import { Message, messageList } from './message';
|
|
19
19
|
export class Meta2d {
|
|
@@ -92,7 +92,9 @@ export class Meta2d {
|
|
|
92
92
|
// });
|
|
93
93
|
this.canvas && (this.canvas.canvasTemplate.bgPatchFlags = true);
|
|
94
94
|
}
|
|
95
|
-
if (opts.rule !== undefined ||
|
|
95
|
+
if (opts.rule !== undefined ||
|
|
96
|
+
opts.ruleColor !== undefined ||
|
|
97
|
+
opts.ruleOptions !== undefined) {
|
|
96
98
|
// this.setRule({
|
|
97
99
|
// rule: opts.rule,
|
|
98
100
|
// ruleColor: opts.ruleColor,
|
|
@@ -115,7 +117,8 @@ export class Meta2d {
|
|
|
115
117
|
}
|
|
116
118
|
if (opts.width !== undefined || opts.height !== undefined) {
|
|
117
119
|
this.canvas && (this.canvas.canvasTemplate.bgPatchFlags = true);
|
|
118
|
-
if (this.canvas &&
|
|
120
|
+
if (this.canvas &&
|
|
121
|
+
this.canvas.canvasTemplate.canvas.style.backgroundImage) {
|
|
119
122
|
this.canvas.canvasTemplate.canvas.style.backgroundImage = '';
|
|
120
123
|
}
|
|
121
124
|
}
|
|
@@ -136,11 +139,12 @@ export class Meta2d {
|
|
|
136
139
|
setTheme(theme) {
|
|
137
140
|
this.store.data.theme = theme;
|
|
138
141
|
this.setBackgroundColor(this.store.theme[theme].background);
|
|
139
|
-
this.canvas.parentElement.style.background =
|
|
142
|
+
this.canvas.parentElement.style.background =
|
|
143
|
+
this.store.theme[theme].parentBackground;
|
|
140
144
|
this.store.data.color = this.store.theme[theme].color;
|
|
141
145
|
this.setOptions({
|
|
142
146
|
ruleColor: this.store.theme[theme].ruleColor,
|
|
143
|
-
ruleOptions: this.store.theme[theme].ruleOptions
|
|
147
|
+
ruleOptions: this.store.theme[theme].ruleOptions,
|
|
144
148
|
});
|
|
145
149
|
this.render();
|
|
146
150
|
}
|
|
@@ -160,7 +164,7 @@ export class Meta2d {
|
|
|
160
164
|
fromArrow,
|
|
161
165
|
toArrow,
|
|
162
166
|
x,
|
|
163
|
-
y
|
|
167
|
+
y,
|
|
164
168
|
});
|
|
165
169
|
}
|
|
166
170
|
init(parent) {
|
|
@@ -204,7 +208,9 @@ export class Meta2d {
|
|
|
204
208
|
if (e.value) {
|
|
205
209
|
_pen = this.findOne(e.value);
|
|
206
210
|
}
|
|
207
|
-
if (this.store.animates.has(_pen) &&
|
|
211
|
+
if (this.store.animates.has(_pen) &&
|
|
212
|
+
!_pen.calculative.pause &&
|
|
213
|
+
_pen.animateName === e.params) {
|
|
208
214
|
return;
|
|
209
215
|
}
|
|
210
216
|
if (e.targetType && e.params) {
|
|
@@ -343,8 +349,7 @@ export class Meta2d {
|
|
|
343
349
|
}
|
|
344
350
|
};
|
|
345
351
|
this.events[EventAction.Dialog] = (pen, e) => {
|
|
346
|
-
if (e.params &&
|
|
347
|
-
typeof e.params === 'string') {
|
|
352
|
+
if (e.params && typeof e.params === 'string') {
|
|
348
353
|
let url = e.params;
|
|
349
354
|
if (e.params.includes('${')) {
|
|
350
355
|
let keys = e.params.match(/(?<=\$\{).*?(?=\})/g);
|
|
@@ -354,20 +359,21 @@ export class Meta2d {
|
|
|
354
359
|
});
|
|
355
360
|
}
|
|
356
361
|
}
|
|
357
|
-
this.
|
|
362
|
+
const data = this.getEventData(e.list, pen);
|
|
363
|
+
this.canvas.dialog.show(e.value, url, e.extend, data);
|
|
358
364
|
}
|
|
359
365
|
};
|
|
360
366
|
this.events[EventAction.SendData] = (pen, e) => {
|
|
361
367
|
if (e.list?.length) {
|
|
362
368
|
// if (e.targetType === 'id') {
|
|
363
|
-
if (e.network && e.network.protocol ===
|
|
369
|
+
if (e.network && e.network.protocol === 'jetLinks') {
|
|
364
370
|
const list = [];
|
|
365
371
|
e.list.forEach((item, index) => {
|
|
366
372
|
const _pen = item.params ? this.findOne(item.params) : pen;
|
|
367
373
|
list[index] = {
|
|
368
374
|
deviceId: _pen.deviceId,
|
|
369
375
|
productId: _pen.productId,
|
|
370
|
-
properties: {}
|
|
376
|
+
properties: {},
|
|
371
377
|
};
|
|
372
378
|
for (let key in item.value) {
|
|
373
379
|
if (item.value[key] === undefined || item.value[key] === '') {
|
|
@@ -377,10 +383,12 @@ export class Meta2d {
|
|
|
377
383
|
list[index].properties[key] = _pen[realTime.key];
|
|
378
384
|
}
|
|
379
385
|
}
|
|
380
|
-
else if (typeof item.value[key] === 'string' &&
|
|
386
|
+
else if (typeof item.value[key] === 'string' &&
|
|
387
|
+
item.value[key]?.indexOf('${') > -1) {
|
|
381
388
|
let keys = item.value[key].match(/(?<=\$\{).*?(?=\})/g);
|
|
382
389
|
if (keys?.length) {
|
|
383
|
-
list[index].properties[key] =
|
|
390
|
+
list[index].properties[key] =
|
|
391
|
+
_pen[keys[0]] ?? this.getDynamicParam(keys[0]);
|
|
384
392
|
}
|
|
385
393
|
}
|
|
386
394
|
else {
|
|
@@ -391,39 +399,22 @@ export class Meta2d {
|
|
|
391
399
|
if (this.jetLinksClient && list.length) {
|
|
392
400
|
list.forEach((item) => {
|
|
393
401
|
this.jetLinksClient.send(JSON.stringify({
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
+
type: 'sub',
|
|
403
|
+
topic: `/device-message-sender/${item.productId}/${item.deviceId}`,
|
|
404
|
+
parameter: {
|
|
405
|
+
messageType: 'WRITE_PROPERTY',
|
|
406
|
+
properties: item.properties,
|
|
407
|
+
headers: {
|
|
408
|
+
async: false,
|
|
409
|
+
},
|
|
402
410
|
},
|
|
403
|
-
|
|
411
|
+
id: item.productId + '/' + item.deviceId + '-' + s8(),
|
|
404
412
|
}));
|
|
405
413
|
});
|
|
406
414
|
}
|
|
407
415
|
return;
|
|
408
416
|
}
|
|
409
|
-
const value =
|
|
410
|
-
e.list.forEach((item) => {
|
|
411
|
-
const _pen = item.params ? this.findOne(item.params) : pen;
|
|
412
|
-
for (let key in item.value) {
|
|
413
|
-
if (item.value[key] === undefined || item.value[key] === '') {
|
|
414
|
-
value[key] = _pen[key];
|
|
415
|
-
}
|
|
416
|
-
else if (typeof item.value[key] === 'string' && item.value[key]?.indexOf('${') > -1) {
|
|
417
|
-
let keys = item.value[key].match(/(?<=\$\{).*?(?=\})/g);
|
|
418
|
-
if (keys?.length) {
|
|
419
|
-
value[key] = _pen[keys[0]] ?? this.getDynamicParam(keys[0]);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
value[key] = item.value[key];
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
});
|
|
417
|
+
const value = this.getEventData(e.list, pen);
|
|
427
418
|
if (pen.deviceId) {
|
|
428
419
|
value.deviceId = pen.deviceId;
|
|
429
420
|
}
|
|
@@ -439,7 +430,8 @@ export class Meta2d {
|
|
|
439
430
|
if (value[key] === undefined || value[key] === '') {
|
|
440
431
|
value[key] = _pen[key];
|
|
441
432
|
}
|
|
442
|
-
else if (typeof value[key] === 'string' &&
|
|
433
|
+
else if (typeof value[key] === 'string' &&
|
|
434
|
+
value[key]?.indexOf('${') > -1) {
|
|
443
435
|
let keys = value[key].match(/(?<=\$\{).*?(?=\})/g);
|
|
444
436
|
if (keys?.length) {
|
|
445
437
|
value[key] = _pen[keys[0]] ?? this.getDynamicParam(keys[0]);
|
|
@@ -466,30 +458,11 @@ export class Meta2d {
|
|
|
466
458
|
return;
|
|
467
459
|
}
|
|
468
460
|
let params = queryURLParams(_pen.iframe.split('?')[1]);
|
|
469
|
-
const value =
|
|
470
|
-
if (e.list?.length) {
|
|
471
|
-
e.list.forEach((item) => {
|
|
472
|
-
const _pen = item.params ? this.findOne(item.params) : pen;
|
|
473
|
-
for (let key in item.value) {
|
|
474
|
-
if (item.value[key] === undefined || item.value[key] === '') {
|
|
475
|
-
value[key] = _pen[key];
|
|
476
|
-
}
|
|
477
|
-
else if (typeof item.value[key] === 'string' && item.value[key]?.indexOf('${') > -1) {
|
|
478
|
-
let keys = item.value[key].match(/(?<=\$\{).*?(?=\})/g);
|
|
479
|
-
if (keys?.length) {
|
|
480
|
-
value[key] = _pen[keys[0]];
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
value[key] = item.value[key];
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
}
|
|
461
|
+
const value = this.getEventData(e.list, _pen);
|
|
489
462
|
_pen.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({
|
|
490
463
|
name: e.value,
|
|
491
464
|
id: params.id,
|
|
492
|
-
value
|
|
465
|
+
data: value,
|
|
493
466
|
}), '*');
|
|
494
467
|
return;
|
|
495
468
|
};
|
|
@@ -498,37 +471,46 @@ export class Meta2d {
|
|
|
498
471
|
console.warn('[meta2d] Emit value must be a string');
|
|
499
472
|
return;
|
|
500
473
|
}
|
|
501
|
-
const value =
|
|
502
|
-
|
|
503
|
-
e.list.forEach((item) => {
|
|
504
|
-
const _pen = item.params ? this.findOne(item.params) : pen;
|
|
505
|
-
for (let key in item.value) {
|
|
506
|
-
if (item.value[key] === undefined || item.value[key] === '') {
|
|
507
|
-
value[key] = _pen[key];
|
|
508
|
-
}
|
|
509
|
-
else if (typeof item.value[key] === 'string' && item.value[key]?.indexOf('${') > -1) {
|
|
510
|
-
let keys = item.value[key].match(/(?<=\$\{).*?(?=\})/g);
|
|
511
|
-
if (keys?.length) {
|
|
512
|
-
value[key] = _pen[keys[0]];
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
value[key] = item.value[key];
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
window.parent.postMessage(JSON.stringify({ name: e.value, value }), '*');
|
|
474
|
+
const value = this.getEventData(e.list, pen);
|
|
475
|
+
window.parent.postMessage(JSON.stringify({ name: e.value, data: value }), '*');
|
|
522
476
|
return;
|
|
523
477
|
};
|
|
524
478
|
this.events[EventAction.Message] = (pen, e) => {
|
|
525
479
|
this.message({
|
|
526
480
|
theme: e.params,
|
|
527
481
|
content: e.value,
|
|
528
|
-
...e.extend
|
|
482
|
+
...e.extend,
|
|
529
483
|
});
|
|
530
484
|
};
|
|
531
485
|
}
|
|
486
|
+
getEventData(list, pen) {
|
|
487
|
+
const value = {};
|
|
488
|
+
if (list?.length) {
|
|
489
|
+
list.forEach((item) => {
|
|
490
|
+
const _pen = item.params ? this.findOne(item.params) : pen;
|
|
491
|
+
for (let key in item.value) {
|
|
492
|
+
if (item.value[key] === undefined || item.value[key] === '') {
|
|
493
|
+
value[key] = _pen[key];
|
|
494
|
+
}
|
|
495
|
+
else if (typeof item.value[key] === 'string' &&
|
|
496
|
+
item.value[key]?.indexOf('${') > -1) {
|
|
497
|
+
let keys = item.value[key].match(/(?<=\$\{).*?(?=\})/g);
|
|
498
|
+
if (keys?.length) {
|
|
499
|
+
value[key] = _pen[keys[0]] ?? this.getDynamicParam(keys[0]);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
value[key] = item.value[key];
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
if (Object.keys(value).length) {
|
|
509
|
+
return value;
|
|
510
|
+
}
|
|
511
|
+
else
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
532
514
|
message(options) {
|
|
533
515
|
const message = new Message(this.canvas.parentElement, options);
|
|
534
516
|
message.init();
|
|
@@ -553,35 +535,17 @@ export class Meta2d {
|
|
|
553
535
|
// }
|
|
554
536
|
// }
|
|
555
537
|
//路径参数更新
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
538
|
+
let hasId = queryURLParams()?.id;
|
|
539
|
+
if (hasId) {
|
|
540
|
+
const url = new URL(window.location);
|
|
541
|
+
url.searchParams.set('id', id);
|
|
542
|
+
history.pushState({}, '', url);
|
|
543
|
+
}
|
|
559
544
|
//图纸更新
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
const res = await fetch((netWork?.url || `/api/data/${collection}/get`) + (netWork?.method === 'GET' ? `?id=${id}` : ''), {
|
|
563
|
-
headers: {
|
|
564
|
-
Authorization: `Bearer ${this.getCookie('token') || localStorage.getItem('token') || new URLSearchParams(location.search).get('token') || ''}`,
|
|
565
|
-
},
|
|
566
|
-
method: netWork?.method || 'POST',
|
|
567
|
-
body: netWork?.method === 'GET' ? undefined : JSON.stringify({ id: id }),
|
|
568
|
-
});
|
|
569
|
-
if (res.ok) {
|
|
570
|
-
let data = await res.text();
|
|
571
|
-
if (data.constructor === Object || data.constructor === Array) {
|
|
572
|
-
data = JSON.parse(JSON.stringify(data));
|
|
573
|
-
}
|
|
574
|
-
else if (typeof data === 'string') {
|
|
575
|
-
data = JSON.parse(data);
|
|
576
|
-
}
|
|
577
|
-
if (data.data) {
|
|
578
|
-
data = data.data;
|
|
579
|
-
}
|
|
545
|
+
const data = await getMeta2dData(this.store, id);
|
|
546
|
+
if (data) {
|
|
580
547
|
this.open(data);
|
|
581
548
|
}
|
|
582
|
-
else {
|
|
583
|
-
this.store.emitter.emit('error', { type: 'http', error: res });
|
|
584
|
-
}
|
|
585
549
|
}
|
|
586
550
|
doSendDataEvent(value, topics) {
|
|
587
551
|
let data = JSON.stringify(value);
|
|
@@ -671,11 +635,11 @@ export class Meta2d {
|
|
|
671
635
|
}
|
|
672
636
|
}
|
|
673
637
|
else if (network.protocol === 'mqtt') {
|
|
674
|
-
const clients = this.mqttClients
|
|
638
|
+
const clients = this.mqttClients?.filter((client) => client.options.href === network.url);
|
|
675
639
|
if (clients && clients.length) {
|
|
676
640
|
if (clients[0].connected) {
|
|
677
641
|
network.topics.split(',').forEach((topic) => {
|
|
678
|
-
clients[0].publish(topic, value);
|
|
642
|
+
clients[0].publish(topic, JSON.stringify(value));
|
|
679
643
|
});
|
|
680
644
|
}
|
|
681
645
|
}
|
|
@@ -685,17 +649,19 @@ export class Meta2d {
|
|
|
685
649
|
mqttClient.on('connect', () => {
|
|
686
650
|
console.info('mqtt连接成功');
|
|
687
651
|
network.topics.split(',').forEach((topic) => {
|
|
688
|
-
mqttClient.publish(topic, value);
|
|
689
|
-
|
|
652
|
+
mqttClient.publish(topic, JSON.stringify(value));
|
|
653
|
+
setTimeout(() => {
|
|
654
|
+
mqttClient?.end();
|
|
655
|
+
}, 1000);
|
|
690
656
|
});
|
|
691
657
|
});
|
|
692
658
|
}
|
|
693
659
|
}
|
|
694
660
|
else if (network.protocol === 'websocket') {
|
|
695
|
-
const websockets = this.websockets
|
|
661
|
+
const websockets = this.websockets?.filter((socket) => socket.url === network.url);
|
|
696
662
|
if (websockets && websockets.length) {
|
|
697
663
|
if (websockets[0].readyState === 1) {
|
|
698
|
-
websockets[0].send(value);
|
|
664
|
+
websockets[0].send(JSON.stringify(value));
|
|
699
665
|
}
|
|
700
666
|
}
|
|
701
667
|
else {
|
|
@@ -703,7 +669,7 @@ export class Meta2d {
|
|
|
703
669
|
let websocket = new WebSocket(network.url, network.protocols || undefined);
|
|
704
670
|
websocket.onopen = function () {
|
|
705
671
|
console.info('websocket连接成功');
|
|
706
|
-
websocket.send(value);
|
|
672
|
+
websocket.send(JSON.stringify(value));
|
|
707
673
|
setTimeout(() => {
|
|
708
674
|
websocket.close();
|
|
709
675
|
}, 100);
|
|
@@ -829,19 +795,19 @@ export class Meta2d {
|
|
|
829
795
|
if (!render) {
|
|
830
796
|
this.canvas.opening = true;
|
|
831
797
|
}
|
|
798
|
+
this.doInitJS();
|
|
799
|
+
this.doInitFn();
|
|
832
800
|
this.initBindDatas();
|
|
833
801
|
this.initBinds();
|
|
834
802
|
this.initMessageEvents();
|
|
835
803
|
this.initGlobalTriggers();
|
|
836
|
-
this.
|
|
804
|
+
this.startAnimate();
|
|
805
|
+
this.startVideo();
|
|
837
806
|
this.listenSocket();
|
|
838
807
|
this.connectSocket();
|
|
839
808
|
this.connectNetwork();
|
|
840
809
|
this.startDataMock();
|
|
841
|
-
this.
|
|
842
|
-
this.startVideo();
|
|
843
|
-
this.doInitJS();
|
|
844
|
-
this.doInitFn();
|
|
810
|
+
this.render();
|
|
845
811
|
setTimeout(() => {
|
|
846
812
|
const pen = this.store.data.pens.find((pen) => pen.autofocus);
|
|
847
813
|
if (pen) {
|
|
@@ -910,6 +876,31 @@ export class Meta2d {
|
|
|
910
876
|
});
|
|
911
877
|
this.render();
|
|
912
878
|
}
|
|
879
|
+
statistics() {
|
|
880
|
+
const num = this.store.data.pens.length;
|
|
881
|
+
const imgNum = this.store.data.pens.filter((pen) => pen.image).length;
|
|
882
|
+
const imgDrawNum = this.store.data.pens.filter((pen) => pen.image && pen.calculative.inView).length;
|
|
883
|
+
const domNum = this.store.data.pens.filter((pen) => pen.name.endsWith('Dom') ||
|
|
884
|
+
isDomShapes.includes(pen.name) ||
|
|
885
|
+
this.store.options.domShapes.includes(pen.name) ||
|
|
886
|
+
pen.externElement).length;
|
|
887
|
+
const aningNum = this.store.animates.size;
|
|
888
|
+
let dataPointsNum = 0;
|
|
889
|
+
Object.keys(this.store.bind).forEach((key) => {
|
|
890
|
+
dataPointsNum += this.store.bind[key].length;
|
|
891
|
+
});
|
|
892
|
+
Object.keys(this.store.bindDatas).forEach((key) => {
|
|
893
|
+
dataPointsNum += this.store.bindDatas[key].length;
|
|
894
|
+
});
|
|
895
|
+
return {
|
|
896
|
+
"图元总数量": num,
|
|
897
|
+
"图片图元数量": imgNum,
|
|
898
|
+
"图片图元绘制数量": imgDrawNum,
|
|
899
|
+
"dom图元数量": domNum,
|
|
900
|
+
"正在执行的动画数量": aningNum,
|
|
901
|
+
"数据点数量": dataPointsNum,
|
|
902
|
+
};
|
|
903
|
+
}
|
|
913
904
|
initBindDatas() {
|
|
914
905
|
this.store.bindDatas = {};
|
|
915
906
|
this.store.data.pens.forEach((pen) => {
|
|
@@ -966,7 +957,7 @@ export class Meta2d {
|
|
|
966
957
|
this.jetLinksList.push({
|
|
967
958
|
topic: `/${productId}/${deviceId}`,
|
|
968
959
|
deviceId,
|
|
969
|
-
properties: [realTime.propertyId]
|
|
960
|
+
properties: [realTime.propertyId],
|
|
970
961
|
});
|
|
971
962
|
}
|
|
972
963
|
}
|
|
@@ -1003,7 +994,7 @@ export class Meta2d {
|
|
|
1003
994
|
binds.push({
|
|
1004
995
|
id: key.replace('bind-', ''),
|
|
1005
996
|
dataId: key.replace('bind-', ''),
|
|
1006
|
-
value: params[key]
|
|
997
|
+
value: params[key],
|
|
1007
998
|
});
|
|
1008
999
|
}
|
|
1009
1000
|
}
|
|
@@ -1034,7 +1025,8 @@ export class Meta2d {
|
|
|
1034
1025
|
this.store.data.pens.forEach((pen) => {
|
|
1035
1026
|
if (pen.externElement === true) {
|
|
1036
1027
|
// pen.onMove && pen.onMove(pen);
|
|
1037
|
-
pen.calculative.singleton?.div &&
|
|
1028
|
+
pen.calculative.singleton?.div &&
|
|
1029
|
+
setElemPosition(pen, pen.calculative.singleton.div);
|
|
1038
1030
|
}
|
|
1039
1031
|
});
|
|
1040
1032
|
if (lock > 0) {
|
|
@@ -1374,8 +1366,9 @@ export class Meta2d {
|
|
|
1374
1366
|
* 组合
|
|
1375
1367
|
* @param pens 组合的画笔们
|
|
1376
1368
|
* @param showChild 组合后展示第几个孩子
|
|
1369
|
+
* @param active 是否激活组合后的画笔
|
|
1377
1370
|
*/
|
|
1378
|
-
combine(pens = this.store.active, showChild) {
|
|
1371
|
+
combine(pens = this.store.active, showChild, active = true) {
|
|
1379
1372
|
if (!pens || !pens.length) {
|
|
1380
1373
|
return;
|
|
1381
1374
|
}
|
|
@@ -1421,7 +1414,9 @@ export class Meta2d {
|
|
|
1421
1414
|
if (index < minIndex) {
|
|
1422
1415
|
minIndex = index;
|
|
1423
1416
|
}
|
|
1424
|
-
if (pen === parent ||
|
|
1417
|
+
if (pen === parent ||
|
|
1418
|
+
pen.parentId === parent.id ||
|
|
1419
|
+
pen.id === parent.id) {
|
|
1425
1420
|
return;
|
|
1426
1421
|
}
|
|
1427
1422
|
// pen 来自于 store.active ,不存在有 parentId 的情况
|
|
@@ -1430,12 +1425,13 @@ export class Meta2d {
|
|
|
1430
1425
|
const childRect = calcRelativeRect(pen.calculative.worldRect, rect);
|
|
1431
1426
|
Object.assign(pen, childRect);
|
|
1432
1427
|
pen.locked = pen.lockedOnCombine ?? LockState.None;
|
|
1433
|
-
pen.locked =
|
|
1428
|
+
pen.locked =
|
|
1429
|
+
pen.interaction || isInteraction.includes(pen.name) ? 0 : pen.locked;
|
|
1434
1430
|
});
|
|
1435
1431
|
//将组合后的父节点置底
|
|
1436
1432
|
this.store.data.pens.splice(minIndex, 0, parent);
|
|
1437
1433
|
this.store.data.pens.pop();
|
|
1438
|
-
this.canvas.active([parent]);
|
|
1434
|
+
active && this.canvas.active([parent]);
|
|
1439
1435
|
let step = 1;
|
|
1440
1436
|
// if (!oneIsParent) {
|
|
1441
1437
|
// step = 2;
|
|
@@ -1523,7 +1519,7 @@ export class Meta2d {
|
|
|
1523
1519
|
if (pens.length < 2) {
|
|
1524
1520
|
return;
|
|
1525
1521
|
}
|
|
1526
|
-
const pIdx = pens.findIndex(pen => pen.name === 'combine' && pen.showChild !== undefined);
|
|
1522
|
+
const pIdx = pens.findIndex((pen) => pen.name === 'combine' && pen.showChild !== undefined);
|
|
1527
1523
|
if (pIdx !== -1) {
|
|
1528
1524
|
let parent = pens[pIdx];
|
|
1529
1525
|
// this.pushChildren(parent,[...pens.slice(0, pIdx), ...pens.slice(pIdx + 1)]);
|
|
@@ -1531,7 +1527,7 @@ export class Meta2d {
|
|
|
1531
1527
|
Object.assign(parent, rect);
|
|
1532
1528
|
Object.assign(parent.calculative.worldRect, rect);
|
|
1533
1529
|
calcWorldAnchors(parent);
|
|
1534
|
-
parent.children.forEach(penId => {
|
|
1530
|
+
parent.children.forEach((penId) => {
|
|
1535
1531
|
const pen = this.store.pens[penId];
|
|
1536
1532
|
const childRect = calcRelativeRect(pen.calculative.worldRect, rect);
|
|
1537
1533
|
Object.assign(pen, childRect);
|
|
@@ -1543,7 +1539,10 @@ export class Meta2d {
|
|
|
1543
1539
|
const childRect = calcRelativeRect(pen.calculative.worldRect, rect);
|
|
1544
1540
|
Object.assign(pen, childRect);
|
|
1545
1541
|
pen.locked = pen.lockedOnCombine ?? LockState.DisableMove;
|
|
1546
|
-
pen.locked =
|
|
1542
|
+
pen.locked =
|
|
1543
|
+
pen.interaction || isInteraction.includes(pen.name)
|
|
1544
|
+
? 0
|
|
1545
|
+
: pen.locked;
|
|
1547
1546
|
calcInView(pen, true);
|
|
1548
1547
|
}
|
|
1549
1548
|
});
|
|
@@ -1579,7 +1578,7 @@ export class Meta2d {
|
|
|
1579
1578
|
width: ex - x,
|
|
1580
1579
|
height: ey - y,
|
|
1581
1580
|
ex,
|
|
1582
|
-
ey
|
|
1581
|
+
ey,
|
|
1583
1582
|
};
|
|
1584
1583
|
if (!parent.parentId) {
|
|
1585
1584
|
Object.assign(parent, parent.calculative.worldRect);
|
|
@@ -1664,7 +1663,10 @@ export class Meta2d {
|
|
|
1664
1663
|
}
|
|
1665
1664
|
}
|
|
1666
1665
|
}
|
|
1667
|
-
data.dataPoints = [
|
|
1666
|
+
data.dataPoints = [
|
|
1667
|
+
...Object.keys(this.store.bind),
|
|
1668
|
+
...Object.keys(this.store.bindDatas),
|
|
1669
|
+
];
|
|
1668
1670
|
return data;
|
|
1669
1671
|
}
|
|
1670
1672
|
copy(pens) {
|
|
@@ -1813,7 +1815,7 @@ export class Meta2d {
|
|
|
1813
1815
|
// 默认每一秒请求一次
|
|
1814
1816
|
this.oldRequestHttp(item);
|
|
1815
1817
|
if (this.store.options.reconnetTimes) {
|
|
1816
|
-
item.times++;
|
|
1818
|
+
// item.times++;
|
|
1817
1819
|
if (item.times >= this.store.options.reconnetTimes) {
|
|
1818
1820
|
item.times = 0;
|
|
1819
1821
|
clearInterval(this.httpTimerList[index]);
|
|
@@ -1853,6 +1855,7 @@ export class Meta2d {
|
|
|
1853
1855
|
this.socketCallback(data, { type: 'http', url: req.http });
|
|
1854
1856
|
}
|
|
1855
1857
|
else {
|
|
1858
|
+
_req.times++;
|
|
1856
1859
|
this.store.emitter.emit('error', { type: 'http', error: res });
|
|
1857
1860
|
}
|
|
1858
1861
|
}
|
|
@@ -1989,7 +1992,7 @@ export class Meta2d {
|
|
|
1989
1992
|
topic: `le5le-iot/properties/${token}`,
|
|
1990
1993
|
type: 'iot',
|
|
1991
1994
|
url: net.url,
|
|
1992
|
-
method: 'mqtt'
|
|
1995
|
+
method: 'mqtt',
|
|
1993
1996
|
});
|
|
1994
1997
|
});
|
|
1995
1998
|
this.mqttClients[mqttIndex].on('error', (error) => {
|
|
@@ -2022,17 +2025,24 @@ export class Meta2d {
|
|
|
2022
2025
|
}
|
|
2023
2026
|
else if (net.protocol === 'jetLinks') {
|
|
2024
2027
|
if (this.jetLinksList.length) {
|
|
2025
|
-
this.jetLinksClient = new WebSocket(`${net.url}/${localStorage.getItem('X-Access-Token') ||
|
|
2028
|
+
this.jetLinksClient = new WebSocket(`${net.url}/${localStorage.getItem('X-Access-Token') ||
|
|
2029
|
+
getCookie('X-Access-Token') ||
|
|
2030
|
+
new URLSearchParams(location.search).get('X-Access-Token') ||
|
|
2031
|
+
''}`
|
|
2032
|
+
// 'ws://8.134.86.52:29000/api/messaging/961d8b395298d3ec3a021df70d6b6ca4'
|
|
2033
|
+
);
|
|
2026
2034
|
//消息接收
|
|
2027
2035
|
this.jetLinksClient.onmessage = (e) => {
|
|
2028
2036
|
const mess = JSON.parse(e.data);
|
|
2029
|
-
if (mess.payload &&
|
|
2037
|
+
if (mess.payload &&
|
|
2038
|
+
mess.payload.success &&
|
|
2039
|
+
mess.payload?.properties) {
|
|
2030
2040
|
const data = [];
|
|
2031
2041
|
for (let key in mess.payload.properties) {
|
|
2032
2042
|
if (!key.startsWith('_')) {
|
|
2033
2043
|
data.push({
|
|
2034
2044
|
id: `${mess.payload.headers.productId}#${mess.payload.deviceId}#${key}`,
|
|
2035
|
-
value: mess.payload.properties[key]
|
|
2045
|
+
value: mess.payload.properties[key],
|
|
2036
2046
|
});
|
|
2037
2047
|
}
|
|
2038
2048
|
}
|
|
@@ -2042,14 +2052,14 @@ export class Meta2d {
|
|
|
2042
2052
|
this.jetLinksClient.onopen = () => {
|
|
2043
2053
|
this.jetLinksList.forEach((item) => {
|
|
2044
2054
|
this.jetLinksClient.send(JSON.stringify({
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2055
|
+
type: 'sub',
|
|
2056
|
+
topic: `/device${item.topic}/message/property/report`,
|
|
2057
|
+
parameter: {
|
|
2058
|
+
deviceId: item.deviceId,
|
|
2059
|
+
properties: item.properties,
|
|
2060
|
+
history: 1,
|
|
2051
2061
|
},
|
|
2052
|
-
|
|
2062
|
+
id: item.topic + '-' + s8(),
|
|
2053
2063
|
}));
|
|
2054
2064
|
});
|
|
2055
2065
|
};
|
|
@@ -2102,12 +2112,15 @@ export class Meta2d {
|
|
|
2102
2112
|
async doSqlCode(type, dbid, sql) {
|
|
2103
2113
|
const res = await fetch(`/api/iot/data/sql/${type}`, {
|
|
2104
2114
|
method: 'POST',
|
|
2105
|
-
body: JSON.stringify({ dbid, sql
|
|
2115
|
+
body: JSON.stringify({ dbid, sql }),
|
|
2106
2116
|
});
|
|
2107
2117
|
if (res.ok) {
|
|
2108
2118
|
const data = await res.text();
|
|
2109
2119
|
if (data) {
|
|
2110
|
-
this.socketCallback(data, {
|
|
2120
|
+
this.socketCallback(data, {
|
|
2121
|
+
type: 'sql',
|
|
2122
|
+
url: `/api/iot/data/sql/${type}`,
|
|
2123
|
+
});
|
|
2111
2124
|
}
|
|
2112
2125
|
}
|
|
2113
2126
|
}
|
|
@@ -2216,8 +2229,7 @@ export class Meta2d {
|
|
|
2216
2229
|
else {
|
|
2217
2230
|
//if (realTime.type === 'string')
|
|
2218
2231
|
if (data.mock && data.mock.indexOf(',') !== -1) {
|
|
2219
|
-
let
|
|
2220
|
-
let arr = str.split(',');
|
|
2232
|
+
let arr = data.mock.split(',');
|
|
2221
2233
|
let rai = Math.floor(Math.random() * arr.length);
|
|
2222
2234
|
value = arr[rai];
|
|
2223
2235
|
}
|
|
@@ -2242,7 +2254,7 @@ export class Meta2d {
|
|
|
2242
2254
|
if (value !== undefined) {
|
|
2243
2255
|
arr.push({
|
|
2244
2256
|
id: data.id,
|
|
2245
|
-
value
|
|
2257
|
+
value,
|
|
2246
2258
|
});
|
|
2247
2259
|
}
|
|
2248
2260
|
});
|
|
@@ -2310,20 +2322,19 @@ export class Meta2d {
|
|
|
2310
2322
|
delete this.store.pensNetwork[pen.id];
|
|
2311
2323
|
}
|
|
2312
2324
|
}
|
|
2313
|
-
getCookie(name) {
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
}
|
|
2325
|
+
// getCookie(name: string) {
|
|
2326
|
+
// let arr: RegExpMatchArray | null;
|
|
2327
|
+
// const reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
|
|
2328
|
+
// if ((arr = document.cookie.match(reg))) {
|
|
2329
|
+
// return decodeURIComponent(arr[2]);
|
|
2330
|
+
// } else {
|
|
2331
|
+
// return '';
|
|
2332
|
+
// }
|
|
2333
|
+
// }
|
|
2323
2334
|
//获取动态参数
|
|
2324
2335
|
getDynamicParam(key) {
|
|
2325
2336
|
let params = queryURLParams();
|
|
2326
|
-
let value = params[key] || localStorage[key] ||
|
|
2337
|
+
let value = params[key] || localStorage[key] || getCookie(key) || '';
|
|
2327
2338
|
return value;
|
|
2328
2339
|
}
|
|
2329
2340
|
onNetworkConnect(https) {
|
|
@@ -2358,7 +2369,7 @@ export class Meta2d {
|
|
|
2358
2369
|
this.updateTimerList[index] = setInterval(async () => {
|
|
2359
2370
|
this.requestHttp(_item);
|
|
2360
2371
|
if (this.store.options.reconnetTimes) {
|
|
2361
|
-
_item.times++;
|
|
2372
|
+
// _item.times++;
|
|
2362
2373
|
if (_item.times >= this.store.options.reconnetTimes) {
|
|
2363
2374
|
_item.times = 0;
|
|
2364
2375
|
clearInterval(this.updateTimerList[index]);
|
|
@@ -2371,6 +2382,14 @@ export class Meta2d {
|
|
|
2371
2382
|
async requestHttp(_req) {
|
|
2372
2383
|
let req = deepClone(_req);
|
|
2373
2384
|
if (req.url) {
|
|
2385
|
+
if (req.url.indexOf('${') > -1) {
|
|
2386
|
+
let keys = req.url.match(/(?<=\$\{).*?(?=\})/g);
|
|
2387
|
+
if (keys) {
|
|
2388
|
+
keys.forEach((key) => {
|
|
2389
|
+
req.url = req.url.replace(`\${${key}}`, this.getDynamicParam(key));
|
|
2390
|
+
});
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2374
2393
|
if (typeof req.headers === 'object') {
|
|
2375
2394
|
for (let i in req.headers) {
|
|
2376
2395
|
if (typeof req.headers[i] === 'string') {
|
|
@@ -2402,6 +2421,7 @@ export class Meta2d {
|
|
|
2402
2421
|
this.socketCallback(data, { type: 'http', url: req.url });
|
|
2403
2422
|
}
|
|
2404
2423
|
else {
|
|
2424
|
+
_req.times++;
|
|
2405
2425
|
this.store.emitter.emit('error', { type: 'http', error: res });
|
|
2406
2426
|
}
|
|
2407
2427
|
}
|
|
@@ -2443,7 +2463,7 @@ export class Meta2d {
|
|
|
2443
2463
|
type: context.type,
|
|
2444
2464
|
topic: context.topic,
|
|
2445
2465
|
url: context.url,
|
|
2446
|
-
method: context.method
|
|
2466
|
+
method: context.method,
|
|
2447
2467
|
});
|
|
2448
2468
|
if (!_message) {
|
|
2449
2469
|
return;
|
|
@@ -2617,10 +2637,9 @@ export class Meta2d {
|
|
|
2617
2637
|
binds.push({
|
|
2618
2638
|
dataId: key,
|
|
2619
2639
|
id: key,
|
|
2620
|
-
value: data[key]
|
|
2640
|
+
value: data[key],
|
|
2621
2641
|
});
|
|
2622
2642
|
}
|
|
2623
|
-
;
|
|
2624
2643
|
if (binds.length) {
|
|
2625
2644
|
this.setDatas(binds, {
|
|
2626
2645
|
render,
|
|
@@ -2720,7 +2739,7 @@ export class Meta2d {
|
|
|
2720
2739
|
}
|
|
2721
2740
|
break;
|
|
2722
2741
|
case 'click':
|
|
2723
|
-
if (this.store.data.locked && e.pen &&
|
|
2742
|
+
if (this.store.data.locked && e.pen && !e.pen.disabled) {
|
|
2724
2743
|
if (e.pen.switch) {
|
|
2725
2744
|
e.pen.checked = !e.pen.checked;
|
|
2726
2745
|
e.pen.calculative.checked = e.pen.checked;
|
|
@@ -2728,29 +2747,50 @@ export class Meta2d {
|
|
|
2728
2747
|
e.pen.calculative.radialGradient = undefined;
|
|
2729
2748
|
}
|
|
2730
2749
|
}
|
|
2731
|
-
e.pen &&
|
|
2732
|
-
|
|
2750
|
+
e.pen &&
|
|
2751
|
+
e.pen.onClick &&
|
|
2752
|
+
!e.pen.disabled &&
|
|
2753
|
+
e.pen.onClick(e.pen, this.canvas.mousePos);
|
|
2754
|
+
this.store.data.locked &&
|
|
2755
|
+
e.pen &&
|
|
2756
|
+
!e.pen.disabled &&
|
|
2757
|
+
this.doEvent(e.pen, eventName);
|
|
2733
2758
|
break;
|
|
2734
2759
|
case 'contextmenu':
|
|
2735
2760
|
e.pen &&
|
|
2736
|
-
e.pen.onContextmenu &&
|
|
2761
|
+
e.pen.onContextmenu &&
|
|
2762
|
+
!e.pen.disabled &&
|
|
2737
2763
|
e.pen.onContextmenu(e.pen, this.canvas.mousePos);
|
|
2738
|
-
this.store.data.locked &&
|
|
2764
|
+
this.store.data.locked &&
|
|
2765
|
+
e.pen &&
|
|
2766
|
+
!e.pen.disabled &&
|
|
2767
|
+
this.doEvent(e.pen, eventName);
|
|
2739
2768
|
break;
|
|
2740
2769
|
case 'mousedown':
|
|
2741
2770
|
e.pen &&
|
|
2742
|
-
e.pen.onMouseDown &&
|
|
2771
|
+
e.pen.onMouseDown &&
|
|
2772
|
+
!e.pen.disabled &&
|
|
2743
2773
|
e.pen.onMouseDown(e.pen, this.canvas.mousePos);
|
|
2744
|
-
this.store.data.locked &&
|
|
2774
|
+
this.store.data.locked &&
|
|
2775
|
+
e.pen &&
|
|
2776
|
+
!e.pen.disabled &&
|
|
2777
|
+
this.doEvent(e.pen, eventName);
|
|
2745
2778
|
break;
|
|
2746
2779
|
case 'mouseup':
|
|
2747
2780
|
e.pen &&
|
|
2748
|
-
e.pen.onMouseUp &&
|
|
2781
|
+
e.pen.onMouseUp &&
|
|
2782
|
+
!e.pen.disabled &&
|
|
2749
2783
|
e.pen.onMouseUp(e.pen, this.canvas.mousePos);
|
|
2750
|
-
this.store.data.locked &&
|
|
2784
|
+
this.store.data.locked &&
|
|
2785
|
+
e.pen &&
|
|
2786
|
+
!e.pen.disabled &&
|
|
2787
|
+
this.doEvent(e.pen, eventName);
|
|
2751
2788
|
break;
|
|
2752
2789
|
case 'dblclick':
|
|
2753
|
-
this.store.data.locked &&
|
|
2790
|
+
this.store.data.locked &&
|
|
2791
|
+
e.pen &&
|
|
2792
|
+
!e.pen.disabled &&
|
|
2793
|
+
this.doEvent(e.pen, eventName);
|
|
2754
2794
|
break;
|
|
2755
2795
|
case 'valueUpdate':
|
|
2756
2796
|
this.store.data.locked && this.doEvent(e, eventName);
|
|
@@ -2770,10 +2810,16 @@ export class Meta2d {
|
|
|
2770
2810
|
this.navigatorTo(e.params);
|
|
2771
2811
|
break;
|
|
2772
2812
|
case 'input':
|
|
2773
|
-
this.store.data.locked &&
|
|
2813
|
+
this.store.data.locked &&
|
|
2814
|
+
e &&
|
|
2815
|
+
!e.disabled &&
|
|
2816
|
+
this.doEvent(e, eventName);
|
|
2774
2817
|
break;
|
|
2775
2818
|
case 'change':
|
|
2776
|
-
this.store.data.locked &&
|
|
2819
|
+
this.store.data.locked &&
|
|
2820
|
+
e &&
|
|
2821
|
+
!e.disabled &&
|
|
2822
|
+
this.doEvent(e, eventName);
|
|
2777
2823
|
break;
|
|
2778
2824
|
}
|
|
2779
2825
|
this.doMessageEvent(eventName);
|
|
@@ -2893,7 +2939,7 @@ export class Meta2d {
|
|
|
2893
2939
|
pen.events?.forEach(async (event, index) => {
|
|
2894
2940
|
if (indexArr.includes(index)) {
|
|
2895
2941
|
if (event.confirm) {
|
|
2896
|
-
if (!await this.canvas.popconfirm.showModal(pen, this.canvas.mousePos, event.confirmTitle)) {
|
|
2942
|
+
if (!(await this.canvas.popconfirm.showModal(pen, this.canvas.mousePos, event.confirmTitle))) {
|
|
2897
2943
|
return;
|
|
2898
2944
|
}
|
|
2899
2945
|
}
|
|
@@ -3074,14 +3120,14 @@ export class Meta2d {
|
|
|
3074
3120
|
}
|
|
3075
3121
|
if (flag) {
|
|
3076
3122
|
item.event.actions.forEach((action) => {
|
|
3077
|
-
this.events[action.action](item.pen, action);
|
|
3123
|
+
this.events[action.action](item.pen, action, data);
|
|
3078
3124
|
});
|
|
3079
3125
|
}
|
|
3080
3126
|
});
|
|
3081
3127
|
}
|
|
3082
3128
|
}
|
|
3083
3129
|
doDataEvent = (datas) => {
|
|
3084
|
-
if (!
|
|
3130
|
+
if (!this.store.data.dataEvents?.length) {
|
|
3085
3131
|
return;
|
|
3086
3132
|
}
|
|
3087
3133
|
const data = datas.reduce((accumulator, { dataId, id, value }) => {
|
|
@@ -3304,7 +3350,8 @@ export class Meta2d {
|
|
|
3304
3350
|
const childRect = calcRelativeRect(pen.calculative.worldRect, parent.calculative.worldRect);
|
|
3305
3351
|
Object.assign(pen, childRect);
|
|
3306
3352
|
pen.locked = pen.lockedOnCombine ?? LockState.DisableMove;
|
|
3307
|
-
pen.locked =
|
|
3353
|
+
pen.locked =
|
|
3354
|
+
pen.interaction || isInteraction.includes(pen.name) ? 0 : pen.locked;
|
|
3308
3355
|
if (!oldPen) {
|
|
3309
3356
|
addPens.push(deepClone(pen, true));
|
|
3310
3357
|
}
|
|
@@ -3371,10 +3418,14 @@ export class Meta2d {
|
|
|
3371
3418
|
rect.y -= 10;
|
|
3372
3419
|
const ctx = new window.C2S(rect.width + 20, rect.height + 20);
|
|
3373
3420
|
ctx.textBaseline = 'middle';
|
|
3421
|
+
ctx.strokeStyle = getGlobalColor(this.store);
|
|
3374
3422
|
for (const pen of this.store.data.pens) {
|
|
3375
3423
|
if (pen.visible == false || !isShowChild(pen, this.store)) {
|
|
3376
3424
|
continue;
|
|
3377
3425
|
}
|
|
3426
|
+
if (pen.name === 'combine' && !pen.draw) {
|
|
3427
|
+
continue;
|
|
3428
|
+
}
|
|
3378
3429
|
renderPenRaw(ctx, pen, rect, true);
|
|
3379
3430
|
}
|
|
3380
3431
|
let mySerializedSVG = ctx.getSerializedSvg();
|
|
@@ -3491,9 +3542,14 @@ export class Meta2d {
|
|
|
3491
3542
|
pen.imageRatio = false;
|
|
3492
3543
|
}
|
|
3493
3544
|
}
|
|
3494
|
-
pen.calculative.worldRect.x =
|
|
3545
|
+
pen.calculative.worldRect.x =
|
|
3546
|
+
rect.x -
|
|
3547
|
+
wGap / 2 +
|
|
3548
|
+
left +
|
|
3549
|
+
(pen.calculative.worldRect.x - rect.x) * ratio; //(fit.leftValue || 0)+ (pen.calculative.worldRect.x + pen.calculative.worldRect.width/2)-( pen.calculative.worldRect.width*ratio)*(range/2- (fit.rightValue || 0))/(range- (fit.leftValue || 0)-(fit.rightValue || 0));
|
|
3495
3550
|
pen.calculative.worldRect.width *= ratio;
|
|
3496
|
-
pen.calculative.worldRect.ex =
|
|
3551
|
+
pen.calculative.worldRect.ex =
|
|
3552
|
+
pen.calculative.worldRect.x + pen.calculative.worldRect.width;
|
|
3497
3553
|
pen.calculative.width = pen.calculative.worldRect.width;
|
|
3498
3554
|
pen.calculative.x = pen.calculative.worldRect.x;
|
|
3499
3555
|
pen.width = pen.calculative.worldRect.width;
|
|
@@ -3508,14 +3564,21 @@ export class Meta2d {
|
|
|
3508
3564
|
//左移
|
|
3509
3565
|
r = -r;
|
|
3510
3566
|
if (fit.leftValue) {
|
|
3511
|
-
r +=
|
|
3567
|
+
r +=
|
|
3568
|
+
Math.abs(fit.leftValue) < 1
|
|
3569
|
+
? fit.leftValue * this.canvas.width
|
|
3570
|
+
: fit.leftValue;
|
|
3512
3571
|
}
|
|
3513
3572
|
this.translatePens(pens, r, 0);
|
|
3514
3573
|
}
|
|
3515
3574
|
else if (fit.right) {
|
|
3516
3575
|
//右移
|
|
3517
3576
|
if (fit.rightValue) {
|
|
3518
|
-
r =
|
|
3577
|
+
r =
|
|
3578
|
+
r -
|
|
3579
|
+
(Math.abs(fit.rightValue) < 1
|
|
3580
|
+
? fit.rightValue * this.canvas.width
|
|
3581
|
+
: fit.rightValue);
|
|
3519
3582
|
}
|
|
3520
3583
|
this.translatePens(pens, r, 0);
|
|
3521
3584
|
}
|
|
@@ -3526,8 +3589,7 @@ export class Meta2d {
|
|
|
3526
3589
|
if (worldRect.width / this.store.data.scale > rect.width * 0.8) {
|
|
3527
3590
|
let bfW = worldRect.width;
|
|
3528
3591
|
pen.calculative.worldRect.x = worldRect.x - wGap / 2;
|
|
3529
|
-
pen.calculative.worldRect.width =
|
|
3530
|
-
worldRect.width + wGap;
|
|
3592
|
+
pen.calculative.worldRect.width = worldRect.width + wGap;
|
|
3531
3593
|
pen.calculative.worldRect.ex = worldRect.ex + wGap;
|
|
3532
3594
|
pen.operationalRect.x =
|
|
3533
3595
|
(pen.operationalRect.x * bfW) / pen.calculative.worldRect.width;
|
|
@@ -3561,7 +3623,8 @@ export class Meta2d {
|
|
|
3561
3623
|
top = 0;
|
|
3562
3624
|
}
|
|
3563
3625
|
if (bottom) {
|
|
3564
|
-
bottom =
|
|
3626
|
+
bottom =
|
|
3627
|
+
Math.abs(bottom) < 1 ? bottom * this.canvas.height : bottom;
|
|
3565
3628
|
}
|
|
3566
3629
|
else {
|
|
3567
3630
|
bottom = 0;
|
|
@@ -3573,9 +3636,14 @@ export class Meta2d {
|
|
|
3573
3636
|
pen.imageRatio = false;
|
|
3574
3637
|
}
|
|
3575
3638
|
}
|
|
3576
|
-
pen.calculative.worldRect.y =
|
|
3639
|
+
pen.calculative.worldRect.y =
|
|
3640
|
+
rect.y -
|
|
3641
|
+
hGap / 2 +
|
|
3642
|
+
top +
|
|
3643
|
+
(pen.calculative.worldRect.y - rect.y) * ratio; //(fit.leftValue || 0)+ (pen.calculative.worldRect.x + pen.calculative.worldRect.width/2)-( pen.calculative.worldRect.width*ratio)*(range/2- (fit.rightValue || 0))/(range- (fit.leftValue || 0)-(fit.rightValue || 0));
|
|
3577
3644
|
pen.calculative.worldRect.height *= ratio;
|
|
3578
|
-
pen.calculative.worldRect.ey =
|
|
3645
|
+
pen.calculative.worldRect.ey =
|
|
3646
|
+
pen.calculative.worldRect.y + pen.calculative.worldRect.height;
|
|
3579
3647
|
pen.calculative.height = pen.calculative.worldRect.height;
|
|
3580
3648
|
pen.calculative.y = pen.calculative.worldRect.y;
|
|
3581
3649
|
pen.height = pen.calculative.worldRect.height;
|
|
@@ -3589,13 +3657,20 @@ export class Meta2d {
|
|
|
3589
3657
|
else if (fit.top) {
|
|
3590
3658
|
r = -r;
|
|
3591
3659
|
if (fit.topValue) {
|
|
3592
|
-
r +=
|
|
3660
|
+
r +=
|
|
3661
|
+
Math.abs(fit.topValue) < 1
|
|
3662
|
+
? fit.topValue * this.canvas.height
|
|
3663
|
+
: fit.topValue;
|
|
3593
3664
|
}
|
|
3594
3665
|
this.translatePens(pens, 0, r);
|
|
3595
3666
|
}
|
|
3596
3667
|
else if (fit.bottom) {
|
|
3597
3668
|
if (fit.bottomValue) {
|
|
3598
|
-
r =
|
|
3669
|
+
r =
|
|
3670
|
+
r -
|
|
3671
|
+
(Math.abs(fit.bottomValue) < 1
|
|
3672
|
+
? fit.bottomValue * this.canvas.height
|
|
3673
|
+
: fit.bottomValue);
|
|
3599
3674
|
}
|
|
3600
3675
|
this.translatePens(pens, 0, r);
|
|
3601
3676
|
}
|
|
@@ -3606,8 +3681,7 @@ export class Meta2d {
|
|
|
3606
3681
|
if (worldRect.height / this.store.data.scale > rect.height * 0.8) {
|
|
3607
3682
|
let bfH = worldRect.height;
|
|
3608
3683
|
pen.calculative.worldRect.y = worldRect.y - hGap / 2;
|
|
3609
|
-
pen.calculative.worldRect.height =
|
|
3610
|
-
worldRect.height + hGap;
|
|
3684
|
+
pen.calculative.worldRect.height = worldRect.height + hGap;
|
|
3611
3685
|
pen.calculative.worldRect.ey = worldRect.ey + hGap;
|
|
3612
3686
|
pen.operationalRect.y =
|
|
3613
3687
|
(pen.operationalRect.y * bfH) / pen.calculative.worldRect.width;
|
|
@@ -3935,10 +4009,11 @@ export class Meta2d {
|
|
|
3935
4009
|
const firstPen = pens[0];
|
|
3936
4010
|
formatAttrs.forEach((attr) => {
|
|
3937
4011
|
attrs[attr] =
|
|
3938
|
-
firstPen[attr] !== undefined
|
|
3939
|
-
|
|
4012
|
+
firstPen[attr] !== undefined
|
|
4013
|
+
? firstPen[attr]
|
|
4014
|
+
: this.store.options.defaultFormat[attr] ||
|
|
3940
4015
|
this.store.data[attr] ||
|
|
3941
|
-
this.store.options[attr]
|
|
4016
|
+
this.store.options[attr];
|
|
3942
4017
|
});
|
|
3943
4018
|
}
|
|
3944
4019
|
else {
|
|
@@ -4942,7 +5017,7 @@ export class Meta2d {
|
|
|
4942
5017
|
pen.locked = pen.lockedOnCombine ?? LockState.DisableMove;
|
|
4943
5018
|
// pen.type = PenType.Node;
|
|
4944
5019
|
});
|
|
4945
|
-
return
|
|
5020
|
+
return oneIsParent || parents.length === 1
|
|
4946
5021
|
? deepClone(components)
|
|
4947
5022
|
: deepClone([parent, ...components]);
|
|
4948
5023
|
}
|
|
@@ -4955,10 +5030,14 @@ export class Meta2d {
|
|
|
4955
5030
|
if (!pen.tag && !pen.name && !pen.id)
|
|
4956
5031
|
return;
|
|
4957
5032
|
let type;
|
|
4958
|
-
pen.id
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
5033
|
+
pen.id
|
|
5034
|
+
? (type = 'id')
|
|
5035
|
+
: pen.tag
|
|
5036
|
+
? (type = 'tag')
|
|
5037
|
+
: pen.name
|
|
5038
|
+
? (type = 'name')
|
|
5039
|
+
: '';
|
|
5040
|
+
plugins.forEach((pluginConfig) => {
|
|
4962
5041
|
let plugin = pluginConfig.plugin;
|
|
4963
5042
|
let option = pluginConfig.options;
|
|
4964
5043
|
if (!plugin)
|
|
@@ -4981,7 +5060,7 @@ export class Meta2d {
|
|
|
4981
5060
|
else {
|
|
4982
5061
|
this.penPluginMap.get(plugin).push({
|
|
4983
5062
|
[type]: pen[type],
|
|
4984
|
-
option
|
|
5063
|
+
option,
|
|
4985
5064
|
});
|
|
4986
5065
|
}
|
|
4987
5066
|
}
|
|
@@ -4990,16 +5069,20 @@ export class Meta2d {
|
|
|
4990
5069
|
}
|
|
4991
5070
|
uninstallPenPlugins(pen, plugins) {
|
|
4992
5071
|
let type;
|
|
4993
|
-
pen.id
|
|
4994
|
-
|
|
4995
|
-
|
|
5072
|
+
pen.id
|
|
5073
|
+
? (type = 'id')
|
|
5074
|
+
: pen.tag
|
|
5075
|
+
? (type = 'tag')
|
|
5076
|
+
: pen.name
|
|
5077
|
+
? (type = 'name')
|
|
5078
|
+
: '';
|
|
4996
5079
|
if (!type)
|
|
4997
5080
|
return;
|
|
4998
|
-
plugins.forEach(pluginConfig => {
|
|
5081
|
+
plugins.forEach((pluginConfig) => {
|
|
4999
5082
|
let plugin = pluginConfig.plugin;
|
|
5000
5083
|
plugin.uninstall(pen, pluginConfig.options);
|
|
5001
5084
|
let mapList = this.penPluginMap.get(plugin);
|
|
5002
|
-
let op = mapList.findIndex(i => i[type] === pen[type]);
|
|
5085
|
+
let op = mapList.findIndex((i) => i[type] === pen[type]);
|
|
5003
5086
|
if (op !== -1) {
|
|
5004
5087
|
mapList.splice(op, 1);
|
|
5005
5088
|
// TODO 在运行时 插件卸载后是否需要移除?
|