联调接口

This commit is contained in:
2025-12-07 01:19:52 +08:00
parent 21772cae01
commit 478642e780
4 changed files with 126 additions and 122 deletions

View File

@@ -127,6 +127,12 @@ import AMapLoader from '@amap/amap-jsapi-loader'
import { ElMessage, ElMessageBox } from 'element-plus'
import { WebSocketClient, MockWebSocketDataGenerator } from './utils/websocket.js'
import droneImage from './assets/wrj.jpg'
import { getConfig } from ".//utils/request";
import DroneCtrl, {
UploadAreaReq
} from 'DroneCtrl';
const ctrl = new DroneCtrl.default(getConfig());
// 地图相关
const mapContainer = ref(null)
@@ -193,7 +199,7 @@ const initMap = async () => {
// 性能优化:节流处理数据更新
let lastUpdateTime = 0
const UPDATE_INTERVAL = 1000 // 3秒更新一次大幅降低更新频率
let conn = null;
// 初始化WebSocket连接
const initWebSocket = () => {
// 使用模拟数据生成器因为目前没有真实WebSocket服务器
@@ -235,9 +241,14 @@ const toggleWebSocket = () => {
}
wsConnected.value = false
ElMessage.info('已断开连接')
conn.close();
} else {
// 连接
initWebSocket()
conn = ctrl.Message();
conn.onDroneGPS = (data) => {
console.log(data);
};
}
}
@@ -709,6 +720,11 @@ const uploadFence = (fenceId) => {
}
if (pointsData) {
const points = pointsData.points;
ctrl.UploadArea(new UploadAreaReq(points.map(point=>({
longitude: point[0],
latitude: point[1],
}))));
// 输出到控制台
console.log('围栏坐标数据:', pointsData)
console.log('围栏坐标数据(JSON):', JSON.stringify(pointsData, null, 2))