From e7234ce63efcb75fb43eee415e4ec9e600b6a8a2 Mon Sep 17 00:00:00 2001
From: mmc <1556375442@qq.com>
Date: Wed, 20 May 2026 09:25:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E6=8E=A7=E5=88=B6=E8=AE=BE?=
=?UTF-8?q?=E5=A4=87=20=20=E5=88=9D=E5=A7=8B=E5=93=88=20=20=20xbox?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=20=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
env.js | 4 +-
src/components/devices/DeviceControl.tsx | 8 +-
src/components/devices/XboxController.tsx | 27 ++-
src/components/devices/deviceController.js | 185 +++++++++++++++++++++
4 files changed, 212 insertions(+), 12 deletions(-)
create mode 100644 src/components/devices/deviceController.js
diff --git a/env.js b/env.js
index 8259afa..5f29637 100644
--- a/env.js
+++ b/env.js
@@ -15,8 +15,8 @@ const envConfig = {
},
[ENV.PROD]: {
// baseURL: 'http://192.168.2.56:8081',
- baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
- //baseURL: 'https://serviceri.satabot.com',
+ //baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
+ baseURL: 'https://serviceri.satabot.com',
WS_URL: 'wss://ri.satabot.com/ws/'
},
};
diff --git a/src/components/devices/DeviceControl.tsx b/src/components/devices/DeviceControl.tsx
index 9a6e2ab..9ce1b57 100644
--- a/src/components/devices/DeviceControl.tsx
+++ b/src/components/devices/DeviceControl.tsx
@@ -86,6 +86,7 @@ const RobotControlCenter = ({ setView }) => {
const [selectedRoute, setSelectedRoute] = useState(null); // ✅ 新增
const [activeTab, setActiveTab] = useState<'remote' | 'gps' | 'vizanti'>('remote');
const [waypoints, setWaypoints] = useState(INITIAL_WAYPOINTS);
+ const [isConnecting, setIsConnecting] = useState(false); // 连接中状态
const [newWaypoint, setNewWaypoint] = useState({ id: 0, lon: '', lat: '' });
const [taskIssued, setTaskIssued] = useState(false);
const [taskRunning, setTaskRunning] = useState(false);
@@ -456,6 +457,8 @@ const RobotControlCenter = ({ setView }) => {
}
const getControl = (serialnum) => {
+ setIsConnecting(true);
+
const data = { platform: "web", deviceId: serialnum };
getJurisdiction(data).then(res => {
if (res?.data?.code === 200 && res?.data?.data?.remoteControl == true) {
@@ -470,7 +473,9 @@ const RobotControlCenter = ({ setView }) => {
}).catch(err => {
controlRef.current = false;
setIsControlled(false);
- })
+ }).finally(() => {
+ setIsConnecting(false);
+ });
};
const handleSelectRobot = async (robot) => {
@@ -1541,6 +1546,7 @@ const RobotControlCenter = ({ setView }) => {
onGamepadUpdate={handleGamepad}
handleControlModal={handleControlModal}
isControlled={isControlled}
+ isConnecting={isConnecting}
/>
diff --git a/src/components/devices/XboxController.tsx b/src/components/devices/XboxController.tsx
index 1c35f03..8c744b6 100644
--- a/src/components/devices/XboxController.tsx
+++ b/src/components/devices/XboxController.tsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useRef } from 'react';
-const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled }) => {
+const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isConnecting }) => {
const [gamepadState, setGamepadState] = useState<{
buttons: boolean[];
axes: number[];
@@ -123,15 +123,24 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled }) =
{/* Gamepad Status Badge */}
- {connected ? isControlled ? '控制中' : '重新选中设备获取控制权限' : '无控制器连接'}
+ {connected
+ ? isConnecting
+ ? '连接中...'
+ : isControlled
+ ? '控制中'
+ : '无控制权限'
+ : '未连接设备'
+ }