魔墙:添加更新通知

This commit is contained in:
miao 2023-02-08 09:08:01 +08:00
parent b58ad2a4fd
commit 71bb5d58e7
3 changed files with 70 additions and 83 deletions

View File

@ -1333,6 +1333,67 @@ export default defineComponent({
});
}
});
const refresh_magic = (a: any) => {
let monitorList: any = [];
$store.commit("setShowMonitorList", monitorList);
if (a) {
a.forEach((element: any) => {
let item: test_monitor2 = new test_monitor2(0, 0, 0);
item.h = element.h;
item.w = element.w;
item.currentx = element.lt.x;
item.currenty = element.lt.y;
item.angle = element.angle;
item.id = element.index;
if ($store.state.show_monitor_list.length == 0) {
monitorList.push(item);
$store.commit("setShowMonitorList", monitorList);
} else {
let flag = false;
$store.state.show_monitor_list.forEach((ele: any) => {
if (element.index == ele.id) {
flag = true;
}
});
if (!flag) {
monitorList.push(item);
$store.commit("setShowMonitorList", monitorList);
}
}
});
}
const wall_dom = wall.value;
if (a && wall_dom) {
test_monitor_wall.value = [];
a.forEach((element: any) => {
let item: test_monitor = new test_monitor(0, "0", 0, 0, 0);
extend(true, item, test_monitor_list.value[element.index]);
let sizeh = wall_dom.offsetHeight / element.background_h;
let sizew = wall_dom.offsetWidth / element.background_w;
item.currentx = element.lt.x * wall_dom.offsetWidth;
item.currenty = element.lt.y * wall_dom.offsetHeight;
percenter.value = parseFloat(element.percenter.toString());
last_percenter.value = percenter.value;
item.InitialH = element.initial_h * sizeh;
item.InitialW = element.initial_w * sizew;
item.h = item.InitialH * percenter.value;
item.w = item.InitialW * percenter.value;
item.resizew = item.InitialW / wall_dom.offsetWidth;
item.resizeh = item.InitialH / wall_dom.offsetHeight;
item.centerx = Math.floor(item.currentx + item.w / 2);
item.centery = Math.floor(item.currenty + item.h / 2);
item.angle = element.angle;
item.isShow = true;
test_monitor_wall.value.push(JSON.parse(JSON.stringify(item)));
last_wall.value.push(JSON.parse(JSON.stringify(item)));
test_monitor_list.value.forEach((ele) => {
if (element.index == ele.id) {
ele.isHide = true;
}
});
});
}
};
EventBus.getInstance().on(
EventNamesDefine.NotifyMessage,
(notify: NotifyMessage) => {
@ -1348,45 +1409,16 @@ export default defineComponent({
}
}
break;
case Protocol.Commands.kRpcSetMagicWallConfig:
{
let temp = JSON.parse(
notify.data
) as Protocol.MagicWallNotifyEntity;
// if (temp) {
// //
// const a = temp?.config.windows;
// let monitorList: any = [];
// if (a) {
// a.forEach((element) => {
// let item: test_monitor2 = new test_monitor2(0, 0, 0);
// item.h = element.h;
// item.w = element.w;
// item.currentx = element.lt.x;
// item.currenty = element.lt.y;
// item.angle = element.angle;
// item.id = element.index;
// if ($store.state.show_monitor_list.length == 0) {
// monitorList.push(item);
// $store.commit("setShowMonitorList", monitorList);
// } else {
// let flag = false;
// $store.state.show_monitor_list.forEach((ele: any) => {
// if (element.index == ele.id) {
// flag = true;
// }
// });
// if (!flag) {
// monitorList.push(item);
// $store.commit("setShowMonitorList", monitorList);
// }
// }
// });
// }
// }
case Protocol.Commands.kSetApplicationConfig: {
let temp = JSON.parse(
notify.data
) as Protocol.SetApplicationConfigRequestEntity;
if (temp.key == "magic_wall_config") {
const a = JSON.parse(temp.value).windows;
refresh_magic(a);
}
break;
}
}
} catch (e) {
console.error(e);

View File

@ -3209,14 +3209,7 @@ export namespace Protocol {
super.flag = PacketEntity.FLAG_NOTIFY;
}
}
export class MagicWallNotifyEntity extends PacketEntity {
config: MagicWallConfig = new MagicWallConfig();
constructor() {
super();
this.command = Commands.kRpcSetMagicWallConfig;
super.flag = PacketEntity.FLAG_NOTIFY;
}
}
export class RpcTestARequestEntity extends PacketEntity {
constructor(

View File

@ -984,45 +984,7 @@ export default defineComponent({
}
}
break;
case Protocol.Commands.kRpcSetMagicWallConfig:
{
let temp = JSON.parse(
notify.data
) as Protocol.MagicWallNotifyEntity;
if (temp) {
//
const a = temp?.config.windows;
let monitorList: any = [];
if (a) {
a.forEach((element) => {
let item: test_monitor = new test_monitor(0, 0, 0);
item.h = element.h;
item.w = element.w;
item.currentx = element.lt.x;
item.currenty = element.lt.y;
item.angle = element.angle;
item.id = element.index;
if ($store.state.show_monitor_list.length == 0) {
monitorList.push(item);
$store.commit("setShowMonitorList", monitorList);
} else {
let flag = false;
$store.state.show_monitor_list.forEach((ele: any) => {
if (element.index == ele.id) {
flag = true;
}
});
if (!flag) {
monitorList.push(item);
$store.commit("setShowMonitorList", monitorList);
}
}
});
}
}
}
break;
}
} catch {}
}