up. 使用状态管理器管理设备
This commit is contained in:
parent
2c0b86a969
commit
ed15d9ffd8
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<ele-modal
|
<ele-modal
|
||||||
title="设备已被锁定"
|
title="设备已被锁定"
|
||||||
v-model="visible"
|
v-model="clientStore.lockScreen"
|
||||||
:modal-penetrable="false"
|
:modal-penetrable="false"
|
||||||
:append-to-body="true"
|
:append-to-body="true"
|
||||||
:lock-scroll="true"
|
:lock-scroll="true"
|
||||||
@ -38,16 +38,25 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { WsEvent, wsEventManager } from '@/plugins/websocket';
|
import { WsEvent, wsEventManager } from '@/plugins/websocket';
|
||||||
import { clientScreenUnlock } from '@/api/layout';
|
import { clientScreenUnlock } from '@/api/layout';
|
||||||
|
import {useClientStore} from "@/store/modules/client";
|
||||||
|
|
||||||
const visible = ref(false);
|
/** 设备状态管理器 */
|
||||||
|
const clientStore = useClientStore();
|
||||||
|
/** 输入解锁密码 */
|
||||||
const lockPassword = ref('');
|
const lockPassword = ref('');
|
||||||
|
/** 解锁loading. */
|
||||||
const unlockLoading = ref(false);
|
const unlockLoading = ref(false);
|
||||||
|
/** 确定解锁 */
|
||||||
const confirmUnlock = () => {
|
const confirmUnlock = () => {
|
||||||
|
if(unlockLoading.value){
|
||||||
|
return;
|
||||||
|
}
|
||||||
unlockLoading.value = true;
|
unlockLoading.value = true;
|
||||||
|
|
||||||
clientScreenUnlock({ password: lockPassword.value })
|
clientScreenUnlock({ password: lockPassword.value })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
visible.value = false;
|
clientStore.setLockScreen(false)
|
||||||
lockPassword.value = '';
|
lockPassword.value = ''; // 清空密码
|
||||||
})
|
})
|
||||||
.catch((message) => {
|
.catch((message) => {
|
||||||
alert(message);
|
alert(message);
|
||||||
@ -56,7 +65,8 @@
|
|||||||
unlockLoading.value = false;
|
unlockLoading.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
/** 事件订阅器 - 锁屏事件 */
|
||||||
wsEventManager.subscribe(WsEvent.LOCK_CLIENT_SCREEN, () => {
|
wsEventManager.subscribe(WsEvent.LOCK_CLIENT_SCREEN, () => {
|
||||||
visible.value = true;
|
clientStore.setLockScreen(true);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
21
z_ele/src/store/modules/client.ts
Normal file
21
z_ele/src/store/modules/client.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* 设备状态管理
|
||||||
|
*/
|
||||||
|
import { defineStore } from 'pinia';
|
||||||
|
|
||||||
|
export interface ClientState {
|
||||||
|
lockScreen: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useClientStore = defineStore('client', {
|
||||||
|
state: (): ClientState => ({
|
||||||
|
/** 锁定会话 */
|
||||||
|
lockScreen: false,
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
setLockScreen(value: boolean) {
|
||||||
|
console.log("锁屏")
|
||||||
|
this.lockScreen = value;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user