diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 3383fde..4a1913d 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -183,10 +183,17 @@ export default class ClientConnection { this.rpc_map.delete(packet.rpc_id); } } else { - EventBus.getInstance().emit(EventNamesDefine.ResponseMessage, { - packet: packet, - data: ev.data, - }); + EventBus.getInstance().emit( + packet.flag == Protocol.PacketEntity.FLAG_NOTIFY + ? EventNamesDefine.NotifyMessage + : packet.flag == Protocol.PacketEntity.FLAG_RESPONSE + ? EventNamesDefine.ResponseMessage + : EventNamesDefine.UnKnow, + { + packet: packet, + data: ev.data, + } + ); } } } else { diff --git a/src/common/EventBus.ts b/src/common/EventBus.ts index 7538a1c..0d572ee 100644 --- a/src/common/EventBus.ts +++ b/src/common/EventBus.ts @@ -17,10 +17,12 @@ export default class EventBus extends EventEmitter { } export namespace EventNamesDefine { + export const UnKnow = "onUnKnow"; export const UnSelectAllWindows = "onUnSelectAllWindows"; export const UnFocusAllWindows = "onUnFocusAllWindows"; export const WindowResize = "onWindowResize"; export const ResponseMessage = "onResponseData"; + export const NotifyMessage = "onNotifyMessage"; export const WebSocketClose = "onWebSocketClose"; export const WebSocketError = "onWebSocketError"; export const WebSocketConnected = "onWebSocketConnected"; diff --git a/src/components/SignalSourceDialog.vue b/src/components/SignalSourceDialog.vue index 8fa542f..9a327f8 100644 --- a/src/components/SignalSourceDialog.vue +++ b/src/components/SignalSourceDialog.vue @@ -314,7 +314,7 @@ export default defineComponent({ value: "EwindowType::Multimedia", }, { - label: $t.t("web"), + label: $t.t("Web"), value: "EwindowType::Web", }, { @@ -350,23 +350,6 @@ export default defineComponent({ } ); - const setItemData = (new_item_data?: SignalSourceEntity) => { - if (!new_item_data) { - new_item_data = new SignalSourceEntity(); - } - - item_data.uuid = new_item_data.uuid; - item_data.base_note = new_item_data.base_note; - item_data.name = new_item_data.name; - item_data.window_type = new_item_data.window_type; - item_data.media_url = new_item_data.media_url; - item_data.user_name = new_item_data.user_name; - item_data.password = new_item_data.password; - item_data.ext_data = new_item_data.ext_data; - item_data.group_uuid = new_item_data.group_uuid; - item_data.system_default = new_item_data.system_default; - }; - const setMediaUrlLabel = (value: string) => { switch (value) { case "EwindowType::Web": @@ -433,9 +416,16 @@ export default defineComponent({ if (options) { type.value = options.type ?? 1; if (options.data && options.data.item_data) { - setItemData(JSON.parse(JSON.stringify(options.data.item_data))); + SignalSourceEntity.copy( + item_data, + JSON.parse(JSON.stringify(options.data.item_data)) + ); + } + if (type.value == 2) { + selected.value = item_data.group_uuid; + } else { + selected.value = options.parent_node ?? ""; } - selected.value = item_data.group_uuid; } if (item_data) { setMediaUrlLabel(item_data.window_type); @@ -445,7 +435,7 @@ export default defineComponent({ resetData() { loading.value = false; selected.value = null; - setItemData(); + SignalSourceEntity.copy(item_data); type.value = 1; }, treeNodesFilter(node: any, filter: any) { diff --git a/src/entities/SignalSourceEntity.ts b/src/entities/SignalSourceEntity.ts index 4bb46f3..953adfc 100644 --- a/src/entities/SignalSourceEntity.ts +++ b/src/entities/SignalSourceEntity.ts @@ -9,6 +9,23 @@ export class SignalSourceEntity extends BaseEntity { ext_data: string = ""; group_uuid = ""; system_default: boolean = false; + + public static copy(dest: SignalSourceEntity, src?: SignalSourceEntity) { + if (!src) { + src = new SignalSourceEntity(); + } + + dest.uuid = src.uuid; + dest.base_note = src.base_note; + dest.name = src.name; + dest.window_type = src.window_type; + dest.media_url = src.media_url; + dest.user_name = src.user_name; + dest.password = src.password; + dest.ext_data = src.ext_data; + dest.group_uuid = src.group_uuid; + dest.system_default = src.system_default; + } } export class SignalSourceTreeItemEntity { diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 26b7f02..b1cedcf 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -446,4 +446,36 @@ export namespace Protocol { this.command = Protocol.Commands.kRpcDeleteSignalSource; } } + + export class SignalSourceGroupEntity extends Protocol.PacketEntity { + parent_uuid: string = ""; + name: string = ""; + system_default: boolean = false; + } + + export class SignalSourceAddNotifyEntity extends Protocol.PacketEntity { + signal_source: SignalSourceEntity = new SignalSourceEntity(); + } + + export class SignalSourceDeleteNotifyEntity extends Protocol.PacketEntity { + uuid: string = ""; + } + + export class SignalSourceEditNotifyEntity extends Protocol.PacketEntity { + signal_source: SignalSourceEntity = new SignalSourceEntity(); + } + + export class SignalSourceGroupAddNotifyEntity extends Protocol.PacketEntity { + signal_source_group: SignalSourceGroupEntity = + new SignalSourceGroupEntity(); + } + + export class SignalSourceGroupDeleteNotifyEntity extends Protocol.PacketEntity { + uuid: string = ""; + } + + export class SignalSourceGroupEditNotifyEntity extends Protocol.PacketEntity { + signal_source_group: SignalSourceGroupEntity = + new SignalSourceGroupEntity(); + } } diff --git a/src/pages/LeftToolBar.vue b/src/pages/LeftToolBar.vue index 1091740..328c962 100644 --- a/src/pages/LeftToolBar.vue +++ b/src/pages/LeftToolBar.vue @@ -131,6 +131,8 @@ import { Common } from "src/common/Common"; import GlobalData from "src/common/GlobalData"; import { useQuasar } from "quasar"; import { useI18n } from "vue-i18n"; +import EventBus, { EventNamesDefine } from "src/common/EventBus"; +import { Protocol } from "src/entities/WSProtocol"; export default defineComponent({ name: "PageLeftToolBar", @@ -156,8 +158,104 @@ export default defineComponent({ tree.value?.setExpanded("", true); }); + interface _ResponseMessage { + packet: Protocol.PacketEntity; + data: string; + } + EventBus.getInstance().on( + EventNamesDefine.NotifyMessage, + (response: _ResponseMessage) => { + if (response) { + switch (response.packet.command) { + case Protocol.Commands.kRpcAddSignalSource: + { + const temp = JSON.parse( + response.data + ) as Protocol.SignalSourceAddNotifyEntity; + if (temp) { + GlobalData.getInstance().signal_source.push( + temp.signal_source + ); + $store.commit("addSignalSourceTreeItem", { + parent: temp.signal_source.group_uuid, + is_group: false, + item_data: temp.signal_source, + }); + } + } + break; + case Protocol.Commands.kRpcDeleteSignalSource: + { + const temp = JSON.parse( + response.data + ) as Protocol.SignalSourceDeleteNotifyEntity; + if (temp) { + $store.commit("deleteSignalSourceTreeItem", { + is_group: false, + uuid: temp.uuid, + }); + } + } + break; + case Protocol.Commands.kRpcEditSignalSource: + { + const temp = JSON.parse( + response.data + ) as Protocol.SignalSourceEditNotifyEntity; + if (temp) { + $store.commit("setSignalSourceTreeItem", { + is_group: false, + item_data: temp.signal_source, + }); + } + } + break; + case Protocol.Commands.kRpcAddSignalSourceGroup: + { + const temp = JSON.parse( + response.data + ) as Protocol.SignalSourceGroupAddNotifyEntity; + if (temp) { + $store.commit("addSignalSourceTreeItem", { + parent: temp.signal_source_group.parent_uuid, + is_group: true, + item_data: temp.signal_source_group, + }); + } + } + break; + case Protocol.Commands.kRpcDeleteSignalSourceGroup: + { + const temp = JSON.parse( + response.data + ) as Protocol.SignalSourceGroupDeleteNotifyEntity; + if (temp) { + $store.commit("deleteSignalSourceTreeItem", { + is_group: true, + uuid: temp.uuid, + }); + } + } + break; + case Protocol.Commands.kRpcEditSignalSourceGroup: + { + const temp = JSON.parse( + response.data + ) as Protocol.SignalSourceGroupEditNotifyEntity; + if (temp) { + $store.commit("setSignalSourceTreeItem", { + is_group: true, + item_data: temp.signal_source_group, + }); + } + } + break; + } + } + } + ); + return { - est() {}, tree, tree_nodes, loga(a: any) { diff --git a/src/pages/WallPage.vue b/src/pages/WallPage.vue index ceecf94..c13abfa 100644 --- a/src/pages/WallPage.vue +++ b/src/pages/WallPage.vue @@ -29,10 +29,7 @@ width: item.width / wall_width_scaler + 'px', height: item.height / wall_height_scaler + 'px', }" - > - {{ wall_height_scaler }} - {{ wall_width_scaler }} - + />