Skip to content

Commit

Permalink
Merge branch 'main' of github.com:le5le-com/meta2d.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Wind-Breaker1 committed Dec 6, 2024
2 parents 7803b2c + bf526cf commit a2d3195
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
21 changes: 12 additions & 9 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,13 +784,13 @@ export class Meta2d {
console.info('http消息发送成功');
}
} else if (network.protocol === 'mqtt') {
const clients = this.mqttClients.filter(
const clients = this.mqttClients?.filter(
(client) => (client.options as any).href === network.url
);
if (clients && clients.length) {
if (clients[0].connected) {
network.topics.split(',').forEach((topic) => {
clients[0].publish(topic, value);
clients[0].publish(topic, JSON.stringify(value));
});
}
} else {
Expand All @@ -799,18 +799,20 @@ export class Meta2d {
mqttClient.on('connect', () => {
console.info('mqtt连接成功');
network.topics.split(',').forEach((topic) => {
mqttClient.publish(topic, value);
mqttClient?.end();
mqttClient.publish(topic, JSON.stringify(value));
setTimeout(() => {
mqttClient?.end();
},1000);
});
});
}
} else if (network.protocol === 'websocket') {
const websockets = this.websockets.filter(
const websockets = this.websockets?.filter(
(socket) => socket.url === network.url
);
if (websockets && websockets.length) {
if (websockets[0].readyState === 1) {
websockets[0].send(value);
websockets[0].send(JSON.stringify(value));
}
} else {
//临时建立连接
Expand All @@ -820,7 +822,7 @@ export class Meta2d {
);
websocket.onopen = function () {
console.info('websocket连接成功');
websocket.send(value);
websocket.send(JSON.stringify(value));
setTimeout(() => {
websocket.close();
}, 100);
Expand Down Expand Up @@ -1598,8 +1600,9 @@ export class Meta2d {
* 组合
* @param pens 组合的画笔们
* @param showChild 组合后展示第几个孩子
* @param active 是否激活组合后的画笔
*/
combine(pens: Pen[] = this.store.active, showChild?: number): any {
combine(pens: Pen[] = this.store.active, showChild?: number, active = true): any {
if (!pens || !pens.length) {
return;
}
Expand Down Expand Up @@ -1668,7 +1671,7 @@ export class Meta2d {
//将组合后的父节点置底
this.store.data.pens.splice(minIndex, 0, parent);
this.store.data.pens.pop();
this.canvas.active([parent]);
active && this.canvas.active([parent]);
let step = 1;
// if (!oneIsParent) {
// step = 2;
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/diagrams/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function video(pen: Pen) {
media.src = pen.video;
} else if (pen.audio) {
media = document.createElement('audio');
media.controls = (pen as any).controls;
media.src = pen.audio;
}
media.loop = pen.playLoop;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class Dialog {
if(rect) {
this.dialog.style.width = rect.width?(rect.width + 'px'): '80%'
this.dialog.style.height = rect.height?(rect.height + 'px'): '420px';
this.dialog.style.top = rect.y?(rect.y + 'px'): '15vh';
this.dialog.style.top = rect.y?(rect.y + 'px'):(rect.height? `calc( 50% - ${rect.height/2}px )` : '15vh');
this.dialog.style.left = rect.x? (rect.x + 'px'): `calc( 50% - ${rect.width? rect.width/2+'px': '40%'} )`;
}
if(isIframe&&data){
Expand Down

0 comments on commit a2d3195

Please sign in to comment.