fix(设备运维中心):新增自定义指令下发

This commit is contained in:
2025-08-19 19:00:14 +08:00
parent cf9f0f05d0
commit 4a9d625944
@@ -277,6 +277,9 @@ const DeviceMapDashboard: React.FC = () => {
playRtmpUrl: string; playRtmpUrl: string;
} | null>(null); } | null>(null);
const [currentStreamType, setCurrentStreamType] = useState<'hls' | 'flv' | 'rtmp'>('hls'); const [currentStreamType, setCurrentStreamType] = useState<'hls' | 'flv' | 'rtmp'>('hls');
// 自定义指令输入
const [customMethod, setCustomMethod] = useState<string>('custom');
const [customPayload, setCustomPayload] = useState<string>('{}');
// 地图相关 // 地图相关
const [mapInitialized, setMapInitialized] = useState(false); const [mapInitialized, setMapInitialized] = useState(false);
@@ -2683,6 +2686,56 @@ const DeviceMapDashboard: React.FC = () => {
设备控制 设备控制
</Button> </Button>
</Space> </Space>
{/* 自定义指令下发 */}
<div style={{ marginTop: 12, padding: 12, background: '#fafafa', borderRadius: 6, border: '1px solid #f0f0f0' }}>
<div style={{ marginBottom: 8, fontWeight: 600 }}>自定义指令下发</div>
<Space direction="vertical" style={{ width: '100%' }} size={8}>
<Input
placeholder="指令方法(method),如 camera_photo_take / return_home / 自定义"
value={customMethod}
onChange={(e) => setCustomMethod(e.target.value)}
size="small"
/>
<Input.TextArea
placeholder={'指令数据(JSON),如 {"speed":5}'}
value={customPayload}
onChange={(e) => setCustomPayload(e.target.value)}
autoSize={{ minRows: 2, maxRows: 6 }}
/>
<Button
type="primary"
size="small"
onClick={async () => {
try {
const method = (customMethod || '').trim();
if (!method) {
message.error('请输入指令方法');
return;
}
let data: any = {};
const payloadText = (customPayload || '').trim();
if (payloadText) {
try {
data = JSON.parse(payloadText);
} catch (err) {
message.error('指令数据需为合法JSON');
return;
}
}
const ok = await sendControlCommand(selectedDevice.deviceSn, method, data);
if (ok) {
message.success('指令已下发');
}
} catch (err) {
message.error('下发失败');
}
}}
>
下发自定义指令
</Button>
</Space>
</div>
</div> </div>
{/* 无人机控制面板 */} {/* 无人机控制面板 */}