待机时显示提示。不发送窗口相关消息。

This commit is contained in:
fangxiang 2022-05-25 18:21:13 +08:00
parent 3c193859c7
commit e03bb2515b
10 changed files with 118 additions and 26 deletions

View File

@ -1074,6 +1074,16 @@ export default class ClientConnection {
} }
} }
public async getPowerState() {
try {
return await this.doRpc<Protocol.GetPowerStateResponseEntity>(
new Protocol.GetPowerStateRequestEntity()
);
} catch (e) {
console.error(e);
}
}
public destory() { public destory() {
if (this.ws) { if (this.ws) {
this.ws.onclose = null; this.ws.onclose = null;

View File

@ -165,6 +165,9 @@ export default class Initializer {
} }
async initialize() { async initialize() {
const options = this.options;
const $store = options.$store;
const global_data = GlobalData.getInstance(); const global_data = GlobalData.getInstance();
let client = global_data.getCurrentClient(); let client = global_data.getCurrentClient();
if (client) { if (client) {
@ -172,18 +175,28 @@ export default class Initializer {
await Common.waitFor(100); await Common.waitFor(100);
} }
await this.getApplicationConfig();
// get device attribute // get device attribute
{ {
await this.getApplicationConfig();
GlobalData.getInstance() GlobalData.getInstance()
.getCurrentClient() .getCurrentClient()
?.getDeviceAttribute() ?.getDeviceAttribute()
.then((response) => { .then((response) => {
if (response && typeof response.attribute != "undefined") { if (response && typeof response.attribute != "undefined") {
this.options.$store.commit( $store.commit("setDeviceAttribute", response.attribute);
"setDeviceAttribute", }
response.attribute });
); }
// get power state
{
GlobalData.getInstance()
.getCurrentClient()
?.getPowerState()
.then((response) => {
if (response) {
$store.commit("setPowerState", response.is_power_on);
} }
}); });
} }

View File

@ -48,12 +48,21 @@ export default class RemoteDataExangeProcesser {
if (temp) { if (temp) {
let global_data = GlobalData.getInstance(); let global_data = GlobalData.getInstance();
if (global_data && global_data.applicationConfig) { if (global_data && global_data.applicationConfig) {
if (temp.key == "registered") { switch (temp.key) {
case "power_state":
$store.commit("setPowerState", temp.value == "on");
break;
case "registered":
{
global_data.applicationConfig.registered = JSON.parse( global_data.applicationConfig.registered = JSON.parse(
temp.value temp.value
); );
} else { }
(<any>global_data.applicationConfig)[temp.key] = temp.value; break;
default:
{
(<any>global_data.applicationConfig)[temp.key] =
temp.value;
$store.commit( $store.commit(
"setWallCol", "setWallCol",
global_data.applicationConfig.wall_col global_data.applicationConfig.wall_col
@ -67,6 +76,8 @@ export default class RemoteDataExangeProcesser {
global_data.applicationConfig.power_on_plan global_data.applicationConfig.power_on_plan
); );
} }
break;
}
} }
} }
} }

View File

@ -11,6 +11,9 @@
clickable clickable
@dblclick=" @dblclick="
(evt) => { (evt) => {
if (!$store.state.power_state) {
return;
}
if ( if (
$store.state.current_running_plan.trim() == '' && $store.state.current_running_plan.trim() == '' &&
!prop.node.is_group !prop.node.is_group

View File

@ -248,6 +248,9 @@ export default defineComponent({
}); });
}, },
runPlan(item: PlanEntity) { runPlan(item: PlanEntity) {
if (!$store.state.power_state) {
return;
}
GlobalData.getInstance().getCurrentClient()?.runPlan(item.uuid); GlobalData.getInstance().getCurrentClient()?.runPlan(item.uuid);
$q.notify({ $q.notify({
color: "positive", color: "positive",

View File

@ -428,6 +428,10 @@ export namespace Protocol {
return Commands.PROTOCOL_PREFIX + "RpcGetCityList"; return Commands.PROTOCOL_PREFIX + "RpcGetCityList";
} }
public static get kRpcGetPowerState() {
return Commands.PROTOCOL_PREFIX + "RpcGetPowerState";
}
static _all_commands = new Set([ static _all_commands = new Set([
Commands.kUnKnowCommand, Commands.kUnKnowCommand,
Commands.kSearchDevice, Commands.kSearchDevice,
@ -534,6 +538,7 @@ export namespace Protocol {
Commands.kRpcGetSystemNetworkInfo, Commands.kRpcGetSystemNetworkInfo,
Commands.kRpcSetHdmiInDecodeType, Commands.kRpcSetHdmiInDecodeType,
Commands.kRpcGetCityList, Commands.kRpcGetCityList,
Commands.kRpcGetPowerState,
]); ]);
public static get AllCommands() { public static get AllCommands() {
return this._all_commands; return this._all_commands;
@ -2719,4 +2724,23 @@ export namespace Protocol {
city_list = []; 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;
}
} }

View File

@ -545,4 +545,5 @@ export default {
city_area: "区", city_area: "区",
location: "位置", location: "位置",
city_city_area: "市区", city_city_area: "市区",
"device standby mode": "设备已休眠",
}; };

View File

@ -3,6 +3,15 @@
ref="wall" ref="wall"
class="fit bg-white q-py-md q-mx-sm row items-center justify-evenly wall" class="fit bg-white q-py-md q-mx-sm row items-center justify-evenly wall"
> >
<div
v-if="!$store.state.power_state"
style="position: absolute"
class="full-width text-center"
>
<span class="text-h5" style="z-index: 999; background: white">
{{ $t("device standby mode") }}
</span>
</div>
<div <div
ref="wall_content" ref="wall_content"
:style="{ :style="{
@ -67,6 +76,7 @@
</vue3-resize-drag> </vue3-resize-drag>
</div> </div>
<div <div
v-show="$store.state.power_state"
ref="wall_grids" ref="wall_grids"
@touchstart="$store.commit('setSelectedWindow', '')" @touchstart="$store.commit('setSelectedWindow', '')"
> >
@ -805,6 +815,9 @@ export default defineComponent({
EventBus.getInstance().on( EventBus.getInstance().on(
EventNamesDefine.DropToWall, EventNamesDefine.DropToWall,
(evt: _IDropToWall) => { (evt: _IDropToWall) => {
if (!$store.state.power_state) {
return;
}
if (evt && evt.data) { if (evt && evt.data) {
switch (evt.type) { switch (evt.type) {
case "signal_source": case "signal_source":

View File

@ -8,6 +8,15 @@
@drop="onDrop" @drop="onDrop"
style="background-color: #bce0f0" style="background-color: #bce0f0"
> >
<div
v-if="!$store.state.power_state"
style="position: absolute; top: -15%"
class="full-width text-center"
>
<span class="text-h5">
{{ $t("device standby mode") }}
</span>
</div>
<div id="windows" style="position: absolute"> <div id="windows" style="position: absolute">
<vue3-resize-drag <vue3-resize-drag
:w="item.width * ($refs.wall?.clientWidth ?? 0)" :w="item.width * ($refs.wall?.clientWidth ?? 0)"
@ -94,7 +103,7 @@
> >
<q-list> <q-list>
<q-item <q-item
:disable="plan_running" :disable="plan_running || !$store.state.power_state"
clickable clickable
v-close-popup v-close-popup
@click="openWindowByLocalFile($event)" @click="openWindowByLocalFile($event)"
@ -105,7 +114,7 @@
<q-item-section> {{ $t("open window") }} </q-item-section> <q-item-section> {{ $t("open window") }} </q-item-section>
</q-item> </q-item>
<q-item <q-item
:disable="plan_running" :disable="plan_running || !$store.state.power_state"
clickable clickable
v-close-popup v-close-popup
@click="closeAllWindows" @click="closeAllWindows"
@ -922,7 +931,7 @@ export default defineComponent({
}, },
onDragOver(e: DragEvent) { onDragOver(e: DragEvent) {
if (!plan_running.value) { if (!plan_running.value && $store.state.power_state) {
e.preventDefault(); e.preventDefault();
} }
}, },

View File

@ -62,6 +62,7 @@ export interface StateInterface {
signal_sources: SignalSourceEntity[]; signal_sources: SignalSourceEntity[];
landspace: boolean; landspace: boolean;
device_attribute: number; device_attribute: number;
power_state: boolean;
} }
// provide typings for `this.$store` // provide typings for `this.$store`
@ -310,6 +311,7 @@ export default store(function (/* { ssrContext } */) {
signal_sources: [], signal_sources: [],
landspace: window.innerWidth > window.innerHeight, landspace: window.innerWidth > window.innerHeight,
device_attribute: 0, device_attribute: 0,
power_state: false,
}, },
mutations: { mutations: {
@ -321,6 +323,9 @@ export default store(function (/* { ssrContext } */) {
state.landspace = playload; state.landspace = playload;
} }
}, },
setPowerState(state: StateInterface, playload: boolean) {
state.power_state = playload;
},
setDeviceAttribute(state: StateInterface, playload?: any) { setDeviceAttribute(state: StateInterface, playload?: any) {
const num = parseInt(playload); const num = parseInt(playload);
if (!isNaN(num) && num >= 0) { if (!isNaN(num) && num >= 0) {