fix(设备运维中心):新增自定义指令下发
This commit is contained in:
@@ -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);
|
||||||
@@ -2652,38 +2655,88 @@ const DeviceMapDashboard: React.FC = () => {
|
|||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
{/* 操作按钮 */}
|
{/* 操作按钮 */}
|
||||||
<div style={{ marginBottom: '16px' }}>
|
<div style={{ marginBottom: '16px' }}>
|
||||||
<Title level={5}>设备操作</Title>
|
<Title level={5}>设备操作</Title>
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
icon={<VideoCameraOutlined />}
|
icon={<VideoCameraOutlined />}
|
||||||
onClick={() => handlePlayVideo(selectedDevice)}
|
onClick={() => handlePlayVideo(selectedDevice)}
|
||||||
loading={videoLoading}
|
loading={videoLoading}
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
视频监控
|
视频监控
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
icon={<ToolOutlined />}
|
icon={<ToolOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
message.info('设备调试功能开发中...');
|
message.info('设备调试功能开发中...');
|
||||||
}}
|
}}
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
远程调试
|
远程调试
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
icon={<ControlOutlined />}
|
icon={<ControlOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
message.info('设备控制功能开发中...');
|
message.info('设备控制功能开发中...');
|
||||||
}}
|
}}
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
设备控制
|
设备控制
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
|
||||||
|
{/* 自定义指令下发 */}
|
||||||
|
<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 && (
|
{selectedDevice.deviceType === 1 && (
|
||||||
|
|||||||
Reference in New Issue
Block a user