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) {