diff --git a/src/components/ControlPanelDialog.vue b/src/components/ControlPanelDialog.vue index 7a4c3a0..07bd6f9 100644 --- a/src/components/ControlPanelDialog.vue +++ b/src/components/ControlPanelDialog.vue @@ -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); diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 610c260..b572001 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -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( diff --git a/src/pages/WallPage.vue b/src/pages/WallPage.vue index 701ac58..2a05283 100644 --- a/src/pages/WallPage.vue +++ b/src/pages/WallPage.vue @@ -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 {} }