|
@@ -5,11 +5,17 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { useWebSocket } from '@/utils/handWs';
|
|
|
-const { handWs } = useWebSocket();
|
|
|
+import { useWebSocket } from '@/utils/handWs';
|
|
|
+const { handWs, startDevice, startHand, stateHand } = useWebSocket();
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
+const data = reactive<any>({
|
|
|
+ device_info: {},//设备信息
|
|
|
+});
|
|
|
+const { device_info } = toRefs(data);
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 手势
|
|
|
*/
|
|
@@ -17,6 +23,24 @@ const getHandWs = async () => {
|
|
|
//加载手势WS
|
|
|
handWs((e: any) => {
|
|
|
// console.log("eeee", e)
|
|
|
+ if (e?.wksid) {
|
|
|
+ //获取设备项目
|
|
|
+ let deviceid = localStorage.getItem("deviceid") || '';
|
|
|
+ if (deviceid) {
|
|
|
+ startDevice({ deviceid: deviceid })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //接收设备信息
|
|
|
+ if (e?.device_info) {
|
|
|
+ device_info.value = e.device_info;
|
|
|
+ let handcontroller_id = device_info.value.handcontroller_id;
|
|
|
+ stateHand(handcontroller_id);
|
|
|
+ }
|
|
|
+ //获取手势状态
|
|
|
+ if (e?.cmd == 'get_handcontroller_state' && e?.state == 0) {
|
|
|
+ let handcontroller_id = device_info.value.handcontroller_id;
|
|
|
+ startHand(handcontroller_id);
|
|
|
+ }
|
|
|
//刷新
|
|
|
if (e?.data?.result == "refresh") {
|
|
|
router.push({ path: '/gesture' });
|