@meta2d/core 1.0.63 → 1.0.65
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 +1 -1
- package/src/canvas/canvas.js +52 -30
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasTemplate.d.ts +1 -0
- package/src/canvas/canvasTemplate.js +8 -2
- package/src/canvas/canvasTemplate.js.map +1 -1
- package/src/core.d.ts +3 -2
- package/src/core.js +258 -208
- 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/pen/render.js +29 -11
- package/src/pen/render.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, } 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]];
|
|
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,10 +430,11 @@ 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
|
-
value[key] = _pen[keys[0]];
|
|
437
|
+
value[key] = _pen[keys[0]] ?? this.getDynamicParam(keys[0]);
|
|
446
438
|
}
|
|
447
439
|
}
|
|
448
440
|
}
|
|
@@ -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) {
|
|
@@ -966,7 +932,7 @@ export class Meta2d {
|
|
|
966
932
|
this.jetLinksList.push({
|
|
967
933
|
topic: `/${productId}/${deviceId}`,
|
|
968
934
|
deviceId,
|
|
969
|
-
properties: [realTime.propertyId]
|
|
935
|
+
properties: [realTime.propertyId],
|
|
970
936
|
});
|
|
971
937
|
}
|
|
972
938
|
}
|
|
@@ -1003,7 +969,7 @@ export class Meta2d {
|
|
|
1003
969
|
binds.push({
|
|
1004
970
|
id: key.replace('bind-', ''),
|
|
1005
971
|
dataId: key.replace('bind-', ''),
|
|
1006
|
-
value: params[key]
|
|
972
|
+
value: params[key],
|
|
1007
973
|
});
|
|
1008
974
|
}
|
|
1009
975
|
}
|
|
@@ -1034,7 +1000,8 @@ export class Meta2d {
|
|
|
1034
1000
|
this.store.data.pens.forEach((pen) => {
|
|
1035
1001
|
if (pen.externElement === true) {
|
|
1036
1002
|
// pen.onMove && pen.onMove(pen);
|
|
1037
|
-
pen.calculative.singleton?.div &&
|
|
1003
|
+
pen.calculative.singleton?.div &&
|
|
1004
|
+
setElemPosition(pen, pen.calculative.singleton.div);
|
|
1038
1005
|
}
|
|
1039
1006
|
});
|
|
1040
1007
|
if (lock > 0) {
|
|
@@ -1374,8 +1341,9 @@ export class Meta2d {
|
|
|
1374
1341
|
* 组合
|
|
1375
1342
|
* @param pens 组合的画笔们
|
|
1376
1343
|
* @param showChild 组合后展示第几个孩子
|
|
1344
|
+
* @param active 是否激活组合后的画笔
|
|
1377
1345
|
*/
|
|
1378
|
-
combine(pens = this.store.active, showChild) {
|
|
1346
|
+
combine(pens = this.store.active, showChild, active = true) {
|
|
1379
1347
|
if (!pens || !pens.length) {
|
|
1380
1348
|
return;
|
|
1381
1349
|
}
|
|
@@ -1421,7 +1389,9 @@ export class Meta2d {
|
|
|
1421
1389
|
if (index < minIndex) {
|
|
1422
1390
|
minIndex = index;
|
|
1423
1391
|
}
|
|
1424
|
-
if (pen === parent ||
|
|
1392
|
+
if (pen === parent ||
|
|
1393
|
+
pen.parentId === parent.id ||
|
|
1394
|
+
pen.id === parent.id) {
|
|
1425
1395
|
return;
|
|
1426
1396
|
}
|
|
1427
1397
|
// pen 来自于 store.active ,不存在有 parentId 的情况
|
|
@@ -1430,12 +1400,13 @@ export class Meta2d {
|
|
|
1430
1400
|
const childRect = calcRelativeRect(pen.calculative.worldRect, rect);
|
|
1431
1401
|
Object.assign(pen, childRect);
|
|
1432
1402
|
pen.locked = pen.lockedOnCombine ?? LockState.None;
|
|
1433
|
-
pen.locked =
|
|
1403
|
+
pen.locked =
|
|
1404
|
+
pen.interaction || isInteraction.includes(pen.name) ? 0 : pen.locked;
|
|
1434
1405
|
});
|
|
1435
1406
|
//将组合后的父节点置底
|
|
1436
1407
|
this.store.data.pens.splice(minIndex, 0, parent);
|
|
1437
1408
|
this.store.data.pens.pop();
|
|
1438
|
-
this.canvas.active([parent]);
|
|
1409
|
+
active && this.canvas.active([parent]);
|
|
1439
1410
|
let step = 1;
|
|
1440
1411
|
// if (!oneIsParent) {
|
|
1441
1412
|
// step = 2;
|
|
@@ -1523,7 +1494,7 @@ export class Meta2d {
|
|
|
1523
1494
|
if (pens.length < 2) {
|
|
1524
1495
|
return;
|
|
1525
1496
|
}
|
|
1526
|
-
const pIdx = pens.findIndex(pen => pen.name === 'combine' && pen.showChild !== undefined);
|
|
1497
|
+
const pIdx = pens.findIndex((pen) => pen.name === 'combine' && pen.showChild !== undefined);
|
|
1527
1498
|
if (pIdx !== -1) {
|
|
1528
1499
|
let parent = pens[pIdx];
|
|
1529
1500
|
// this.pushChildren(parent,[...pens.slice(0, pIdx), ...pens.slice(pIdx + 1)]);
|
|
@@ -1531,7 +1502,7 @@ export class Meta2d {
|
|
|
1531
1502
|
Object.assign(parent, rect);
|
|
1532
1503
|
Object.assign(parent.calculative.worldRect, rect);
|
|
1533
1504
|
calcWorldAnchors(parent);
|
|
1534
|
-
parent.children.forEach(penId => {
|
|
1505
|
+
parent.children.forEach((penId) => {
|
|
1535
1506
|
const pen = this.store.pens[penId];
|
|
1536
1507
|
const childRect = calcRelativeRect(pen.calculative.worldRect, rect);
|
|
1537
1508
|
Object.assign(pen, childRect);
|
|
@@ -1543,7 +1514,10 @@ export class Meta2d {
|
|
|
1543
1514
|
const childRect = calcRelativeRect(pen.calculative.worldRect, rect);
|
|
1544
1515
|
Object.assign(pen, childRect);
|
|
1545
1516
|
pen.locked = pen.lockedOnCombine ?? LockState.DisableMove;
|
|
1546
|
-
pen.locked =
|
|
1517
|
+
pen.locked =
|
|
1518
|
+
pen.interaction || isInteraction.includes(pen.name)
|
|
1519
|
+
? 0
|
|
1520
|
+
: pen.locked;
|
|
1547
1521
|
calcInView(pen, true);
|
|
1548
1522
|
}
|
|
1549
1523
|
});
|
|
@@ -1579,7 +1553,7 @@ export class Meta2d {
|
|
|
1579
1553
|
width: ex - x,
|
|
1580
1554
|
height: ey - y,
|
|
1581
1555
|
ex,
|
|
1582
|
-
ey
|
|
1556
|
+
ey,
|
|
1583
1557
|
};
|
|
1584
1558
|
if (!parent.parentId) {
|
|
1585
1559
|
Object.assign(parent, parent.calculative.worldRect);
|
|
@@ -1664,7 +1638,10 @@ export class Meta2d {
|
|
|
1664
1638
|
}
|
|
1665
1639
|
}
|
|
1666
1640
|
}
|
|
1667
|
-
data.dataPoints = [
|
|
1641
|
+
data.dataPoints = [
|
|
1642
|
+
...Object.keys(this.store.bind),
|
|
1643
|
+
...Object.keys(this.store.bindDatas),
|
|
1644
|
+
];
|
|
1668
1645
|
return data;
|
|
1669
1646
|
}
|
|
1670
1647
|
copy(pens) {
|
|
@@ -1989,7 +1966,7 @@ export class Meta2d {
|
|
|
1989
1966
|
topic: `le5le-iot/properties/${token}`,
|
|
1990
1967
|
type: 'iot',
|
|
1991
1968
|
url: net.url,
|
|
1992
|
-
method: 'mqtt'
|
|
1969
|
+
method: 'mqtt',
|
|
1993
1970
|
});
|
|
1994
1971
|
});
|
|
1995
1972
|
this.mqttClients[mqttIndex].on('error', (error) => {
|
|
@@ -2022,17 +1999,24 @@ export class Meta2d {
|
|
|
2022
1999
|
}
|
|
2023
2000
|
else if (net.protocol === 'jetLinks') {
|
|
2024
2001
|
if (this.jetLinksList.length) {
|
|
2025
|
-
this.jetLinksClient = new WebSocket(`${net.url}/${localStorage.getItem('X-Access-Token') ||
|
|
2002
|
+
this.jetLinksClient = new WebSocket(`${net.url}/${localStorage.getItem('X-Access-Token') ||
|
|
2003
|
+
getCookie('X-Access-Token') ||
|
|
2004
|
+
new URLSearchParams(location.search).get('X-Access-Token') ||
|
|
2005
|
+
''}`
|
|
2006
|
+
// 'ws://8.134.86.52:29000/api/messaging/961d8b395298d3ec3a021df70d6b6ca4'
|
|
2007
|
+
);
|
|
2026
2008
|
//消息接收
|
|
2027
2009
|
this.jetLinksClient.onmessage = (e) => {
|
|
2028
2010
|
const mess = JSON.parse(e.data);
|
|
2029
|
-
if (mess.payload &&
|
|
2011
|
+
if (mess.payload &&
|
|
2012
|
+
mess.payload.success &&
|
|
2013
|
+
mess.payload?.properties) {
|
|
2030
2014
|
const data = [];
|
|
2031
2015
|
for (let key in mess.payload.properties) {
|
|
2032
2016
|
if (!key.startsWith('_')) {
|
|
2033
2017
|
data.push({
|
|
2034
2018
|
id: `${mess.payload.headers.productId}#${mess.payload.deviceId}#${key}`,
|
|
2035
|
-
value: mess.payload.properties[key]
|
|
2019
|
+
value: mess.payload.properties[key],
|
|
2036
2020
|
});
|
|
2037
2021
|
}
|
|
2038
2022
|
}
|
|
@@ -2042,14 +2026,14 @@ export class Meta2d {
|
|
|
2042
2026
|
this.jetLinksClient.onopen = () => {
|
|
2043
2027
|
this.jetLinksList.forEach((item) => {
|
|
2044
2028
|
this.jetLinksClient.send(JSON.stringify({
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2029
|
+
type: 'sub',
|
|
2030
|
+
topic: `/device${item.topic}/message/property/report`,
|
|
2031
|
+
parameter: {
|
|
2032
|
+
deviceId: item.deviceId,
|
|
2033
|
+
properties: item.properties,
|
|
2034
|
+
history: 1,
|
|
2051
2035
|
},
|
|
2052
|
-
|
|
2036
|
+
id: item.topic + '-' + s8(),
|
|
2053
2037
|
}));
|
|
2054
2038
|
});
|
|
2055
2039
|
};
|
|
@@ -2102,12 +2086,15 @@ export class Meta2d {
|
|
|
2102
2086
|
async doSqlCode(type, dbid, sql) {
|
|
2103
2087
|
const res = await fetch(`/api/iot/data/sql/${type}`, {
|
|
2104
2088
|
method: 'POST',
|
|
2105
|
-
body: JSON.stringify({ dbid, sql
|
|
2089
|
+
body: JSON.stringify({ dbid, sql }),
|
|
2106
2090
|
});
|
|
2107
2091
|
if (res.ok) {
|
|
2108
2092
|
const data = await res.text();
|
|
2109
2093
|
if (data) {
|
|
2110
|
-
this.socketCallback(data, {
|
|
2094
|
+
this.socketCallback(data, {
|
|
2095
|
+
type: 'sql',
|
|
2096
|
+
url: `/api/iot/data/sql/${type}`,
|
|
2097
|
+
});
|
|
2111
2098
|
}
|
|
2112
2099
|
}
|
|
2113
2100
|
}
|
|
@@ -2242,7 +2229,7 @@ export class Meta2d {
|
|
|
2242
2229
|
if (value !== undefined) {
|
|
2243
2230
|
arr.push({
|
|
2244
2231
|
id: data.id,
|
|
2245
|
-
value
|
|
2232
|
+
value,
|
|
2246
2233
|
});
|
|
2247
2234
|
}
|
|
2248
2235
|
});
|
|
@@ -2310,20 +2297,19 @@ export class Meta2d {
|
|
|
2310
2297
|
delete this.store.pensNetwork[pen.id];
|
|
2311
2298
|
}
|
|
2312
2299
|
}
|
|
2313
|
-
getCookie(name) {
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
}
|
|
2300
|
+
// getCookie(name: string) {
|
|
2301
|
+
// let arr: RegExpMatchArray | null;
|
|
2302
|
+
// const reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
|
|
2303
|
+
// if ((arr = document.cookie.match(reg))) {
|
|
2304
|
+
// return decodeURIComponent(arr[2]);
|
|
2305
|
+
// } else {
|
|
2306
|
+
// return '';
|
|
2307
|
+
// }
|
|
2308
|
+
// }
|
|
2323
2309
|
//获取动态参数
|
|
2324
2310
|
getDynamicParam(key) {
|
|
2325
2311
|
let params = queryURLParams();
|
|
2326
|
-
let value = params[key] || localStorage[key] ||
|
|
2312
|
+
let value = params[key] || localStorage[key] || getCookie(key) || '';
|
|
2327
2313
|
return value;
|
|
2328
2314
|
}
|
|
2329
2315
|
onNetworkConnect(https) {
|
|
@@ -2443,7 +2429,7 @@ export class Meta2d {
|
|
|
2443
2429
|
type: context.type,
|
|
2444
2430
|
topic: context.topic,
|
|
2445
2431
|
url: context.url,
|
|
2446
|
-
method: context.method
|
|
2432
|
+
method: context.method,
|
|
2447
2433
|
});
|
|
2448
2434
|
if (!_message) {
|
|
2449
2435
|
return;
|
|
@@ -2617,10 +2603,9 @@ export class Meta2d {
|
|
|
2617
2603
|
binds.push({
|
|
2618
2604
|
dataId: key,
|
|
2619
2605
|
id: key,
|
|
2620
|
-
value: data[key]
|
|
2606
|
+
value: data[key],
|
|
2621
2607
|
});
|
|
2622
2608
|
}
|
|
2623
|
-
;
|
|
2624
2609
|
if (binds.length) {
|
|
2625
2610
|
this.setDatas(binds, {
|
|
2626
2611
|
render,
|
|
@@ -2720,7 +2705,7 @@ export class Meta2d {
|
|
|
2720
2705
|
}
|
|
2721
2706
|
break;
|
|
2722
2707
|
case 'click':
|
|
2723
|
-
if (this.store.data.locked && e.pen &&
|
|
2708
|
+
if (this.store.data.locked && e.pen && !e.pen.disabled) {
|
|
2724
2709
|
if (e.pen.switch) {
|
|
2725
2710
|
e.pen.checked = !e.pen.checked;
|
|
2726
2711
|
e.pen.calculative.checked = e.pen.checked;
|
|
@@ -2728,29 +2713,50 @@ export class Meta2d {
|
|
|
2728
2713
|
e.pen.calculative.radialGradient = undefined;
|
|
2729
2714
|
}
|
|
2730
2715
|
}
|
|
2731
|
-
e.pen &&
|
|
2732
|
-
|
|
2716
|
+
e.pen &&
|
|
2717
|
+
e.pen.onClick &&
|
|
2718
|
+
!e.pen.disabled &&
|
|
2719
|
+
e.pen.onClick(e.pen, this.canvas.mousePos);
|
|
2720
|
+
this.store.data.locked &&
|
|
2721
|
+
e.pen &&
|
|
2722
|
+
!e.pen.disabled &&
|
|
2723
|
+
this.doEvent(e.pen, eventName);
|
|
2733
2724
|
break;
|
|
2734
2725
|
case 'contextmenu':
|
|
2735
2726
|
e.pen &&
|
|
2736
|
-
e.pen.onContextmenu &&
|
|
2727
|
+
e.pen.onContextmenu &&
|
|
2728
|
+
!e.pen.disabled &&
|
|
2737
2729
|
e.pen.onContextmenu(e.pen, this.canvas.mousePos);
|
|
2738
|
-
this.store.data.locked &&
|
|
2730
|
+
this.store.data.locked &&
|
|
2731
|
+
e.pen &&
|
|
2732
|
+
!e.pen.disabled &&
|
|
2733
|
+
this.doEvent(e.pen, eventName);
|
|
2739
2734
|
break;
|
|
2740
2735
|
case 'mousedown':
|
|
2741
2736
|
e.pen &&
|
|
2742
|
-
e.pen.onMouseDown &&
|
|
2737
|
+
e.pen.onMouseDown &&
|
|
2738
|
+
!e.pen.disabled &&
|
|
2743
2739
|
e.pen.onMouseDown(e.pen, this.canvas.mousePos);
|
|
2744
|
-
this.store.data.locked &&
|
|
2740
|
+
this.store.data.locked &&
|
|
2741
|
+
e.pen &&
|
|
2742
|
+
!e.pen.disabled &&
|
|
2743
|
+
this.doEvent(e.pen, eventName);
|
|
2745
2744
|
break;
|
|
2746
2745
|
case 'mouseup':
|
|
2747
2746
|
e.pen &&
|
|
2748
|
-
e.pen.onMouseUp &&
|
|
2747
|
+
e.pen.onMouseUp &&
|
|
2748
|
+
!e.pen.disabled &&
|
|
2749
2749
|
e.pen.onMouseUp(e.pen, this.canvas.mousePos);
|
|
2750
|
-
this.store.data.locked &&
|
|
2750
|
+
this.store.data.locked &&
|
|
2751
|
+
e.pen &&
|
|
2752
|
+
!e.pen.disabled &&
|
|
2753
|
+
this.doEvent(e.pen, eventName);
|
|
2751
2754
|
break;
|
|
2752
2755
|
case 'dblclick':
|
|
2753
|
-
this.store.data.locked &&
|
|
2756
|
+
this.store.data.locked &&
|
|
2757
|
+
e.pen &&
|
|
2758
|
+
!e.pen.disabled &&
|
|
2759
|
+
this.doEvent(e.pen, eventName);
|
|
2754
2760
|
break;
|
|
2755
2761
|
case 'valueUpdate':
|
|
2756
2762
|
this.store.data.locked && this.doEvent(e, eventName);
|
|
@@ -2770,10 +2776,16 @@ export class Meta2d {
|
|
|
2770
2776
|
this.navigatorTo(e.params);
|
|
2771
2777
|
break;
|
|
2772
2778
|
case 'input':
|
|
2773
|
-
this.store.data.locked &&
|
|
2779
|
+
this.store.data.locked &&
|
|
2780
|
+
e &&
|
|
2781
|
+
!e.disabled &&
|
|
2782
|
+
this.doEvent(e, eventName);
|
|
2774
2783
|
break;
|
|
2775
2784
|
case 'change':
|
|
2776
|
-
this.store.data.locked &&
|
|
2785
|
+
this.store.data.locked &&
|
|
2786
|
+
e &&
|
|
2787
|
+
!e.disabled &&
|
|
2788
|
+
this.doEvent(e, eventName);
|
|
2777
2789
|
break;
|
|
2778
2790
|
}
|
|
2779
2791
|
this.doMessageEvent(eventName);
|
|
@@ -2893,7 +2905,7 @@ export class Meta2d {
|
|
|
2893
2905
|
pen.events?.forEach(async (event, index) => {
|
|
2894
2906
|
if (indexArr.includes(index)) {
|
|
2895
2907
|
if (event.confirm) {
|
|
2896
|
-
if (!await this.canvas.popconfirm.showModal(pen, this.canvas.mousePos, event.confirmTitle)) {
|
|
2908
|
+
if (!(await this.canvas.popconfirm.showModal(pen, this.canvas.mousePos, event.confirmTitle))) {
|
|
2897
2909
|
return;
|
|
2898
2910
|
}
|
|
2899
2911
|
}
|
|
@@ -3074,14 +3086,14 @@ export class Meta2d {
|
|
|
3074
3086
|
}
|
|
3075
3087
|
if (flag) {
|
|
3076
3088
|
item.event.actions.forEach((action) => {
|
|
3077
|
-
this.events[action.action](item.pen, action);
|
|
3089
|
+
this.events[action.action](item.pen, action, data);
|
|
3078
3090
|
});
|
|
3079
3091
|
}
|
|
3080
3092
|
});
|
|
3081
3093
|
}
|
|
3082
3094
|
}
|
|
3083
3095
|
doDataEvent = (datas) => {
|
|
3084
|
-
if (!
|
|
3096
|
+
if (!this.store.data.dataEvents?.length) {
|
|
3085
3097
|
return;
|
|
3086
3098
|
}
|
|
3087
3099
|
const data = datas.reduce((accumulator, { dataId, id, value }) => {
|
|
@@ -3304,7 +3316,8 @@ export class Meta2d {
|
|
|
3304
3316
|
const childRect = calcRelativeRect(pen.calculative.worldRect, parent.calculative.worldRect);
|
|
3305
3317
|
Object.assign(pen, childRect);
|
|
3306
3318
|
pen.locked = pen.lockedOnCombine ?? LockState.DisableMove;
|
|
3307
|
-
pen.locked =
|
|
3319
|
+
pen.locked =
|
|
3320
|
+
pen.interaction || isInteraction.includes(pen.name) ? 0 : pen.locked;
|
|
3308
3321
|
if (!oldPen) {
|
|
3309
3322
|
addPens.push(deepClone(pen, true));
|
|
3310
3323
|
}
|
|
@@ -3371,10 +3384,14 @@ export class Meta2d {
|
|
|
3371
3384
|
rect.y -= 10;
|
|
3372
3385
|
const ctx = new window.C2S(rect.width + 20, rect.height + 20);
|
|
3373
3386
|
ctx.textBaseline = 'middle';
|
|
3387
|
+
ctx.strokeStyle = getGlobalColor(this.store);
|
|
3374
3388
|
for (const pen of this.store.data.pens) {
|
|
3375
3389
|
if (pen.visible == false || !isShowChild(pen, this.store)) {
|
|
3376
3390
|
continue;
|
|
3377
3391
|
}
|
|
3392
|
+
if (pen.name === 'combine' && !pen.draw) {
|
|
3393
|
+
continue;
|
|
3394
|
+
}
|
|
3378
3395
|
renderPenRaw(ctx, pen, rect, true);
|
|
3379
3396
|
}
|
|
3380
3397
|
let mySerializedSVG = ctx.getSerializedSvg();
|
|
@@ -3491,9 +3508,14 @@ export class Meta2d {
|
|
|
3491
3508
|
pen.imageRatio = false;
|
|
3492
3509
|
}
|
|
3493
3510
|
}
|
|
3494
|
-
pen.calculative.worldRect.x =
|
|
3511
|
+
pen.calculative.worldRect.x =
|
|
3512
|
+
rect.x -
|
|
3513
|
+
wGap / 2 +
|
|
3514
|
+
left +
|
|
3515
|
+
(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
3516
|
pen.calculative.worldRect.width *= ratio;
|
|
3496
|
-
pen.calculative.worldRect.ex =
|
|
3517
|
+
pen.calculative.worldRect.ex =
|
|
3518
|
+
pen.calculative.worldRect.x + pen.calculative.worldRect.width;
|
|
3497
3519
|
pen.calculative.width = pen.calculative.worldRect.width;
|
|
3498
3520
|
pen.calculative.x = pen.calculative.worldRect.x;
|
|
3499
3521
|
pen.width = pen.calculative.worldRect.width;
|
|
@@ -3508,14 +3530,21 @@ export class Meta2d {
|
|
|
3508
3530
|
//左移
|
|
3509
3531
|
r = -r;
|
|
3510
3532
|
if (fit.leftValue) {
|
|
3511
|
-
r +=
|
|
3533
|
+
r +=
|
|
3534
|
+
Math.abs(fit.leftValue) < 1
|
|
3535
|
+
? fit.leftValue * this.canvas.width
|
|
3536
|
+
: fit.leftValue;
|
|
3512
3537
|
}
|
|
3513
3538
|
this.translatePens(pens, r, 0);
|
|
3514
3539
|
}
|
|
3515
3540
|
else if (fit.right) {
|
|
3516
3541
|
//右移
|
|
3517
3542
|
if (fit.rightValue) {
|
|
3518
|
-
r =
|
|
3543
|
+
r =
|
|
3544
|
+
r -
|
|
3545
|
+
(Math.abs(fit.rightValue) < 1
|
|
3546
|
+
? fit.rightValue * this.canvas.width
|
|
3547
|
+
: fit.rightValue);
|
|
3519
3548
|
}
|
|
3520
3549
|
this.translatePens(pens, r, 0);
|
|
3521
3550
|
}
|
|
@@ -3526,8 +3555,7 @@ export class Meta2d {
|
|
|
3526
3555
|
if (worldRect.width / this.store.data.scale > rect.width * 0.8) {
|
|
3527
3556
|
let bfW = worldRect.width;
|
|
3528
3557
|
pen.calculative.worldRect.x = worldRect.x - wGap / 2;
|
|
3529
|
-
pen.calculative.worldRect.width =
|
|
3530
|
-
worldRect.width + wGap;
|
|
3558
|
+
pen.calculative.worldRect.width = worldRect.width + wGap;
|
|
3531
3559
|
pen.calculative.worldRect.ex = worldRect.ex + wGap;
|
|
3532
3560
|
pen.operationalRect.x =
|
|
3533
3561
|
(pen.operationalRect.x * bfW) / pen.calculative.worldRect.width;
|
|
@@ -3561,7 +3589,8 @@ export class Meta2d {
|
|
|
3561
3589
|
top = 0;
|
|
3562
3590
|
}
|
|
3563
3591
|
if (bottom) {
|
|
3564
|
-
bottom =
|
|
3592
|
+
bottom =
|
|
3593
|
+
Math.abs(bottom) < 1 ? bottom * this.canvas.height : bottom;
|
|
3565
3594
|
}
|
|
3566
3595
|
else {
|
|
3567
3596
|
bottom = 0;
|
|
@@ -3573,9 +3602,14 @@ export class Meta2d {
|
|
|
3573
3602
|
pen.imageRatio = false;
|
|
3574
3603
|
}
|
|
3575
3604
|
}
|
|
3576
|
-
pen.calculative.worldRect.y =
|
|
3605
|
+
pen.calculative.worldRect.y =
|
|
3606
|
+
rect.y -
|
|
3607
|
+
hGap / 2 +
|
|
3608
|
+
top +
|
|
3609
|
+
(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
3610
|
pen.calculative.worldRect.height *= ratio;
|
|
3578
|
-
pen.calculative.worldRect.ey =
|
|
3611
|
+
pen.calculative.worldRect.ey =
|
|
3612
|
+
pen.calculative.worldRect.y + pen.calculative.worldRect.height;
|
|
3579
3613
|
pen.calculative.height = pen.calculative.worldRect.height;
|
|
3580
3614
|
pen.calculative.y = pen.calculative.worldRect.y;
|
|
3581
3615
|
pen.height = pen.calculative.worldRect.height;
|
|
@@ -3589,13 +3623,20 @@ export class Meta2d {
|
|
|
3589
3623
|
else if (fit.top) {
|
|
3590
3624
|
r = -r;
|
|
3591
3625
|
if (fit.topValue) {
|
|
3592
|
-
r +=
|
|
3626
|
+
r +=
|
|
3627
|
+
Math.abs(fit.topValue) < 1
|
|
3628
|
+
? fit.topValue * this.canvas.height
|
|
3629
|
+
: fit.topValue;
|
|
3593
3630
|
}
|
|
3594
3631
|
this.translatePens(pens, 0, r);
|
|
3595
3632
|
}
|
|
3596
3633
|
else if (fit.bottom) {
|
|
3597
3634
|
if (fit.bottomValue) {
|
|
3598
|
-
r =
|
|
3635
|
+
r =
|
|
3636
|
+
r -
|
|
3637
|
+
(Math.abs(fit.bottomValue) < 1
|
|
3638
|
+
? fit.bottomValue * this.canvas.height
|
|
3639
|
+
: fit.bottomValue);
|
|
3599
3640
|
}
|
|
3600
3641
|
this.translatePens(pens, 0, r);
|
|
3601
3642
|
}
|
|
@@ -3606,8 +3647,7 @@ export class Meta2d {
|
|
|
3606
3647
|
if (worldRect.height / this.store.data.scale > rect.height * 0.8) {
|
|
3607
3648
|
let bfH = worldRect.height;
|
|
3608
3649
|
pen.calculative.worldRect.y = worldRect.y - hGap / 2;
|
|
3609
|
-
pen.calculative.worldRect.height =
|
|
3610
|
-
worldRect.height + hGap;
|
|
3650
|
+
pen.calculative.worldRect.height = worldRect.height + hGap;
|
|
3611
3651
|
pen.calculative.worldRect.ey = worldRect.ey + hGap;
|
|
3612
3652
|
pen.operationalRect.y =
|
|
3613
3653
|
(pen.operationalRect.y * bfH) / pen.calculative.worldRect.width;
|
|
@@ -3622,6 +3662,7 @@ export class Meta2d {
|
|
|
3622
3662
|
}
|
|
3623
3663
|
});
|
|
3624
3664
|
}
|
|
3665
|
+
this.canvas.canvasTemplate.fit = true;
|
|
3625
3666
|
this.canvas.canvasTemplate.init();
|
|
3626
3667
|
this.canvas.canvasImage.init();
|
|
3627
3668
|
this.canvas.canvasImageBottom.init();
|
|
@@ -3934,10 +3975,11 @@ export class Meta2d {
|
|
|
3934
3975
|
const firstPen = pens[0];
|
|
3935
3976
|
formatAttrs.forEach((attr) => {
|
|
3936
3977
|
attrs[attr] =
|
|
3937
|
-
firstPen[attr] !== undefined
|
|
3938
|
-
|
|
3978
|
+
firstPen[attr] !== undefined
|
|
3979
|
+
? firstPen[attr]
|
|
3980
|
+
: this.store.options.defaultFormat[attr] ||
|
|
3939
3981
|
this.store.data[attr] ||
|
|
3940
|
-
this.store.options[attr]
|
|
3982
|
+
this.store.options[attr];
|
|
3941
3983
|
});
|
|
3942
3984
|
}
|
|
3943
3985
|
else {
|
|
@@ -4941,7 +4983,7 @@ export class Meta2d {
|
|
|
4941
4983
|
pen.locked = pen.lockedOnCombine ?? LockState.DisableMove;
|
|
4942
4984
|
// pen.type = PenType.Node;
|
|
4943
4985
|
});
|
|
4944
|
-
return
|
|
4986
|
+
return oneIsParent || parents.length === 1
|
|
4945
4987
|
? deepClone(components)
|
|
4946
4988
|
: deepClone([parent, ...components]);
|
|
4947
4989
|
}
|
|
@@ -4954,10 +4996,14 @@ export class Meta2d {
|
|
|
4954
4996
|
if (!pen.tag && !pen.name && !pen.id)
|
|
4955
4997
|
return;
|
|
4956
4998
|
let type;
|
|
4957
|
-
pen.id
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4999
|
+
pen.id
|
|
5000
|
+
? (type = 'id')
|
|
5001
|
+
: pen.tag
|
|
5002
|
+
? (type = 'tag')
|
|
5003
|
+
: pen.name
|
|
5004
|
+
? (type = 'name')
|
|
5005
|
+
: '';
|
|
5006
|
+
plugins.forEach((pluginConfig) => {
|
|
4961
5007
|
let plugin = pluginConfig.plugin;
|
|
4962
5008
|
let option = pluginConfig.options;
|
|
4963
5009
|
if (!plugin)
|
|
@@ -4980,7 +5026,7 @@ export class Meta2d {
|
|
|
4980
5026
|
else {
|
|
4981
5027
|
this.penPluginMap.get(plugin).push({
|
|
4982
5028
|
[type]: pen[type],
|
|
4983
|
-
option
|
|
5029
|
+
option,
|
|
4984
5030
|
});
|
|
4985
5031
|
}
|
|
4986
5032
|
}
|
|
@@ -4989,16 +5035,20 @@ export class Meta2d {
|
|
|
4989
5035
|
}
|
|
4990
5036
|
uninstallPenPlugins(pen, plugins) {
|
|
4991
5037
|
let type;
|
|
4992
|
-
pen.id
|
|
4993
|
-
|
|
4994
|
-
|
|
5038
|
+
pen.id
|
|
5039
|
+
? (type = 'id')
|
|
5040
|
+
: pen.tag
|
|
5041
|
+
? (type = 'tag')
|
|
5042
|
+
: pen.name
|
|
5043
|
+
? (type = 'name')
|
|
5044
|
+
: '';
|
|
4995
5045
|
if (!type)
|
|
4996
5046
|
return;
|
|
4997
|
-
plugins.forEach(pluginConfig => {
|
|
5047
|
+
plugins.forEach((pluginConfig) => {
|
|
4998
5048
|
let plugin = pluginConfig.plugin;
|
|
4999
5049
|
plugin.uninstall(pen, pluginConfig.options);
|
|
5000
5050
|
let mapList = this.penPluginMap.get(plugin);
|
|
5001
|
-
let op = mapList.findIndex(i => i[type] === pen[type]);
|
|
5051
|
+
let op = mapList.findIndex((i) => i[type] === pen[type]);
|
|
5002
5052
|
if (op !== -1) {
|
|
5003
5053
|
mapList.splice(op, 1);
|
|
5004
5054
|
// TODO 在运行时 插件卸载后是否需要移除?
|