diff --git a/src/api/device.ts b/src/api/device.ts index 8f68ab5..d1a8360 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -365,6 +365,14 @@ export function getDeviceTotalData(data) { }) } +export function releaseControl(data) { + return request({ + url: '/forward/device/releaseControl', + method: 'post', + data + }) +} + diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 3fc0b60..cda5a4b 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -189,7 +189,6 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints = } return; } - console.log(points, "4324345") const validPoints = points.filter(p => { const lon = Number(p.lng); @@ -229,7 +228,6 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints = // ====================== // 🚀 非实时模式 -> 自动飞到轨迹 // ====================== - console.log('=== drawTrackLine ===', { points, validPoints, isRealtimeMode }); if (!isRealtimeMode) { let minLon = 180, maxLon = -180; @@ -245,7 +243,6 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints = // 单个点 if (validPoints.length === 1) { - console.log('=== drawTrackLine1111 ===', { points, validPoints, isRealtimeMode }); const p = validPoints[0]; @@ -261,7 +258,6 @@ export default function CesiumMap({ realtimePosition, realtimeType, pathPoints = viewer.scene.requestRender(); } else { - console.log('=== drawTrackLine2222 ===', { points, validPoints, isRealtimeMode }); const rectangle = Cesium.Rectangle.fromDegrees( diff --git a/src/components/SystemSetting/DeviceAccessPage.tsx b/src/components/SystemSetting/DeviceAccessPage.tsx index 42caee6..f8ad7f6 100644 --- a/src/components/SystemSetting/DeviceAccessPage.tsx +++ b/src/components/SystemSetting/DeviceAccessPage.tsx @@ -333,7 +333,6 @@ export default function DeviceAccessPage() { if (modalType === 'product') { form.setFieldValue('modelId', selectedModelId); const { modelId, limitConfig, actionConfig, ...params } = values; - console.log('提交的产品数据:', { ...params, modelId, limitConfig, actionConfig }); // 👈 这里可以看到提交的数据结构 const finalLimitConfig = {}; if (limitConfig) { diff --git a/src/components/SystemSetting/MenuList.tsx b/src/components/SystemSetting/MenuList.tsx index 33c25a2..63396fb 100644 --- a/src/components/SystemSetting/MenuList.tsx +++ b/src/components/SystemSetting/MenuList.tsx @@ -51,7 +51,6 @@ export default function MenuList() { }; getMenuList(params).then(res => { - console.log(res, "res") if (res.code === 200) { const data = res.rows || []; setRawMenuList(data); diff --git a/src/components/SystemSetting/SerialNumGenerate.jsx b/src/components/SystemSetting/SerialNumGenerate.jsx index aec4825..ee64dca 100644 --- a/src/components/SystemSetting/SerialNumGenerate.jsx +++ b/src/components/SystemSetting/SerialNumGenerate.jsx @@ -194,7 +194,6 @@ const SerialNumGenerate = () => { const generateQRCode = async () => { try { const values = await form.validateFields(); - console.log(values, "jnjn") const { model, config, type, country, province } = values; const ts = Date.now(); const suffix = generateSerialSuffix(); @@ -244,7 +243,6 @@ const SerialNumGenerate = () => { try { setLoading(true); const values = form.getFieldsValue(); - console.log(values, "oiii", types) const model = models.find(m => m.displayName === values.model); const config = configs.find(c => c.displayName === values.config); const type = types.find(t => t.storeValue === values.type); @@ -355,7 +353,6 @@ const SerialNumGenerate = () => { key: 'type', render: (_, r) => { const qrInfo = parseQrJson(r.qrJson); - console.log(types, qrInfo.type) const typeItem = types.find(t => t.storeValue === qrInfo.type); return typeItem?.displayName || qrInfo.type || '-'; } diff --git a/src/components/devices/DeviceControl.tsx b/src/components/devices/DeviceControl.tsx index b0733b7..1e24ec7 100644 --- a/src/components/devices/DeviceControl.tsx +++ b/src/components/devices/DeviceControl.tsx @@ -298,7 +298,6 @@ const RobotControlCenter = ({ setView }) => { if (res.data.code == 200) { setUrlInfo(res.data.data); } - console.log(res, "获取") }) } diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx index 24e04d7..b3a98e9 100644 --- a/src/components/devices/DeviceOverviewPage.tsx +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -71,7 +71,6 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS if (!stationId) return; try { - console.log('开始请求设备数据,stationId:', userInfo); // 1. 同时发请求 const [deviceRes, planeRes] = await Promise.all([ getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: userInfo.orgId }), diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx index 29d9241..64130f2 100644 --- a/src/components/devices/DeviceStatusPage.tsx +++ b/src/components/devices/DeviceStatusPage.tsx @@ -255,7 +255,6 @@ export default function DeviceStatusPage({ if (device.gateway_sn && device.gateway_sn !== device.device_sn) { topics.push(`thing/product/${device.gateway_sn}/osd`); } - console.log('DeviceStatusPage 订阅的MQTT主题:', topics); return topics; }, [isUAV, device]); @@ -371,8 +370,9 @@ export default function DeviceStatusPage({ controllerRef.current?.destroy(); controllerRef.current = null; + }; - }, [userInfo, messageApi]); + }, []); useEffect(() => { if (!device || !controllerRef.current || !device?.serialNumber || isUAV) return; diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx index 6b63907..24f1cca 100644 --- a/src/components/devices/RobotTaskPage.tsx +++ b/src/components/devices/RobotTaskPage.tsx @@ -234,7 +234,6 @@ export default function RobotTaskPage() { }); }; const handleTaskexcuted = (route) => { - console.log('执行任务,路线数据:', route); // 检查路径点 let hasPathPoints = false; @@ -272,7 +271,6 @@ export default function RobotTaskPage() { ...(userInfo?.orgId ? { orgId: userInfo.orgId } : {}), }; - console.log('执行任务参数:', params); const res = await excuetRoute(params); if (res.code === 200) { diff --git a/src/components/devices/WayLinePage.tsx b/src/components/devices/WayLinePage.tsx index 443c60e..7f91de5 100644 --- a/src/components/devices/WayLinePage.tsx +++ b/src/components/devices/WayLinePage.tsx @@ -92,7 +92,6 @@ export default function WayLinePage({ onRefresh }) { try { const parsedMessage = JSON.parse(message); - //console.log('WayLinePage 解析后的消息:', parsedMessage); if (parsedMessage.data && parsedMessage.data.host) { const { host } = parsedMessage.data; @@ -513,7 +512,6 @@ export default function WayLinePage({ onRefresh }) { const getBoardTask = async () => { if (!planedevices?.length) return; try { - console.log('获取看板任务数据,当前筛选条件:') const defaultStart = dayjs().startOf('day').unix(); const defaultEnd = dayjs().endOf('day').unix(); @@ -524,7 +522,6 @@ export default function WayLinePage({ onRefresh }) { const sns = boardDrone ? [boardDrone.gateway_sn] : planedevices.map(item => item.gateway_sn); const res = await getsinglePlan({ sns, beginAt, endAt }); - console.log('看板任务数据接口返回:', res); if (res?.code === 200) { let combinedList = []; if (res.data) { diff --git a/src/components/devices/deviceController.js b/src/components/devices/deviceController.js index 2ad0ddc..e0a9450 100644 --- a/src/components/devices/deviceController.js +++ b/src/components/devices/deviceController.js @@ -64,7 +64,10 @@ export default class DeviceController { // 切后台:关闭 WS if (document.visibilityState === 'hidden') { console.log('🔌 页面切后台,关闭 WebSocket'); + this.release(); wsManager.close(); + this.connectedDeviceSn = null; + this.isControlled = false; this.onControlStatusChange?.(false); @@ -91,6 +94,22 @@ export default class DeviceController { } }, 8000); } + release() { + if (this.isControlled && this.connectedDeviceSn) { + const data = { + platform: "web", + type: 1 + }; + const url = `${envConfig.baseURL}/forward/device/releaseControl`; + + try { + const blob = new Blob([JSON.stringify(data)], { type: 'application/json' }); + navigator.sendBeacon(url, blob); + } catch (e) { + console.error('Failed to send releaseControl beacon:', e); + } + } + } destroy() { this.clearControlTimeout(); @@ -106,8 +125,11 @@ export default class DeviceController { this.unSubMessage?.(); this.unSubStatus?.(); + this.release(); wsManager.close(); + this.connectedDeviceSn = null; + } handleWsStatus(status) { @@ -154,6 +176,7 @@ export default class DeviceController { wsManager.connect(sn, this.wsUrl); this.connectedDeviceSn = sn; + await this.getControl(sn); } catch (err) { console.error(err); @@ -223,6 +246,7 @@ export default class DeviceController { } handleWsMessage(msg) { + console.log('📨 收到消息:', msg); switch (msg.type) { case 'deviceInfo': { const data = {}; diff --git a/src/pages/Agri.jsx b/src/pages/Agri.jsx index 9d8c5bd..1b1851c 100644 --- a/src/pages/Agri.jsx +++ b/src/pages/Agri.jsx @@ -188,7 +188,6 @@ export default function Agri() { const formData = new FormData(); detectFiles.forEach(file => { - console.log(file, "dsdsvc") formData.append('files', file.originFileObj); }); formData.append('inputType', detectForm.inputType);