From e03bb2515bc133424e66f8e1e2343f4393a89fff Mon Sep 17 00:00:00 2001 From: fangxiang Date: Wed, 25 May 2022 18:21:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E6=9C=BA=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E3=80=82=E4=B8=8D=E5=8F=91=E9=80=81=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E7=9B=B8=E5=85=B3=E6=B6=88=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ClientConnection.ts | 10 ++++++ src/common/Initializer.ts | 23 +++++++++--- src/common/RemoteDataExangeProcesser.ts | 47 +++++++++++++++---------- src/components/ModeTree.vue | 3 ++ src/components/PlanTree.vue | 3 ++ src/entities/WSProtocol.ts | 24 +++++++++++++ src/i18n/zh-CN/index.ts | 1 + src/pad/ContentWall.vue | 13 +++++++ src/pages/WallPage.vue | 15 ++++++-- src/store/index.ts | 5 +++ 10 files changed, 118 insertions(+), 26 deletions(-) diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 01a57ba..e77a695 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -1074,6 +1074,16 @@ export default class ClientConnection { } } + public async getPowerState() { + try { + return await this.doRpc( + new Protocol.GetPowerStateRequestEntity() + ); + } catch (e) { + console.error(e); + } + } + public destory() { if (this.ws) { this.ws.onclose = null; diff --git a/src/common/Initializer.ts b/src/common/Initializer.ts index 09c9781..e99cf34 100644 --- a/src/common/Initializer.ts +++ b/src/common/Initializer.ts @@ -165,6 +165,9 @@ export default class Initializer { } async initialize() { + const options = this.options; + const $store = options.$store; + const global_data = GlobalData.getInstance(); let client = global_data.getCurrentClient(); if (client) { @@ -172,18 +175,28 @@ export default class Initializer { await Common.waitFor(100); } + await this.getApplicationConfig(); + // get device attribute { - await this.getApplicationConfig(); GlobalData.getInstance() .getCurrentClient() ?.getDeviceAttribute() .then((response) => { if (response && typeof response.attribute != "undefined") { - this.options.$store.commit( - "setDeviceAttribute", - response.attribute - ); + $store.commit("setDeviceAttribute", response.attribute); + } + }); + } + + // get power state + { + GlobalData.getInstance() + .getCurrentClient() + ?.getPowerState() + .then((response) => { + if (response) { + $store.commit("setPowerState", response.is_power_on); } }); } diff --git a/src/common/RemoteDataExangeProcesser.ts b/src/common/RemoteDataExangeProcesser.ts index 7a909ea..ebbd682 100644 --- a/src/common/RemoteDataExangeProcesser.ts +++ b/src/common/RemoteDataExangeProcesser.ts @@ -48,24 +48,35 @@ export default class RemoteDataExangeProcesser { if (temp) { let global_data = GlobalData.getInstance(); if (global_data && global_data.applicationConfig) { - if (temp.key == "registered") { - global_data.applicationConfig.registered = JSON.parse( - temp.value - ); - } else { - (global_data.applicationConfig)[temp.key] = temp.value; - $store.commit( - "setWallCol", - global_data.applicationConfig.wall_col - ); - $store.commit( - "setWallRow", - global_data.applicationConfig.wall_row - ); - $store.commit( - "setPowerOnPlan", - global_data.applicationConfig.power_on_plan - ); + switch (temp.key) { + case "power_state": + $store.commit("setPowerState", temp.value == "on"); + break; + case "registered": + { + global_data.applicationConfig.registered = JSON.parse( + temp.value + ); + } + break; + default: + { + (global_data.applicationConfig)[temp.key] = + temp.value; + $store.commit( + "setWallCol", + global_data.applicationConfig.wall_col + ); + $store.commit( + "setWallRow", + global_data.applicationConfig.wall_row + ); + $store.commit( + "setPowerOnPlan", + global_data.applicationConfig.power_on_plan + ); + } + break; } } } diff --git a/src/components/ModeTree.vue b/src/components/ModeTree.vue index 37c176a..4bb3347 100644 --- a/src/components/ModeTree.vue +++ b/src/components/ModeTree.vue @@ -11,6 +11,9 @@ clickable @dblclick=" (evt) => { + if (!$store.state.power_state) { + return; + } if ( $store.state.current_running_plan.trim() == '' && !prop.node.is_group diff --git a/src/components/PlanTree.vue b/src/components/PlanTree.vue index 1fa1a9d..e526baf 100644 --- a/src/components/PlanTree.vue +++ b/src/components/PlanTree.vue @@ -248,6 +248,9 @@ export default defineComponent({ }); }, runPlan(item: PlanEntity) { + if (!$store.state.power_state) { + return; + } GlobalData.getInstance().getCurrentClient()?.runPlan(item.uuid); $q.notify({ color: "positive", diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index a5e7155..8ff6917 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -428,6 +428,10 @@ export namespace Protocol { return Commands.PROTOCOL_PREFIX + "RpcGetCityList"; } + public static get kRpcGetPowerState() { + return Commands.PROTOCOL_PREFIX + "RpcGetPowerState"; + } + static _all_commands = new Set([ Commands.kUnKnowCommand, Commands.kSearchDevice, @@ -534,6 +538,7 @@ export namespace Protocol { Commands.kRpcGetSystemNetworkInfo, Commands.kRpcSetHdmiInDecodeType, Commands.kRpcGetCityList, + Commands.kRpcGetPowerState, ]); public static get AllCommands() { return this._all_commands; @@ -2719,4 +2724,23 @@ export namespace Protocol { city_list = []; } + + export class GetPowerStateRequestEntity extends PacketEntity { + constructor(rpc_id = 0) { + super(); + super.command = Commands.kRpcGetPowerState; + super.flag = PacketEntity.FLAG_REQUEST; + super.rpc_id = rpc_id; + } + timestamp = Date.now(); + } + + export class GetPowerStateResponseEntity extends PacketEntity { + constructor() { + super(); + super.flag = PacketEntity.FLAG_RESPONSE; + } + + is_power_on = false; + } } diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index dd0c404..b4f3232 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -545,4 +545,5 @@ export default { city_area: "区", location: "位置", city_city_area: "市区", + "device standby mode": "设备已休眠", }; diff --git a/src/pad/ContentWall.vue b/src/pad/ContentWall.vue index 7c403ca..8d396b4 100644 --- a/src/pad/ContentWall.vue +++ b/src/pad/ContentWall.vue @@ -3,6 +3,15 @@ ref="wall" class="fit bg-white q-py-md q-mx-sm row items-center justify-evenly wall" > +
+ + {{ $t("device standby mode") }} + +
@@ -805,6 +815,9 @@ export default defineComponent({ EventBus.getInstance().on( EventNamesDefine.DropToWall, (evt: _IDropToWall) => { + if (!$store.state.power_state) { + return; + } if (evt && evt.data) { switch (evt.type) { case "signal_source": diff --git a/src/pages/WallPage.vue b/src/pages/WallPage.vue index c57bac3..8926646 100644 --- a/src/pages/WallPage.vue +++ b/src/pages/WallPage.vue @@ -8,6 +8,15 @@ @drop="onDrop" style="background-color: #bce0f0" > +
+ + {{ $t("device standby mode") }} + +
{{ $t("open window") }} window.innerHeight, device_attribute: 0, + power_state: false, }, mutations: { @@ -321,6 +323,9 @@ export default store(function (/* { ssrContext } */) { state.landspace = playload; } }, + setPowerState(state: StateInterface, playload: boolean) { + state.power_state = playload; + }, setDeviceAttribute(state: StateInterface, playload?: any) { const num = parseInt(playload); if (!isNaN(num) && num >= 0) {