up. ws update.

This commit is contained in:
扶桑花间 2025-08-28 22:47:09 +08:00
parent a4768d49b0
commit 8a6772daad
5 changed files with 21 additions and 11 deletions

View File

@ -76,6 +76,8 @@ class Worker extends Command
'client_id' => $connection->clientId,
'client_name'=> $connection->clientName
])->update(['is_lock'=>1,'lock_password'=>$lock_password,'lock_time'=>date('Y-m-d H:i:s')]);
// 锁定屏幕
$connection->send(json_encode(['event'=>'lock_client_screen_run']));
}
}
}

View File

@ -10,20 +10,19 @@
:close-on-press-escape="false"
:close-on-click-modal="false"
:show-close="false"
:fullscreen="true"
>
屏幕已锁定
</ele-modal>
</template>
<script setup lang="ts">
import {computed, inject} from 'vue';
import {ConnectionStatus} from "@/plugins/webSocket_plugin";
import {useUserStore} from "@/store/modules/user";
const { connectionStatus } = <any>inject('websocket');
const userStore = useUserStore();
import { ref } from 'vue';
import { WsEvent, wsEventManager } from '@/plugins/websocket';
const visible = computed<boolean>(()=> {
return (connectionStatus.value != ConnectionStatus.CONNECTED && userStore.info)
});
const visible = ref(false);
wsEventManager.subscribe(WsEvent.LOCK_CLIENT_SCREEN, () => {
visible.value = true;
});
</script>

View File

@ -43,5 +43,6 @@
wsInstance.sendMessage(WsSendEventType.LOCK_CLIENT_SCREEN, {
lockPassword: lockPassword.value
});
visible.value = false;
};
</script>

View File

@ -45,8 +45,15 @@ export function createWsInstance(config: WsConfig): WsInstance {
wsEventManager.emit(WsEvent.CONNECTED, e);
};
const handleMessage = (e: MessageEvent) =>
const handleMessage = (e: MessageEvent) =>{
addMessage(e.data, WsMessageType.INCOMING);
const jsonData = JSON.parse(e.data);
if (jsonData.event == WsEvent.LOCK_CLIENT_SCREEN) {
// 锁屏
wsEventManager.emit(WsEvent.LOCK_CLIENT_SCREEN, e);
}
}
const handleError = (e: Event) => {
isConnecting.value = false;

View File

@ -2,7 +2,8 @@ import type { Ref } from 'vue';
import { WsEventManager } from '@/plugins/websocket/core/event-manager';
export enum WsEvent {
CONNECTED = 'CONNECTED'
CONNECTED = 'CONNECTED',
LOCK_CLIENT_SCREEN = 'LOCK_CLIENT_SCREEN'
}
export enum WsSendEventType {