From 7e456340dc74e60a5ef12738263619a7515fe5e6 Mon Sep 17 00:00:00 2001 From: fangxiang Date: Thu, 23 Dec 2021 09:28:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=9D=99=E9=9F=B3=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ClientConnection.ts | 20 ++++++++ src/components/Window.vue | 28 ++++++++--- src/entities/MultimediaWindowEntity.ts | 13 ----- src/entities/WSProtocol.ts | 32 +++++++++++++ .../WindowOtherStateChangeNotifyEntity.ts | 1 + src/i18n/zh-CN/index.ts | 1 + src/pages/WallPage.vue | 48 ++++++++++++------- 7 files changed, 108 insertions(+), 35 deletions(-) diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index a4c5ab8..7d851ee 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -635,6 +635,26 @@ export default class ClientConnection { } } + public async unmuteWindow(window_id: number) { + try { + return await this.doRpc( + new Protocol.UnMuteWindowRequestEntity(window_id, 0) + ); + } catch (e) { + console.error(e); + } + } + + public async muteWindow(window_id: number) { + try { + return await this.doRpc( + new Protocol.MuteWindowRequestEntity(window_id, 0) + ); + } catch (e) { + console.error(e); + } + } + public restartDevice(delay_ms?: number) { this.ws?.send( JSON.stringify(new Protocol.RestartDeviceRequestEntity(delay_ms)) diff --git a/src/components/Window.vue b/src/components/Window.vue index 98df7ed..10250fb 100644 --- a/src/components/Window.vue +++ b/src/components/Window.vue @@ -19,7 +19,7 @@ v-close-popup :disable="$props.disable" @click="$emit('edit_volume', $props.window.window_id)" - v-if="!$props.window.muted" + v-if="!$props.window.muted && is_audo_player_window" > {{ $t("edit volume") }} @@ -28,8 +28,11 @@ v-close-popup :disable="$props.disable" @click="$emit('mute_unmute', $props.window.window_id)" + v-if="is_audo_player_window" > - {{ $t("mute") }} + + {{ $props.window.muted ? $t("unmute") : $t("mute") }} + -
- +
+ {{ signal_source.name }} + +
+ signal_source.value.window_type == "EwindowType::Multimedia" || + signal_source.value.window_type == "EwindowType::HdmiIn" + ); + reload_signal_source(); watch(props, (a, b) => { reload_signal_source(); @@ -346,7 +361,7 @@ export default defineComponent({ }); watch( - () => props.window.window_state, + () => props.window.focus, (newValue, oldValue) => { if (newValue) { let old = selected.value; @@ -379,6 +394,7 @@ export default defineComponent({ can_move, can_resize, flags, + is_audo_player_window, onClick(evt: PointerEvent) { if (selected.value != true) { diff --git a/src/entities/MultimediaWindowEntity.ts b/src/entities/MultimediaWindowEntity.ts index d93410b..c4acdeb 100644 --- a/src/entities/MultimediaWindowEntity.ts +++ b/src/entities/MultimediaWindowEntity.ts @@ -2,18 +2,6 @@ import BaseEntity from "./BaseEntity"; import { SignalSourceEntity } from "./SignalSourceEntity"; import { Protocol } from "./WSProtocol"; -export class WindowStates { - playing = false; - focus = false; - muted = false; - - constructor(playing?: boolean, focus?: boolean, muted?: boolean) { - this.playing = playing ?? false; - this.focus = focus ?? false; - this.muted = muted ?? false; - } -} - export class MultimediaWindowEntity extends BaseEntity { x: number = 0; y: number = 0; @@ -21,7 +9,6 @@ export class MultimediaWindowEntity extends BaseEntity { height: number = 0; signal_source_table_uuid: string = ""; - window_state = new WindowStates(); volume: number = 80; muted: boolean = false; paused: boolean = false; diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index 3778824..55a3c48 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -224,6 +224,14 @@ export namespace Protocol { return Commands.PROTOCOL_PREFIX + "SetWindowVolume"; } + public static get kMuteWidow() { + return Commands.PROTOCOL_PREFIX + "MuteWidow"; + } + + public static get kUnMuteWidow() { + return Commands.PROTOCOL_PREFIX + "UnMuteWidow"; + } + static _all_commands = new Set([ Commands.kUnKnowCommand, Commands.kSearchDevice, @@ -275,6 +283,8 @@ export namespace Protocol { Commands.kRpcSetOutputBoardSetting, Commands.kRpcGetOutputBoardSetting, Commands.kSetWindowVolume, + Commands.kMuteWidow, + Commands.kUnMuteWidow, ]); public static get AllCommands() { @@ -1351,4 +1361,26 @@ export namespace Protocol { this.volume = volume; } } + + export class MuteWindowRequestEntity extends Protocol.PacketEntity { + window_id: number; + + constructor(window_id: number, rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kMuteWidow; + this.window_id = window_id; + } + } + + export class UnMuteWindowRequestEntity extends Protocol.PacketEntity { + window_id: number; + + constructor(window_id: number, rcp_id?: number) { + super(); + this.rpc_id = rcp_id ?? 0; + this.command = Protocol.Commands.kUnMuteWidow; + this.window_id = window_id; + } + } } diff --git a/src/entities/WindowOtherStateChangeNotifyEntity.ts b/src/entities/WindowOtherStateChangeNotifyEntity.ts index 1a66f67..13e084f 100644 --- a/src/entities/WindowOtherStateChangeNotifyEntity.ts +++ b/src/entities/WindowOtherStateChangeNotifyEntity.ts @@ -5,4 +5,5 @@ export default class WindowOtherStateChangeNotifyEntity extends Protocol.PacketE playing = false; focus = false; muted = false; + volume = 80; } diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index 8e3e5b0..becfe0d 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -265,6 +265,7 @@ export default { "重要图形参数已更改,需要重启后生效,是否重启", "output audio card": "输出声卡", muted: "静音", + unmute: "取消静音", "the system will reboot after the setup is complete": "系统将在设置完成后重启", "restart command send": "重启指令发送", diff --git a/src/pages/WallPage.vue b/src/pages/WallPage.vue index bb65d6f..c587880 100644 --- a/src/pages/WallPage.vue +++ b/src/pages/WallPage.vue @@ -115,10 +115,7 @@ import Window from "src/components/Window.vue"; import { useI18n } from "vue-i18n"; import { useStore } from "src/store"; import EventBus, { EventNamesDefine } from "src/common/EventBus"; -import { - WindowOpenNotifyEntity, - WindowStates, -} from "src/entities/MultimediaWindowEntity"; +import { WindowOpenNotifyEntity } from "src/entities/MultimediaWindowEntity"; import WindowOtherStateChangeNotifyEntity from "src/entities/WindowOtherStateChangeNotifyEntity"; import { useQuasar } from "quasar"; import { NotifyMessage } from "src/common/ClientConnection"; @@ -285,16 +282,30 @@ export default defineComponent({ (item) => item.window_id == temp.window_id ); if (window) { - window.window_state; // - $store.commit("setWindowProperty", { - window, - property_name: "window_state", - value: new WindowStates( - temp.playing, - temp.focus, - temp.muted - ), - }); + console.log(temp); + console.log(window); + $store.commit("setWindowPropertys", [ + { + window, + property_name: "playing", + value: temp.playing, + }, + { + window, + property_name: "focus", + value: temp.focus, + }, + { + window, + property_name: "muted", + value: temp.muted, + }, + { + window, + property_name: "volume", + value: temp.volume, + }, + ]); } } } @@ -535,12 +546,17 @@ export default defineComponent({ } }, mute_unmute(window_id: number) { - console.log(windows.value); - const window = windows.value.find( (element) => element && element.window_id == window_id ); if (window) { + if (window.muted) { + GlobalData.getInstance() + .getCurrentClient() + ?.unmuteWindow(window_id); + } else { + GlobalData.getInstance().getCurrentClient()?.muteWindow(window_id); + } } }, };