From 644a222430a53c54748ef8f341e00c3fef02308b Mon Sep 17 00:00:00 2001 From: fengsen <2548667232@qq.com> Date: Wed, 10 Sep 2025 10:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9E=E6=8E=A5ws?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +++- .../ProjectScreen/components/newmap.vue | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.env.development b/.env.development index 038e52d..8b07eb7 100644 --- a/.env.development +++ b/.env.development @@ -18,8 +18,10 @@ VITE_APP_BASE_API = 'http://192.168.110.180:8899' #曾涛 # VITE_APP_BASE_API = 'http://192.168.110.171:8899' -# 无人机接口地址 +# ws +VITE_APP_BASE_WS_API = 'ws://192.168.110.149:8899/resource/websocket' +# 无人机接口地址 VITE_APP_BASE_DRONE_API = 'http://58.17.134.85:9512' # 应用访问路径 例如使用前缀 /admin/ diff --git a/src/views/projectLarge/ProjectScreen/components/newmap.vue b/src/views/projectLarge/ProjectScreen/components/newmap.vue index f2b541d..60975ee 100644 --- a/src/views/projectLarge/ProjectScreen/components/newmap.vue +++ b/src/views/projectLarge/ProjectScreen/components/newmap.vue @@ -4,11 +4,24 @@ import CesiumImageLabelEntity from '../js/CesiumImageLabelEntity.js'; import CesiumFlyToRoamingController from '../js/CesiumFlyToRoamingController.js'; import { setSelect, getSelectList, getGps } from '@/api/projectScreen/index.ts' import videoDialog from "./video.vue" +import { getToken } from '@/utils/auth'; const defaultExpandedKeys = [1, 2, 3] //默认展开第一级节点 const defaultCheckedKeys = ref([]) //默认选中节点 const data = ref([]); const deviceId = ref(''); const videoDialogRef = ref(null); +let token = 'Bearer '+ getToken() +let ws = new ReconnectingWebSocket( import.meta.env.VITE_APP_BASE_WS_API + '?Authorization='+token+'&clientid='+import.meta.env.VITE_APP_CLIENT_ID); +// 连接ws +const connectWs = () => { + ws.onopen = (e) => { + console.log('this.gateWay', e); + // ws.send(JSON.stringify(message)); + ws.onmessage = (e) => { + console.log('ws', e); + }; + }; +} const props = defineProps({ isHide:{ type:Boolean, @@ -214,6 +227,8 @@ function stopRoaming() { } } onMounted(() => { + // 连接ws + connectWs(); // 获取选中节点 getCheckedNode(); // 获取GPS数据