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;
} | null>(null);
const [currentStreamType, setCurrentStreamType] = useState<'hls' | 'flv' | 'rtmp'>('hls');
// 自定义指令输入
const [customMethod, setCustomMethod] = useState<string>('custom');
const [customPayload, setCustomPayload] = useState<string>('{}');
// 地图相关
const [mapInitialized, setMapInitialized] = useState(false);
@@ -2652,38 +2655,88 @@ const DeviceMapDashboard: React.FC = () => {
<Divider />
{/* 操作按钮 */}
<div style={{ marginBottom: '16px' }}>
<Title level={5}>设备操作</Title>
<Space wrap>
<Button
type="primary"
icon={<VideoCameraOutlined />}
onClick={() => handlePlayVideo(selectedDevice)}
loading={videoLoading}
size="small"
>
视频监控
</Button>
<Button
icon={<ToolOutlined />}
onClick={() => {
message.info('设备调试功能开发中...');
}}
size="small"
>
远程调试
</Button>
<Button
icon={<ControlOutlined />}
onClick={() => {
message.info('设备控制功能开发中...');
}}
size="small"
>
设备控制
</Button>
</Space>
</div>
<div style={{ marginBottom: '16px' }}>
<Title level={5}>设备操作</Title>
<Space wrap>
<Button
type="primary"
icon={<VideoCameraOutlined />}
onClick={() => handlePlayVideo(selectedDevice)}
loading={videoLoading}
size="small"
>
视频监控
</Button>
<Button
icon={<ToolOutlined />}
onClick={() => {
message.info('设备调试功能开发中...');
}}
size="small"
>
远程调试
</Button>
<Button
icon={<ControlOutlined />}
onClick={() => {
message.info('设备控制功能开发中...');
}}
size="small"
>
设备控制
</Button>
</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>
{/* 无人机控制面板 */}
{selectedDevice.deviceType === 1 && (