fix:支付宝支付退款以及消息通知
This commit is contained in:
+116
@@ -973,6 +973,120 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.zoomControl {
|
||||
position: relative;
|
||||
flex: 0 0 52px;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
|
||||
.zoomBtn {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
}
|
||||
|
||||
.zoomBar {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 3;
|
||||
width: 52px;
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
border: 1px solid rgba(0, 212, 255, 0.52);
|
||||
border-radius: 12px;
|
||||
background: rgba(5, 17, 29, 0.96);
|
||||
box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.zoomCloseBtn,
|
||||
.zoomStepBtn {
|
||||
width: 42px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: rgba(208, 242, 250, 0.85);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: rgba(0, 212, 255, 0.16);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:active:not(:disabled) {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
transform: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.zoomCloseBtn {
|
||||
height: 26px;
|
||||
border-bottom: 1px solid rgba(168, 210, 226, 0.16);
|
||||
border-radius: 7px 7px 0 0;
|
||||
color: rgba(201, 222, 230, 0.62);
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 92, 105, 0.13);
|
||||
color: #ff9ca4;
|
||||
}
|
||||
}
|
||||
|
||||
.zoomStepBtn {
|
||||
height: 38px;
|
||||
margin: 2px 0;
|
||||
border-radius: 8px;
|
||||
font-size: 17px;
|
||||
line-height: 1;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.zoomReadout {
|
||||
width: 42px;
|
||||
height: 47px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-top: 1px solid rgba(168, 210, 226, 0.12);
|
||||
border-bottom: 1px solid rgba(168, 210, 226, 0.12);
|
||||
}
|
||||
|
||||
.zoomLabel {
|
||||
color: rgba(183, 211, 222, 0.56);
|
||||
font-size: 9px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.08em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.zoomValue {
|
||||
margin-top: 2px;
|
||||
color: #eefbff;
|
||||
font-family: 'Bahnschrift', 'Microsoft YaHei', sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.zoomUnit {
|
||||
margin-left: 1px;
|
||||
color: @primary;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
opacity: 0.82;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,6 +1108,8 @@
|
||||
50% { opacity: 0.4; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@keyframes recordPulse {
|
||||
0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.6); }
|
||||
70% { box-shadow: 0 0 0 15px rgba(255, 71, 87, 0); }
|
||||
|
||||
+161
-3
@@ -17,6 +17,9 @@ import {
|
||||
DisconnectOutlined,
|
||||
CompassOutlined,
|
||||
WarningOutlined,
|
||||
ZoomInOutlined,
|
||||
MinusOutlined,
|
||||
PlusOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { message, Modal, Tooltip, Spin } from 'antd';
|
||||
import { deviceApi } from '@/services/device';
|
||||
@@ -108,6 +111,8 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
hSpeed: Number(data?.horizontal_speed ?? 0).toFixed(1),
|
||||
vSpeed: Number(data?.vertical_speed ?? 0).toFixed(1),
|
||||
alt: Number(data?.height ?? data?.elevation ?? 0).toFixed(1),
|
||||
relAlt: Number(data?.height ?? 0).toFixed(1),
|
||||
absAlt: Number(data?.elevation ?? 0).toFixed(1),
|
||||
dist: Number(data?.home_distance ?? 0).toFixed(1),
|
||||
sat: data?.position_state?.gps_number ?? 0,
|
||||
rtk: data?.position_state?.is_fixed === 2 ? 'FIX' : 'FLOAT',
|
||||
@@ -142,6 +147,11 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
const [cameraMode, setCameraMode] = useState<number | null>(null);
|
||||
// 相机操作loading状态
|
||||
const [cameraLoading, setCameraLoading] = useState(false);
|
||||
// 变焦
|
||||
const [zoomFactor, setZoomFactor] = useState<number>(2);
|
||||
const [zoomLoading, setZoomLoading] = useState(false);
|
||||
const [zoomActive, setZoomActive] = useState(false);
|
||||
const zoomTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
// 视频尺寸状态
|
||||
const [videoSize, setVideoSize] = useState<'normal' | 'large' | 'fullscreen'>('normal');
|
||||
@@ -365,7 +375,60 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
// 进入指令飞行模式(DRC模式)
|
||||
// ========== 云台变焦 ==========
|
||||
|
||||
// 切换到变焦镜头并展开变焦控制
|
||||
const switchToZoomLens = useCallback(async () => {
|
||||
if (!deviceSn || !wsConnected || !drcModeRef.current) return;
|
||||
setZoomLoading(true);
|
||||
try {
|
||||
await deviceApi.liveLensChange({ deviceSn, videoType: 'zoom' });
|
||||
setZoomActive(true);
|
||||
message.success('已切换到变焦镜头');
|
||||
} catch {
|
||||
message.error('切换变焦镜头失败');
|
||||
} finally {
|
||||
setZoomLoading(false);
|
||||
}
|
||||
}, [deviceSn, wsConnected]);
|
||||
|
||||
// 设置变焦倍数
|
||||
const setZoom = useCallback(async (factor: number) => {
|
||||
if (!deviceSn || !wsConnected || !drcModeRef.current) return;
|
||||
const clamped = Math.max(2, Math.min(200, Math.round(factor * 10) / 10));
|
||||
setZoomFactor(clamped);
|
||||
try {
|
||||
await deviceApi.cameraFocalLengthSet({ deviceSn, zoomFactor: clamped });
|
||||
} catch {
|
||||
// 变焦失败时静默
|
||||
}
|
||||
}, [deviceSn, wsConnected]);
|
||||
|
||||
// 连续变焦(按住时持续调用)
|
||||
const startContinuousZoom = useCallback((delta: number) => {
|
||||
if (zoomTimerRef.current) return; // 已在变焦中
|
||||
const step = delta > 0 ? 2 : -2; // 每次步进2倍
|
||||
const ms = 200; // 200ms 间隔
|
||||
|
||||
const tick = () => {
|
||||
setZoomFactor(prev => {
|
||||
const next = Math.max(2, Math.min(200, prev + step));
|
||||
deviceApi.cameraFocalLengthSet({ deviceSn, zoomFactor: next }).catch(() => {});
|
||||
return next;
|
||||
});
|
||||
zoomTimerRef.current = setTimeout(tick, ms);
|
||||
};
|
||||
tick();
|
||||
}, [deviceSn]);
|
||||
|
||||
const stopContinuousZoom = useCallback(() => {
|
||||
if (zoomTimerRef.current) {
|
||||
clearTimeout(zoomTimerRef.current);
|
||||
zoomTimerRef.current = null;
|
||||
}
|
||||
}, []);
|
||||
|
||||
// ===============================
|
||||
const handleEnterDrcMode = async () => {
|
||||
if (!deviceSn || !wsConnected || drcLoading) return;
|
||||
|
||||
@@ -392,6 +455,8 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
setDrcMode(false);
|
||||
drcModeRef.current = false;
|
||||
setActiveKeys(new Set());
|
||||
setZoomActive(false);
|
||||
setZoomFactor(2);
|
||||
message.info('已退出指令飞行模式');
|
||||
};
|
||||
|
||||
@@ -465,6 +530,9 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
'arrowleft': ['left', 'gimbal'], // 云台左转
|
||||
'arrowright': ['right', 'gimbal'] // 云台右转
|
||||
};
|
||||
// 变焦用独立定时器(连续按键)
|
||||
let zoomInTimer: NodeJS.Timeout | null = null;
|
||||
let zoomOutTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
const down = (e: KeyboardEvent) => {
|
||||
const k = e.key.toLowerCase();
|
||||
@@ -480,6 +548,25 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
if (map[k] && !activeKeys.has(k)) {
|
||||
setActiveKeys(p => new Set(p).add(k));
|
||||
}
|
||||
// 变焦按键:`+` / `=` 放大,`-` 缩小(仅在DRC模式)
|
||||
const isZoomIn = (k === '=' || k === '+');
|
||||
const isZoomOut = (k === '-');
|
||||
if (drcModeRef.current && (isZoomIn || isZoomOut) && !e.repeat) {
|
||||
e.preventDefault();
|
||||
const timer = isZoomIn ? zoomInTimer : zoomOutTimer;
|
||||
if (timer) return;
|
||||
const step = isZoomIn ? 2 : -2;
|
||||
const tick = () => {
|
||||
setZoomFactor(prev => {
|
||||
const next = Math.max(2, Math.min(200, prev + step));
|
||||
deviceApi.cameraFocalLengthSet({ deviceSn, zoomFactor: next }).catch(() => {});
|
||||
return next;
|
||||
});
|
||||
if (isZoomIn) { zoomInTimer = setTimeout(tick, 200); }
|
||||
else { zoomOutTimer = setTimeout(tick, 200); }
|
||||
};
|
||||
tick();
|
||||
}
|
||||
};
|
||||
|
||||
const up = (e: KeyboardEvent) => {
|
||||
@@ -491,6 +578,13 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
return n;
|
||||
});
|
||||
}
|
||||
// 停止连续变焦
|
||||
if (k === '=' || k === '+') {
|
||||
if (zoomInTimer) { clearTimeout(zoomInTimer); zoomInTimer = null; }
|
||||
}
|
||||
if (k === '-') {
|
||||
if (zoomOutTimer) { clearTimeout(zoomOutTimer); zoomOutTimer = null; }
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', down);
|
||||
@@ -877,6 +971,8 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
<div>X: 切换速度档位</div>
|
||||
<div style={{ marginTop: '4px' }}><b>云台控制:</b></div>
|
||||
<div>方向键: 上/下/左/右</div>
|
||||
<div style={{ marginTop: '4px' }}><b>变焦:</b></div>
|
||||
<div>- / + : 缩小 / 放大</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -945,8 +1041,12 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
<div className={styles.rightDataPanel}>
|
||||
<div className={styles.dataCard}>
|
||||
<div className={styles.dataRow}>
|
||||
<span className={styles.label}>高度</span>
|
||||
<span className={styles.value}>{flightData.alt}<span className={styles.unit}>m</span></span>
|
||||
<span className={styles.label}>相对高度</span>
|
||||
<span className={styles.value}>{flightData.relAlt}<span className={styles.unit}>m</span></span>
|
||||
</div>
|
||||
<div className={styles.dataRow}>
|
||||
<span className={styles.label}>绝对高度</span>
|
||||
<span className={styles.value}>{flightData.absAlt}<span className={styles.unit}>m</span></span>
|
||||
</div>
|
||||
<div className={styles.divider}></div>
|
||||
<div className={styles.attitudeRow}>
|
||||
@@ -1057,6 +1157,63 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
|
||||
{/* 右侧相机控制 */}
|
||||
<div className={styles.cameraControls}>
|
||||
{/* 变焦入口固定在相机按钮组内;展开时仅在该位置向上显示竖向控制 */}
|
||||
<div className={styles.zoomControl}>
|
||||
{!zoomActive ? (
|
||||
<Tooltip title={drcMode ? '切换至变焦镜头' : '请先进入手动控制模式'} placement="top">
|
||||
<button
|
||||
className={`${styles.cameraBtn} ${styles.zoomBtn} ${(!drcMode || zoomLoading) ? styles.disabled : ''}`}
|
||||
onClick={switchToZoomLens}
|
||||
disabled={!drcMode || zoomLoading}
|
||||
aria-label="切换至变焦镜头"
|
||||
>
|
||||
{zoomLoading ? <LoadingOutlined spin /> : <ZoomInOutlined />}
|
||||
</button>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<div className={styles.zoomBar}>
|
||||
<Tooltip title="退出变焦" placement="left">
|
||||
<button
|
||||
className={styles.zoomCloseBtn}
|
||||
aria-label="退出变焦"
|
||||
onClick={() => {
|
||||
setZoomActive(false);
|
||||
setZoomFactor(2);
|
||||
if (deviceSn && drcModeRef.current) {
|
||||
deviceApi.cameraFocalLengthSet({ deviceSn, zoomFactor: 2 }).catch(() => {});
|
||||
}
|
||||
}}
|
||||
>
|
||||
<CloseOutlined style={{ fontSize: 12 }} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<button
|
||||
className={styles.zoomStepBtn}
|
||||
onMouseDown={() => startContinuousZoom(2)}
|
||||
onMouseUp={stopContinuousZoom}
|
||||
onMouseLeave={stopContinuousZoom}
|
||||
disabled={!drcMode}
|
||||
aria-label="放大"
|
||||
>
|
||||
<PlusOutlined />
|
||||
</button>
|
||||
<div className={styles.zoomReadout}>
|
||||
<span className={styles.zoomLabel}>变焦</span>
|
||||
<span className={styles.zoomValue}>{zoomFactor.toFixed(1)}<span className={styles.zoomUnit}>×</span></span>
|
||||
</div>
|
||||
<button
|
||||
className={styles.zoomStepBtn}
|
||||
onMouseDown={() => startContinuousZoom(-2)}
|
||||
onMouseUp={stopContinuousZoom}
|
||||
onMouseLeave={stopContinuousZoom}
|
||||
disabled={!drcMode}
|
||||
aria-label="缩小"
|
||||
>
|
||||
<MinusOutlined />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Tooltip title={isRecording ? '录像中,请先停止录像' : (cameraLoading ? '处理中...' : '拍照')} placement="top">
|
||||
<button
|
||||
className={`${styles.cameraBtn} ${(cameraLoading || isRecording) ? styles.disabled : ''}`}
|
||||
@@ -1084,6 +1241,7 @@ const LeftControlPanel: React.FC<LeftControlPanelProps> = ({
|
||||
</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</>
|
||||
|
||||
+39
-10
@@ -31,8 +31,12 @@ interface RightPanelProps {
|
||||
/** 关闭面板(退出设备:会清空选中设备等) */
|
||||
onClose: () => void;
|
||||
onControlClick: (device: any, realtimeData: any) => void;
|
||||
/** 一键起飞任务创建成功后切换到操控台 */
|
||||
onTakeoffSuccess?: (device: any, realtimeData: any) => void;
|
||||
onTaskPanelOpen?: (device: any, dockData: any) => void; // 打开任务管理面板回调
|
||||
onRoutePlanningOpen?: (device: any) => void; // 打开航线规划面板回调(无人船)
|
||||
onFlyToPointActivate?: (deviceSn: string, dockLat?: number, dockLng?: number, dockH?: number) => void; // 激活指点飞行
|
||||
flyToPointState?: string; // 指点飞行状态(用于按钮禁用)
|
||||
viewer?: any; // Cesium Viewer 实例
|
||||
Cesium?: any; // Cesium 库
|
||||
}
|
||||
@@ -43,8 +47,11 @@ const RightPanel: React.FC<RightPanelProps> = ({
|
||||
onMinimize,
|
||||
onClose,
|
||||
onControlClick,
|
||||
onTakeoffSuccess,
|
||||
onTaskPanelOpen,
|
||||
onRoutePlanningOpen,
|
||||
onFlyToPointActivate,
|
||||
flyToPointState,
|
||||
viewer,
|
||||
Cesium
|
||||
}) => {
|
||||
@@ -171,12 +178,13 @@ const RightPanel: React.FC<RightPanelProps> = ({
|
||||
targetHeight: targetHeight,
|
||||
});
|
||||
|
||||
// 兼容两种响应格式:resp_code/resp_msg 或 code/msg
|
||||
const code = res.resp_code !== undefined ? res.resp_code : res.resp_code;
|
||||
const msg = res.resp_msg !== undefined ? res.resp_msg : res.resp_msg;
|
||||
// 网关与服务端可能分别返回 resp_code 或 code,统一为数值后判断。
|
||||
const code = Number(res.resp_code ?? res.code);
|
||||
const msg = res.resp_msg ?? res.msg;
|
||||
|
||||
if (code === 0) {
|
||||
message.success('一键起飞任务已创建,无人机将自动开机并起飞');
|
||||
onTakeoffSuccess?.(device, realtimeData);
|
||||
} else {
|
||||
message.error(msg || '一键起飞任务创建失败');
|
||||
}
|
||||
@@ -318,13 +326,34 @@ const RightPanel: React.FC<RightPanelProps> = ({
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>
|
||||
<span>机库信息 / DOCK INFO</span>
|
||||
<button
|
||||
className={styles.takeoffBtn}
|
||||
disabled={takeoffLoading || dockData?.mode_code === 1 || dockData?.drone_in_dock === 0}
|
||||
onClick={handleTakeoff}
|
||||
>
|
||||
{takeoffLoading ? <LoadingOutlined /> : <RocketOutlined />} 一键起飞
|
||||
</button>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<button
|
||||
className={styles.takeoffBtn}
|
||||
disabled={takeoffLoading || dockData?.mode_code === 1 || dockData?.drone_in_dock === 0}
|
||||
onClick={handleTakeoff}
|
||||
>
|
||||
{takeoffLoading ? <LoadingOutlined /> : <RocketOutlined />} 一键起飞
|
||||
</button>
|
||||
<button
|
||||
className={styles.takeoffBtn}
|
||||
disabled={
|
||||
!onFlyToPointActivate ||
|
||||
!device?.deviceSn ||
|
||||
!!flyToPointState && flyToPointState !== 'IDLE' && flyToPointState !== 'COMPLETED'
|
||||
}
|
||||
onClick={() => {
|
||||
if (onFlyToPointActivate && device?.deviceSn) {
|
||||
const dockLat = dockData?.latitude || realtimeData?.gps?.latitude;
|
||||
const dockLng = dockData?.longitude || realtimeData?.gps?.longitude;
|
||||
const dockH = dockData?.height || realtimeData?.gps?.altitude || 0;
|
||||
onFlyToPointActivate(device.deviceSn, dockLat, dockLng, dockH);
|
||||
}
|
||||
}}
|
||||
title="创建指点飞行任务,升空后可在地图上连续点击目标位置"
|
||||
>
|
||||
<EnvironmentOutlined /> 指点飞行
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 状态卡片 */}
|
||||
|
||||
+104
-104
@@ -156,7 +156,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
const modalPendingPosRef = useRef({ x: 0, y: 0 });
|
||||
|
||||
// Tab 状态
|
||||
const [activeTab, setActiveTab] = useState<string>('route');
|
||||
const [activeTab, setActiveTab] = useState<string>('task');
|
||||
|
||||
// 拖拽状态
|
||||
const [position, setPosition] = useState({ x: 0, y: 0 });
|
||||
@@ -258,8 +258,8 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
}));
|
||||
setRouteList(unifiedRoutes);
|
||||
|
||||
// 默认选中第一条,并绘制到模型上(仅首次进入或未选中时)
|
||||
if (!selectedRouteId && unifiedRoutes.length > 0) {
|
||||
// 默认选中第一条航线(仅在航线 Tab 激活时)
|
||||
if (!selectedRouteId && unifiedRoutes.length > 0 && activeTab === 'route') {
|
||||
const first = unifiedRoutes[0];
|
||||
setSelectedRouteId(first.routeId);
|
||||
loadWaypointsRef.current?.(first.routeId, first.routeType);
|
||||
@@ -286,7 +286,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
}));
|
||||
setRouteList(unifiedRoutes);
|
||||
|
||||
if (!selectedRouteId && unifiedRoutes.length > 0) {
|
||||
if (!selectedRouteId && unifiedRoutes.length > 0 && activeTab === 'route') {
|
||||
const first = unifiedRoutes[0];
|
||||
setSelectedRouteId(first.routeId);
|
||||
loadWaypointsRef.current?.(first.routeId, first.routeType);
|
||||
@@ -966,7 +966,105 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
className={styles.tabs}
|
||||
items={[
|
||||
items={[{
|
||||
key: 'task',
|
||||
label: <span><UnorderedListOutlined /> 任务</span>,
|
||||
children: (
|
||||
<div className={styles.tabContent}>
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionTitle}>
|
||||
任务列表
|
||||
{missionLoading && <Spin size="small" style={{ marginLeft: 8 }} />}
|
||||
</div>
|
||||
<div className={styles.taskList}>
|
||||
{missionLoading && missionList.length === 0 ? (
|
||||
<div className={styles.loading}>加载中...</div>
|
||||
) : missionList.length === 0 ? (
|
||||
<Empty
|
||||
description="暂无任务,请先创建"
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
className={styles.emptyState}
|
||||
/>
|
||||
) : (
|
||||
missionList.map(mission => (
|
||||
<div
|
||||
key={mission.missionCode}
|
||||
className={`${styles.taskItem} ${selectedMissionCode === mission.missionCode ? styles.selected : ''}`}
|
||||
onClick={() => setSelectedMissionCode(mission.missionCode || null)}
|
||||
>
|
||||
<div className={styles.taskInfo}>
|
||||
<div className={styles.taskHeader}>
|
||||
<span className={styles.taskCode}>{mission.missionCode}</span>
|
||||
</div>
|
||||
<div className={styles.taskName}>
|
||||
{mission.missionName || mission.waylineName || '未命名任务'}
|
||||
</div>
|
||||
<div className={styles.taskMeta}>
|
||||
<Tag color={mission.missionType === MissionType.TAKEOFF ? 'orange' : 'blue'}>
|
||||
{MissionTypeMap[mission.missionType || 1]}
|
||||
</Tag>
|
||||
<Tag
|
||||
icon={getMissionStatusIcon(mission.missionStatus || 1)}
|
||||
color={MissionStatusColorMap[mission.missionStatus || 1]}
|
||||
>
|
||||
{MissionStatusMap[mission.missionStatus || 1]}
|
||||
</Tag>
|
||||
<span className={styles.taskTime}>{formatTime(mission.createTime)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.taskActions}>
|
||||
<Tooltip title="查看媒体">
|
||||
<button
|
||||
className={styles.actionBtn}
|
||||
onClick={(e) => { e.stopPropagation(); handleViewMissionMedia(mission); }}
|
||||
disabled={mediaLoading}
|
||||
>
|
||||
<PictureOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
{mission.missionStatus === MissionStatus.PENDING && mission.missionType === MissionType.WAYLINE && (
|
||||
<Tooltip title={isDockIdle ? '执行任务' : '机库忙碌中'}>
|
||||
<button
|
||||
className={`${styles.actionBtn} ${styles.execute}`}
|
||||
onClick={(e) => { e.stopPropagation(); handleExecuteMission(mission); }}
|
||||
disabled={!isDockIdle}
|
||||
>
|
||||
<PlayCircleOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{(mission.missionStatus === MissionStatus.DOING || mission.missionStatus === MissionStatus.UPLOADING || mission.missionStatus === MissionStatus.UPLOADED) && (
|
||||
<Tooltip title="完成任务">
|
||||
<button className={styles.actionBtn} onClick={(e) => { e.stopPropagation(); handleCompleteMission(mission); }}>
|
||||
<CheckCircleOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{mission.missionStatus === MissionStatus.PENDING && (
|
||||
<Tooltip title="取消任务">
|
||||
<button className={styles.actionBtn} onClick={(e) => { e.stopPropagation(); handleCancelMission(mission); }}>
|
||||
<CloseCircleOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{(mission.missionStatus === MissionStatus.COMPLETE || mission.missionStatus === MissionStatus.CANCELED) && (
|
||||
<Tooltip title="删除任务">
|
||||
<button className={`${styles.actionBtn} ${styles.danger}`} onClick={(e) => { e.stopPropagation(); handleDeleteMission(mission); }}>
|
||||
<DeleteOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
,
|
||||
|
||||
{
|
||||
key: 'route',
|
||||
label: <span><EnvironmentOutlined /> 航线</span>,
|
||||
@@ -1072,105 +1170,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'task',
|
||||
label: <span><UnorderedListOutlined /> 任务</span>,
|
||||
children: (
|
||||
<div className={styles.tabContent}>
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionTitle}>
|
||||
任务列表
|
||||
{missionLoading && <Spin size="small" style={{ marginLeft: 8 }} />}
|
||||
</div>
|
||||
<div className={styles.taskList}>
|
||||
{missionLoading && missionList.length === 0 ? (
|
||||
<div className={styles.loading}>加载中...</div>
|
||||
) : missionList.length === 0 ? (
|
||||
<Empty
|
||||
description="暂无任务,请先创建"
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
className={styles.emptyState}
|
||||
/>
|
||||
) : (
|
||||
missionList.map(mission => (
|
||||
<div
|
||||
key={mission.missionCode}
|
||||
className={`${styles.taskItem} ${selectedMissionCode === mission.missionCode ? styles.selected : ''}`}
|
||||
onClick={() => setSelectedMissionCode(mission.missionCode || null)}
|
||||
>
|
||||
<div className={styles.taskInfo}>
|
||||
<div className={styles.taskHeader}>
|
||||
<span className={styles.taskCode}>{mission.missionCode}</span>
|
||||
</div>
|
||||
<div className={styles.taskName}>
|
||||
{mission.missionName || mission.waylineName || '未命名任务'}
|
||||
</div>
|
||||
<div className={styles.taskMeta}>
|
||||
<Tag color={mission.missionType === MissionType.TAKEOFF ? 'orange' : 'blue'}>
|
||||
{MissionTypeMap[mission.missionType || 1]}
|
||||
</Tag>
|
||||
<Tag
|
||||
icon={getMissionStatusIcon(mission.missionStatus || 1)}
|
||||
color={MissionStatusColorMap[mission.missionStatus || 1]}
|
||||
>
|
||||
{MissionStatusMap[mission.missionStatus || 1]}
|
||||
</Tag>
|
||||
<span className={styles.taskTime}>{formatTime(mission.createTime)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.taskActions}>
|
||||
<Tooltip title="查看媒体">
|
||||
<button
|
||||
className={styles.actionBtn}
|
||||
onClick={(e) => { e.stopPropagation(); handleViewMissionMedia(mission); }}
|
||||
disabled={mediaLoading}
|
||||
>
|
||||
<PictureOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
{mission.missionStatus === MissionStatus.PENDING && mission.missionType === MissionType.WAYLINE && (
|
||||
<Tooltip title={isDockIdle ? '执行任务' : '机库忙碌中'}>
|
||||
<button
|
||||
className={`${styles.actionBtn} ${styles.execute}`}
|
||||
onClick={(e) => { e.stopPropagation(); handleExecuteMission(mission); }}
|
||||
disabled={!isDockIdle}
|
||||
>
|
||||
<PlayCircleOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{(mission.missionStatus === MissionStatus.DOING || mission.missionStatus === MissionStatus.UPLOADING || mission.missionStatus === MissionStatus.UPLOADED) && (
|
||||
<Tooltip title="完成任务">
|
||||
<button className={styles.actionBtn} onClick={(e) => { e.stopPropagation(); handleCompleteMission(mission); }}>
|
||||
<CheckCircleOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{mission.missionStatus === MissionStatus.PENDING && (
|
||||
<Tooltip title="取消任务">
|
||||
<button className={styles.actionBtn} onClick={(e) => { e.stopPropagation(); handleCancelMission(mission); }}>
|
||||
<CloseCircleOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{(mission.missionStatus === MissionStatus.COMPLETE || mission.missionStatus === MissionStatus.CANCELED) && (
|
||||
<Tooltip title="删除任务">
|
||||
<button className={`${styles.actionBtn} ${styles.danger}`} onClick={(e) => { e.stopPropagation(); handleDeleteMission(mission); }}>
|
||||
<DeleteOutlined />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
}]}
|
||||
/>
|
||||
|
||||
{/* 实时位置 */}
|
||||
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
.targetPanel {
|
||||
position: absolute;
|
||||
top: 92px;
|
||||
right: 18px;
|
||||
z-index: 1000;
|
||||
width: 356px;
|
||||
overflow: hidden;
|
||||
color: #f3fbff;
|
||||
background: linear-gradient(155deg, rgba(7, 21, 34, 0.98), rgba(5, 13, 24, 0.98));
|
||||
border: 1px solid rgba(0, 212, 255, 0.42);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 18px 44px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 70px;
|
||||
padding: 14px 16px;
|
||||
background: linear-gradient(90deg, rgba(0, 212, 255, 0.13), rgba(0, 212, 255, 0.02));
|
||||
border-bottom: 1px solid rgba(0, 212, 255, 0.2);
|
||||
}
|
||||
|
||||
.eyebrow,
|
||||
.sectionTitle,
|
||||
.label {
|
||||
display: block;
|
||||
color: rgba(164, 220, 239, 0.68);
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.9px;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-top: 3px;
|
||||
color: #ffffff;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.closeButton {
|
||||
display: grid;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
color: rgba(230, 248, 255, 0.72);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.13);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
place-items: center;
|
||||
|
||||
&:hover {
|
||||
color: #ffffff;
|
||||
background: rgba(255, 77, 79, 0.18);
|
||||
border-color: rgba(255, 77, 79, 0.65);
|
||||
}
|
||||
}
|
||||
|
||||
.targetSummary {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
|
||||
}
|
||||
|
||||
.locationIcon {
|
||||
display: grid;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
color: #00d4ff;
|
||||
background: rgba(0, 212, 255, 0.1);
|
||||
border: 1px solid rgba(0, 212, 255, 0.28);
|
||||
border-radius: 8px;
|
||||
font-size: 17px;
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.coordinateBlock,
|
||||
.heightBlock {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.coordinate {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
overflow: hidden;
|
||||
color: #72e8ff;
|
||||
font-family: Consolas, 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.heightBlock {
|
||||
padding-left: 12px;
|
||||
border-left: 1px solid rgba(255, 255, 255, 0.1);
|
||||
|
||||
strong {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: #ffffff;
|
||||
font-family: Consolas, 'Courier New', monospace;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
small {
|
||||
color: rgba(191, 230, 241, 0.65);
|
||||
font-size: 10px;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
||||
.riskNotice {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin: 14px 16px 0;
|
||||
padding: 11px 12px;
|
||||
background: rgba(255, 170, 0, 0.1);
|
||||
border: 1px solid rgba(255, 170, 0, 0.38);
|
||||
border-radius: 8px;
|
||||
|
||||
strong {
|
||||
display: block;
|
||||
color: #ffca70;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 5px 0 0;
|
||||
color: rgba(255, 235, 197, 0.75);
|
||||
font-size: 11px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
}
|
||||
|
||||
.warningIcon {
|
||||
margin-top: 2px;
|
||||
color: #ffaa00;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.parameterSection {
|
||||
padding: 15px 16px 12px;
|
||||
}
|
||||
|
||||
.sectionTitle {
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.parameterGrid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.parameterField {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 7px 10px 8px;
|
||||
background: rgba(255, 255, 255, 0.035);
|
||||
border: 1px solid rgba(128, 209, 235, 0.18);
|
||||
border-radius: 7px;
|
||||
|
||||
> span {
|
||||
display: block;
|
||||
margin-bottom: 3px;
|
||||
color: rgba(185, 223, 235, 0.64);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
em {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
bottom: 10px;
|
||||
color: rgba(185, 223, 235, 0.6);
|
||||
font-size: 10px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
:global(.ant-input-number) {
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
|
||||
input {
|
||||
height: 21px;
|
||||
padding: 0 26px 0 0;
|
||||
color: #ffffff;
|
||||
font-family: Consolas, 'Courier New', monospace;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.riskCheck {
|
||||
display: flex;
|
||||
margin: 0 16px 14px;
|
||||
color: rgba(230, 245, 250, 0.84);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
|
||||
:global(.ant-checkbox) {
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
:global(.ant-checkbox-inner) {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-color: rgba(130, 222, 248, 0.6);
|
||||
}
|
||||
|
||||
:global(.ant-checkbox-checked .ant-checkbox-inner) {
|
||||
background: #00b8df;
|
||||
border-color: #00b8df;
|
||||
}
|
||||
|
||||
:global(.ant-checkbox + span) {
|
||||
padding-inline-start: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: grid;
|
||||
grid-template-columns: 88px 1fr;
|
||||
gap: 10px;
|
||||
padding: 13px 16px 16px;
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.07);
|
||||
}
|
||||
|
||||
.discardButton,
|
||||
.sendButton {
|
||||
height: 38px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.discardButton {
|
||||
color: rgba(230, 245, 250, 0.84) !important;
|
||||
background: rgba(255, 255, 255, 0.04) !important;
|
||||
border-color: rgba(255, 255, 255, 0.2) !important;
|
||||
|
||||
&:hover {
|
||||
color: #ffffff !important;
|
||||
background: rgba(255, 77, 79, 0.14) !important;
|
||||
border-color: rgba(255, 77, 79, 0.65) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.sendButton {
|
||||
background: linear-gradient(90deg, #009bc1, #00c7e8) !important;
|
||||
border-color: #20d7f3 !important;
|
||||
box-shadow: 0 0 16px rgba(0, 212, 255, 0.2);
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: linear-gradient(90deg, #00afda, #14d8f7) !important;
|
||||
box-shadow: 0 0 20px rgba(0, 212, 255, 0.38);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
color: rgba(255, 255, 255, 0.55) !important;
|
||||
background: rgba(68, 112, 126, 0.55) !important;
|
||||
border-color: rgba(125, 190, 208, 0.25) !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.targetPanel {
|
||||
right: 12px;
|
||||
left: 12px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Alert, Button, Checkbox, InputNumber, Modal, Space } from 'antd';
|
||||
import { CloseOutlined, EnvironmentOutlined, SendOutlined, StopOutlined, WarningFilled } from '@ant-design/icons';
|
||||
import type { FlyToPointState, TargetPoint } from '../hooks/useFlyToPoint';
|
||||
import styles from './FlyToPointPanel.less';
|
||||
|
||||
interface FlyToPointPanelProps {
|
||||
visible: boolean;
|
||||
state: FlyToPointState;
|
||||
missionCode: string | null;
|
||||
candidateTarget: TargetPoint | null;
|
||||
currentTarget: TargetPoint | null;
|
||||
distanceToTarget: number;
|
||||
isAirborne: boolean;
|
||||
isSending: boolean;
|
||||
onConfirmStart: () => void;
|
||||
onCancelStart: () => void;
|
||||
onConfirmFly: (clearanceMeters: number, maxSpeed: number, riskAcknowledged: boolean) => void;
|
||||
onCancelTarget: () => void;
|
||||
onEndFlight: () => void;
|
||||
}
|
||||
|
||||
const FlyToPointPanel: React.FC<FlyToPointPanelProps> = ({
|
||||
visible, state, missionCode, candidateTarget, currentTarget, distanceToTarget, isAirborne, isSending,
|
||||
onConfirmStart, onCancelStart, onConfirmFly, onCancelTarget, onEndFlight,
|
||||
}) => {
|
||||
const [clearanceMeters, setClearanceMeters] = useState(30);
|
||||
const [maxSpeed, setMaxSpeed] = useState(12);
|
||||
const [riskAcknowledged, setRiskAcknowledged] = useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (candidateTarget) {
|
||||
setClearanceMeters(candidateTarget.clearanceMeters);
|
||||
setRiskAcknowledged(false);
|
||||
}
|
||||
}, [candidateTarget]);
|
||||
|
||||
const status = state === 'TAKING_OFF' ? '起飞中' : state === 'RETURNING' ? '返航中' : state === 'FLYING_TO'
|
||||
? `飞往已发送目标,距离 ${distanceToTarget.toFixed(0)}m` : '等待地图点选目标';
|
||||
|
||||
return <>
|
||||
{state !== 'IDLE' && state !== 'COMPLETED' && <div style={{ position: 'absolute', top: 10, left: '50%', transform: 'translateX(-50%)', zIndex: 1000, background: 'rgba(0,0,0,.78)', color: '#fff', padding: '8px 14px', borderRadius: 20, display: 'flex', alignItems: 'center', gap: 10 }}>
|
||||
<span>指点飞行 | {status}</span>
|
||||
{(state === 'WAITING_TARGET' || state === 'FLYING_TO') && <Button size="small" danger icon={<StopOutlined />} onClick={onEndFlight}>结束飞行</Button>}
|
||||
</div>}
|
||||
|
||||
<Modal title={<Space><EnvironmentOutlined />指点飞行</Space>} open={visible && state === 'IDLE'} onCancel={onCancelStart} footer={<Space><Button onClick={onCancelStart}>取消</Button><Button type="primary" icon={<SendOutlined />} onClick={onConfirmStart}>确认开始</Button></Space>}>
|
||||
<Alert type="info" showIcon message="将创建指点飞行任务" description={isAirborne ? '无人机已升空,确认后可在地图连续点选候选目标。' : '将先自动起飞,升空后可在地图连续点选候选目标。'} />
|
||||
</Modal>
|
||||
|
||||
{candidateTarget && <aside className={styles.targetPanel} aria-label="候选飞行目标确认">
|
||||
<header className={styles.header}>
|
||||
<div>
|
||||
<div className={styles.eyebrow}>POINT-TO-POINT FLIGHT</div>
|
||||
<div className={styles.title}>{currentTarget ? '确认改飞目标' : '确认飞行目标'}</div>
|
||||
</div>
|
||||
<button className={styles.closeButton} type="button" onClick={onCancelTarget} aria-label="丢弃候选目标">
|
||||
<CloseOutlined />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<section className={styles.targetSummary}>
|
||||
<div className={styles.locationIcon}><EnvironmentOutlined /></div>
|
||||
<div className={styles.coordinateBlock}>
|
||||
<span className={styles.label}>目标坐标</span>
|
||||
<span className={styles.coordinate}>{candidateTarget.longitude.toFixed(6)}, {candidateTarget.latitude.toFixed(6)}</span>
|
||||
</div>
|
||||
<div className={styles.heightBlock}>
|
||||
<span className={styles.label}>模型高度</span>
|
||||
<strong>{candidateTarget.candidateSurfaceHeight.toFixed(1)}<small> m</small></strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className={styles.riskNotice}>
|
||||
<WarningFilled className={styles.warningIcon} />
|
||||
<div>
|
||||
<strong>路径净空尚未完成三维验证</strong>
|
||||
<p>模型表面高度不等于安全飞行高度。下发时将取当前安全高度与目标净空高度中的较大值。</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className={styles.parameterSection}>
|
||||
<div className={styles.sectionTitle}>飞行参数</div>
|
||||
<div className={styles.parameterGrid}>
|
||||
<label className={styles.parameterField}>
|
||||
<span>目标净空</span>
|
||||
<InputNumber value={clearanceMeters} min={10} max={200} controls={false} onChange={(v) => setClearanceMeters(v ?? 30)} />
|
||||
<em>m</em>
|
||||
</label>
|
||||
<label className={styles.parameterField}>
|
||||
<span>最大速度</span>
|
||||
<InputNumber value={maxSpeed} min={1} max={15} controls={false} onChange={(v) => setMaxSpeed(v ?? 12)} />
|
||||
<em>m/s</em>
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Checkbox className={styles.riskCheck} checked={riskAcknowledged} onChange={(e) => setRiskAcknowledged(e.target.checked)}>
|
||||
我已知晓路径净空未验证,确认继续飞行
|
||||
</Checkbox>
|
||||
|
||||
<footer className={styles.actions}>
|
||||
<Button className={styles.discardButton} onClick={onCancelTarget}>丢弃</Button>
|
||||
<Button className={styles.sendButton} type="primary" loading={isSending} disabled={!riskAcknowledged} icon={<SendOutlined />} onClick={() => onConfirmFly(clearanceMeters, maxSpeed, riskAcknowledged)}>
|
||||
{currentTarget ? '发送改飞' : '发送飞行'}
|
||||
</Button>
|
||||
</footer>
|
||||
</aside>}
|
||||
</>;
|
||||
};
|
||||
|
||||
export default FlyToPointPanel;
|
||||
@@ -0,0 +1,216 @@
|
||||
import { useState, useCallback, useRef, useEffect } from 'react';
|
||||
import { message } from 'antd';
|
||||
import * as missionApi from '@/services/mission';
|
||||
import type { DroneData } from './useDroneSSE';
|
||||
|
||||
export type FlyToPointState = 'IDLE' | 'TAKING_OFF' | 'WAITING_TARGET' | 'FLYING_TO' | 'RETURNING' | 'COMPLETED';
|
||||
|
||||
export interface TargetPoint {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
candidateSurfaceHeight: number;
|
||||
clearanceStatus: 'VERIFIED' | 'UNVERIFIED';
|
||||
clearanceMeters: number;
|
||||
}
|
||||
|
||||
const SAFE_HEIGHT = 5;
|
||||
const ARRIVAL_THRESHOLD = 5;
|
||||
const LANDED_THRESHOLD = 2;
|
||||
const DEFAULT_CLEARANCE = 30;
|
||||
|
||||
export function useFlyToPoint(droneData: DroneData | null, onStarted?: (deviceSn: string) => void, isDroneInDock?: boolean) {
|
||||
const [state, setState] = useState<FlyToPointState>('IDLE');
|
||||
const [missionCode, setMissionCode] = useState<string | null>(null);
|
||||
const [deviceSn, setDeviceSn] = useState<string | null>(null);
|
||||
const [candidateTarget, setCandidateTarget] = useState<TargetPoint | null>(null);
|
||||
const [currentTarget, setCurrentTarget] = useState<TargetPoint | null>(null);
|
||||
const [distanceToTarget, setDistanceToTarget] = useState(0);
|
||||
const [isSending, setIsSending] = useState(false);
|
||||
|
||||
const stateRef = useRef(state);
|
||||
const candidateRef = useRef(candidateTarget);
|
||||
const targetRef = useRef(currentTarget);
|
||||
const missionCodeRef = useRef(missionCode);
|
||||
const takeoffElevationRef = useRef<number>(0); // 记录起飞时的椭球高
|
||||
const returnTimerRef = useRef<NodeJS.Timeout | null>(null); // 返航超时兜底
|
||||
stateRef.current = state;
|
||||
candidateRef.current = candidateTarget;
|
||||
targetRef.current = currentTarget;
|
||||
missionCodeRef.current = missionCode;
|
||||
|
||||
const startFlyToPoint = useCallback(async (sn: string, dockLat?: number, dockLng?: number, dockH?: number) => {
|
||||
try {
|
||||
setState('TAKING_OFF');
|
||||
setDeviceSn(sn);
|
||||
takeoffElevationRef.current = droneData?.elevation ?? droneData?.height ?? 0;
|
||||
const res = await missionApi.startFlyToPoint({
|
||||
deviceSn: sn,
|
||||
dockLatitude: dockLat,
|
||||
dockLongitude: dockLng,
|
||||
dockHeight: dockH,
|
||||
isAirborne: (droneData?.height ?? 0) > SAFE_HEIGHT || ((droneData?.elevation ?? 0) - takeoffElevationRef.current) > SAFE_HEIGHT,
|
||||
});
|
||||
if (res?.resp_code !== 0 || !res?.data?.missionCode) {
|
||||
throw new Error(res?.resp_msg || '启动失败');
|
||||
}
|
||||
setMissionCode(res.data.missionCode);
|
||||
if ((droneData?.height ?? 0) > SAFE_HEIGHT) setState('WAITING_TARGET');
|
||||
onStarted?.(sn);
|
||||
message.success('指点飞行任务已启动');
|
||||
} catch (error: any) {
|
||||
message.error(`开始指点飞行失败:${error?.message || '请重试'}`);
|
||||
setState('IDLE');
|
||||
setDeviceSn(null);
|
||||
}
|
||||
}, [droneData, onStarted]);
|
||||
|
||||
const selectTarget = useCallback((longitude: number, latitude: number, candidateSurfaceHeight: number) => {
|
||||
if (!['TAKING_OFF', 'WAITING_TARGET', 'FLYING_TO'].includes(stateRef.current)) return;
|
||||
// 第一版不把不可验证的模型表面伪装成已验证的安全路径。
|
||||
setCandidateTarget({
|
||||
longitude,
|
||||
latitude,
|
||||
candidateSurfaceHeight,
|
||||
clearanceStatus: 'UNVERIFIED',
|
||||
clearanceMeters: DEFAULT_CLEARANCE,
|
||||
});
|
||||
}, []);
|
||||
|
||||
const cancelTarget = useCallback(() => setCandidateTarget(null), []);
|
||||
|
||||
const confirmFly = useCallback(async (clearanceMeters: number, maxSpeed = 12, riskAcknowledged = false) => {
|
||||
const target = candidateRef.current;
|
||||
const code = missionCodeRef.current;
|
||||
if (!target || !code) return;
|
||||
if (!riskAcknowledged && target.clearanceStatus !== 'VERIFIED') {
|
||||
message.warning('请确认路径净空尚未验证的飞行风险');
|
||||
return;
|
||||
}
|
||||
|
||||
// 高度以当前无人机椭球高度为下限,模型命中高度仅作为障碍物顶高度候选。
|
||||
const targetEllipsoidHeight = Math.max(
|
||||
droneData?.elevation ?? Number.NEGATIVE_INFINITY,
|
||||
target.candidateSurfaceHeight + clearanceMeters,
|
||||
);
|
||||
if (!Number.isFinite(targetEllipsoidHeight)) {
|
||||
message.error('缺少无人机高度和模型高度,无法计算安全目标高度');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSending(true);
|
||||
try {
|
||||
const res = await missionApi.flyToPointUpdate({
|
||||
missionCode: code,
|
||||
latitude: target.latitude,
|
||||
longitude: target.longitude,
|
||||
height: targetEllipsoidHeight,
|
||||
maxSpeed,
|
||||
clearanceStatus: target.clearanceStatus,
|
||||
clearanceMeters,
|
||||
candidateSurfaceHeight: target.candidateSurfaceHeight,
|
||||
riskAcknowledged,
|
||||
riskReason: target.clearanceStatus === 'VERIFIED' ? undefined : '路径净空尚未完成三维验证',
|
||||
});
|
||||
if (res?.resp_code !== 0) throw new Error(res?.resp_msg || '命令发送失败');
|
||||
setCurrentTarget({ ...target, clearanceMeters });
|
||||
setCandidateTarget(null);
|
||||
setState('FLYING_TO');
|
||||
message.success(currentTarget ? '已发送改飞指令' : '已发送飞往目标指令');
|
||||
} catch (error: any) {
|
||||
message.error(`发送目标失败:${error?.message || '请重试'}`);
|
||||
} finally {
|
||||
setIsSending(false);
|
||||
}
|
||||
}, [droneData, currentTarget]);
|
||||
|
||||
const endFlight = useCallback(async () => {
|
||||
const code = missionCodeRef.current;
|
||||
if (!code) return;
|
||||
setState('RETURNING');
|
||||
try {
|
||||
const res = await missionApi.endFlyToPoint(code);
|
||||
if (res?.resp_code !== 0) throw new Error(res?.resp_msg || '结束失败');
|
||||
setCandidateTarget(null);
|
||||
message.success('正在返航,等待降落');
|
||||
} catch (error: any) {
|
||||
message.error(`结束飞行失败:${error?.message || '请重试'}`);
|
||||
setState(currentTarget ? 'FLYING_TO' : 'WAITING_TARGET');
|
||||
}
|
||||
}, [currentTarget]);
|
||||
|
||||
const cancel = useCallback(() => {
|
||||
setState('IDLE');
|
||||
setMissionCode(null);
|
||||
setDeviceSn(null);
|
||||
setCandidateTarget(null);
|
||||
setCurrentTarget(null);
|
||||
setDistanceToTarget(0);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// RETURNING 超时兜底:120 秒后自动完成(SSE 断流时也能正常结束)
|
||||
if (stateRef.current === 'RETURNING' && !returnTimerRef.current) {
|
||||
returnTimerRef.current = setTimeout(() => {
|
||||
if (stateRef.current === 'RETURNING' && missionCodeRef.current) {
|
||||
missionApi.completeMission(missionCodeRef.current).finally(() => {
|
||||
setState('COMPLETED');
|
||||
message.success('指点飞行完成(超时自动结束)');
|
||||
});
|
||||
}
|
||||
}, 120_000);
|
||||
}
|
||||
if (stateRef.current !== 'RETURNING' && returnTimerRef.current) {
|
||||
clearTimeout(returnTimerRef.current);
|
||||
returnTimerRef.current = null;
|
||||
}
|
||||
|
||||
if (!droneData) return;
|
||||
const relHeight = droneData.height ?? 0;
|
||||
const elevation = droneData.elevation ?? 0;
|
||||
// 起飞检测:相对高度 > 5m,或椭球高相对起飞基准升高 > 5m
|
||||
const isAirborne = relHeight > SAFE_HEIGHT || (elevation - takeoffElevationRef.current) > SAFE_HEIGHT;
|
||||
const target = targetRef.current;
|
||||
if (stateRef.current === 'TAKING_OFF' && isAirborne) {
|
||||
setState('WAITING_TARGET');
|
||||
message.success('无人机已升空,请在地图上点击候选目标');
|
||||
}
|
||||
if (stateRef.current === 'FLYING_TO' && target && droneData.latitude != null && droneData.longitude != null) {
|
||||
const distance = getHorizontalDistance(droneData.latitude, droneData.longitude, target.latitude, target.longitude);
|
||||
setDistanceToTarget(distance);
|
||||
if (distance < ARRIVAL_THRESHOLD) {
|
||||
setState('WAITING_TARGET');
|
||||
setCurrentTarget(null);
|
||||
message.success('已到达目标位置,可继续点选下一个目标');
|
||||
}
|
||||
}
|
||||
// RETURNING 状态:检测无人机是否已回库
|
||||
// elevation 回到起飞基准附近 + 相对高度接近0,判定回库
|
||||
const elevBackToBase = Math.abs(elevation - takeoffElevationRef.current) < 3;
|
||||
const hasLanded = relHeight < 3;
|
||||
if (stateRef.current === 'RETURNING' && (isDroneInDock || elevBackToBase || hasLanded) && missionCodeRef.current) {
|
||||
missionApi.completeMission(missionCodeRef.current).finally(() => {
|
||||
setState('COMPLETED');
|
||||
message.success('指点飞行完成,无人机已回库');
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
if (returnTimerRef.current) {
|
||||
clearTimeout(returnTimerRef.current);
|
||||
returnTimerRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [droneData]);
|
||||
|
||||
return {
|
||||
state, missionCode, deviceSn, candidateTarget, currentTarget, distanceToTarget, isSending,
|
||||
startFlyToPoint, selectTarget, cancelTarget, confirmFly, endFlight, cancel,
|
||||
isAirborne: (droneData?.height ?? 0) > SAFE_HEIGHT || ((droneData?.elevation ?? 0) - takeoffElevationRef.current) > SAFE_HEIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
function getHorizontalDistance(lat1: number, lng1: number, lat2: number, lng2: number): number {
|
||||
const dLat = ((lat2 - lat1) * Math.PI) / 180;
|
||||
const dLng = ((lng2 - lng1) * Math.PI) / 180;
|
||||
const a = Math.sin(dLat / 2) ** 2 + Math.cos((lat1 * Math.PI) / 180) * Math.cos((lat2 * Math.PI) / 180) * Math.sin(dLng / 2) ** 2;
|
||||
return 6371000 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
}
|
||||
+13
-5
@@ -93,16 +93,19 @@ export const useTilesetLoader = (): UseTilesetLoaderResult => {
|
||||
});
|
||||
|
||||
try {
|
||||
// 处理跨域问题:非 localhost 访问时将 CDN URL 转换为代理路径
|
||||
// 处理跨域问题:将 CDN URL 转换为代理路径(始终使用代理,避免 CORS)
|
||||
let tilesetUrl = config.url;
|
||||
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
|
||||
if (!isLocalhost && tilesetUrl.includes('minicdn.goflytec.com')) {
|
||||
if (tilesetUrl.includes('minicdn.goflytec.com')) {
|
||||
tilesetUrl = tilesetUrl.replace('https://minicdn.goflytec.com', '');
|
||||
console.log('[Tileset] 使用代理路径:', tilesetUrl);
|
||||
}
|
||||
|
||||
// 使用 Resource 显式设置 baseUrl,确保外部 tileset 引用的相对路径正确解析
|
||||
const resource = Cesium.Resource.createIfNeeded(tilesetUrl);
|
||||
console.log('[Tileset] Resource URL:', resource.url, 'baseUrl:', resource.baseUrl);
|
||||
|
||||
// 创建3DTileset - 高清晰度渲染配置
|
||||
const tileset = await Cesium.Cesium3DTileset.fromUrl(tilesetUrl, {
|
||||
const tileset = await Cesium.Cesium3DTileset.fromUrl(resource, {
|
||||
// 核心清晰度控制 - 值越小越清晰(大疆司空使用约1-2)
|
||||
maximumScreenSpaceError: config.style?.maximumScreenSpaceError ?? 1,
|
||||
maximumMemoryUsage: config.style?.maximumMemoryUsage ?? 2048, // 增加内存以加载更多高精度瓦片
|
||||
@@ -127,7 +130,7 @@ export const useTilesetLoader = (): UseTilesetLoaderResult => {
|
||||
foveatedMinimumScreenSpaceErrorRelaxation: 0.0,
|
||||
|
||||
// 裁剪优化 - 减少移动时的清晰度降低
|
||||
cullWithChildrenBounds: true,
|
||||
cullWithChildrenBounds: false, // 外部 tileset 引用的模型必须关闭,否则子 tileset 会被错误裁剪
|
||||
cullRequestsWhileMoving: false, // 禁用移动时的请求裁剪
|
||||
cullRequestsWhileMovingMultiplier: 1.0,
|
||||
|
||||
@@ -154,6 +157,11 @@ export const useTilesetLoader = (): UseTilesetLoaderResult => {
|
||||
});
|
||||
});
|
||||
|
||||
// 监听瓦片加载失败(外部 tileset 引用失败会在这里体现)
|
||||
tileset.tileFailed.addEventListener((error: any) => {
|
||||
console.error(`[Tileset] 模型 [${config.name}] 瓦片加载失败:`, error);
|
||||
});
|
||||
|
||||
// 模型位置调整 - 根据当前地形类型选择对应的高度偏移
|
||||
if (config.position) {
|
||||
const { longitude = 0, latitude = 0, cesiumHeight, arcgisHeight } = config.position;
|
||||
|
||||
@@ -9,6 +9,8 @@ import RouteEditor from '../RouteEditor';
|
||||
import BoundaryEditor from '../BoundaryEditor';
|
||||
import { useTilesetLoader, TilesetConfig } from './3d/hooks/useTilesetLoader';
|
||||
import { useDroneSSE } from './3d/hooks/useDroneSSE';
|
||||
import { useFlyToPoint } from './3d/hooks/useFlyToPoint';
|
||||
import FlyToPointPanel from './3d/components/FlyToPointPanel';
|
||||
import { getModelsByDeviceSn, convertToTilesetConfig } from '@/services/threeDModel';
|
||||
import TilesetPanel from "@/pages/map3d/components/MapContainer/3d/TilesetPanel";
|
||||
|
||||
@@ -21,6 +23,24 @@ const DEFAULT_GLOBAL_VIEW = {
|
||||
height: 19000000,
|
||||
};
|
||||
|
||||
const TERRAIN_LOAD_TIMEOUT_MS = 8000;
|
||||
|
||||
function withTimeout<T>(promise: Promise<T>, providerName: string): Promise<T> {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
const timer = window.setTimeout(() => reject(new Error(`${providerName} 地形服务连接超时`)), TERRAIN_LOAD_TIMEOUT_MS);
|
||||
promise.then(
|
||||
value => {
|
||||
window.clearTimeout(timer);
|
||||
resolve(value);
|
||||
},
|
||||
error => {
|
||||
window.clearTimeout(timer);
|
||||
reject(error);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
interface CesiumContainerProps {
|
||||
deviceList: any[];
|
||||
externalSelectedDevice?: any; // 接收外部选择的设备
|
||||
@@ -66,6 +86,49 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
const [droneDeviceSn, setDroneDeviceSn] = useState<string>('');
|
||||
const { droneData, connectDroneSSE, disconnectDroneSSE, resetDroneData } = useDroneSSE();
|
||||
|
||||
// 指点飞行
|
||||
const flyToPointStartedRef = useRef<(deviceSn: string) => void>();
|
||||
|
||||
// 无人机在库状态(来自实时数据)
|
||||
const isDroneInDock = useMemo(
|
||||
() => controlRealtimeData?.rawData?.dockData?.drone_in_dock === 1,
|
||||
[controlRealtimeData]
|
||||
);
|
||||
|
||||
const flyToPoint = useFlyToPoint(droneData, (deviceSn) => flyToPointStartedRef.current?.(deviceSn), isDroneInDock);
|
||||
const [flyToPointStartVisible, setFlyToPointStartVisible] = useState(false);
|
||||
const [pendingFlyDeviceSn, setPendingFlyDeviceSn] = useState<string | null>(null);
|
||||
const [pendingDockCoords, setPendingDockCoords] = useState<{lat?: number; lng?: number; height?: number}>({});
|
||||
|
||||
// 激活指点飞行(从 RightPanel 按钮触发,仅打开确认弹窗)
|
||||
const handleFlyToPointActivate = useCallback((deviceSn: string, dockLat?: number, dockLng?: number, dockH?: number) => {
|
||||
setPendingFlyDeviceSn(deviceSn);
|
||||
setPendingDockCoords({ lat: dockLat, lng: dockLng, height: dockH });
|
||||
setFlyToPointStartVisible(true);
|
||||
}, []);
|
||||
|
||||
// 确认开始指点飞行
|
||||
const handleFlyToPointConfirm = useCallback(() => {
|
||||
setFlyToPointStartVisible(false);
|
||||
if (pendingFlyDeviceSn) {
|
||||
flyToPoint.startFlyToPoint(pendingFlyDeviceSn, pendingDockCoords.lat, pendingDockCoords.lng, pendingDockCoords.height);
|
||||
setPendingFlyDeviceSn(null);
|
||||
setPendingDockCoords({});
|
||||
}
|
||||
}, [pendingFlyDeviceSn, pendingDockCoords, flyToPoint]);
|
||||
|
||||
// 取消指点飞行
|
||||
const handleFlyToPointCancel = useCallback(() => {
|
||||
setFlyToPointStartVisible(false);
|
||||
setPendingFlyDeviceSn(null);
|
||||
}, []);
|
||||
|
||||
// 指点飞行目标标记实体 ref
|
||||
const flyTargetEntityRef = useRef<any>(null);
|
||||
const flyCandidateEntityRef = useRef<any>(null);
|
||||
const flyToPointStateRef = useRef(flyToPoint.state);
|
||||
flyToPointStateRef.current = flyToPoint.state;
|
||||
|
||||
// 无人机位置渲染相关引用
|
||||
const droneEntityRef = useRef<any>(null);
|
||||
const flightTrackEntityRef = useRef<any>(null);
|
||||
@@ -80,6 +143,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
const [modelLoading, setModelLoading] = useState(false);
|
||||
const [terrainLoading, setTerrainLoading] = useState(false); // 是否正在加载高程地形
|
||||
const terrainLoadedRef = useRef(false); // 是否已加载高程地形
|
||||
const terrainRequestIdRef = useRef(0);
|
||||
const {
|
||||
tilesets,
|
||||
loadTileset,
|
||||
@@ -143,6 +207,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
return 'loaded';
|
||||
}
|
||||
|
||||
const requestId = ++terrainRequestIdRef.current;
|
||||
setTerrainLoading(true);
|
||||
console.log('开始加载高程地形...', preferredTerrainType ? `优先使用: ${preferredTerrainType}` : '');
|
||||
|
||||
@@ -152,9 +217,9 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
if (preferredTerrainType === 'arcgis') {
|
||||
// 优先尝试 ArcGIS
|
||||
try {
|
||||
const terrainProvider = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
|
||||
const terrainProvider = await withTimeout(Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
|
||||
'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer'
|
||||
);
|
||||
), 'ArcGIS');
|
||||
console.log('高程地形加载成功: ArcGIS World Elevation (根据模型配置)');
|
||||
viewerRef.current.terrainProvider = terrainProvider;
|
||||
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
|
||||
@@ -163,10 +228,10 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
} catch (arcgisError) {
|
||||
console.warn('ArcGIS 加载失败,尝试 Cesium Ion:', arcgisError);
|
||||
try {
|
||||
const terrainProvider = await Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
|
||||
const terrainProvider = await withTimeout(Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
|
||||
requestVertexNormals: true,
|
||||
requestWaterMask: true,
|
||||
});
|
||||
}), 'Cesium Ion');
|
||||
console.log('高程地形加载成功: Cesium World Terrain (备用)');
|
||||
viewerRef.current.terrainProvider = terrainProvider;
|
||||
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
|
||||
@@ -181,10 +246,10 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
} else {
|
||||
// 默认优先尝试 Cesium Ion
|
||||
try {
|
||||
const terrainProvider = await Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
|
||||
const terrainProvider = await withTimeout(Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
|
||||
requestVertexNormals: true,
|
||||
requestWaterMask: true,
|
||||
});
|
||||
}), 'Cesium Ion');
|
||||
console.log('高程地形加载成功: Cesium World Terrain');
|
||||
viewerRef.current.terrainProvider = terrainProvider;
|
||||
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
|
||||
@@ -193,9 +258,9 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
} catch (cesiumError) {
|
||||
console.warn('Cesium World Terrain 加载失败,尝试 ArcGIS:', cesiumError);
|
||||
try {
|
||||
const terrainProvider = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
|
||||
const terrainProvider = await withTimeout(Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
|
||||
'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer'
|
||||
);
|
||||
), 'ArcGIS');
|
||||
console.log('高程地形加载成功: ArcGIS World Elevation');
|
||||
viewerRef.current.terrainProvider = terrainProvider;
|
||||
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
|
||||
@@ -211,7 +276,9 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
setTerrainLoading(false);
|
||||
if (terrainRequestIdRef.current === requestId) {
|
||||
setTerrainLoading(false);
|
||||
}
|
||||
return loadedTerrainType;
|
||||
}, []);
|
||||
|
||||
@@ -391,6 +458,18 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
}
|
||||
}, [droneDeviceSn, disconnectDroneSSE, connectDroneSSE, clearDroneLayers]);
|
||||
|
||||
flyToPointStartedRef.current = (deviceSn: string) => {
|
||||
const device = selectedDevice?.deviceSn === deviceSn ? selectedDevice : { deviceSn };
|
||||
setRightPanelVisible(false);
|
||||
handleOpenControl(device, controlRealtimeData);
|
||||
};
|
||||
|
||||
// 一键起飞成功后切换到操控台,便于立即查看视频和实时飞行状态。
|
||||
const handleTakeoffSuccess = useCallback((device: any, realtimeData: any) => {
|
||||
setRightPanelVisible(false);
|
||||
handleOpenControl(device, realtimeData);
|
||||
}, [handleOpenControl]);
|
||||
|
||||
// 关闭操控台 - 断开无人机SSE
|
||||
const handleCloseControl = useCallback(() => {
|
||||
setLeftPanelVisible(false);
|
||||
@@ -936,6 +1015,47 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
}
|
||||
|
||||
handler.setInputAction((movement: any) => {
|
||||
// 指点飞行模式:优先处理地图点击
|
||||
if (['TAKING_OFF', 'WAITING_TARGET', 'FLYING_TO'].includes(flyToPointStateRef.current)) {
|
||||
const cartesian = viewer.scene.pickPosition(movement.position);
|
||||
if (Cesium.defined(cartesian)) {
|
||||
const cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
||||
const lng = Cesium.Math.toDegrees(cartographic.longitude);
|
||||
const lat = Cesium.Math.toDegrees(cartographic.latitude);
|
||||
const cartographicHeight = cartographic.height; // WGS84 椭球高
|
||||
|
||||
// 蓝色标记表示尚未发送的候选点,避免与当前飞行目标混淆。
|
||||
if (flyCandidateEntityRef.current) {
|
||||
viewer.entities.remove(flyCandidateEntityRef.current);
|
||||
}
|
||||
flyCandidateEntityRef.current = viewer.entities.add({
|
||||
position: Cesium.Cartesian3.fromDegrees(lng, lat, cartographicHeight),
|
||||
point: {
|
||||
pixelSize: 16,
|
||||
color: Cesium.Color.CYAN,
|
||||
outlineColor: Cesium.Color.WHITE,
|
||||
outlineWidth: 2,
|
||||
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
||||
},
|
||||
label: {
|
||||
text: '候选目标(未发送)',
|
||||
font: '14px sans-serif',
|
||||
fillColor: Cesium.Color.CYAN,
|
||||
outlineColor: Cesium.Color.WHITE,
|
||||
outlineWidth: 2,
|
||||
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
||||
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||
pixelOffset: new Cesium.Cartesian2(0, -20),
|
||||
},
|
||||
});
|
||||
|
||||
flyToPoint.selectTarget(lng, lat, cartographicHeight);
|
||||
return; // 不执行设备选择逻辑
|
||||
}
|
||||
message.info('未能获取目标表面高度,请选择可见模型或地形位置');
|
||||
return;
|
||||
}
|
||||
|
||||
const pickedObject = viewer.scene.pick(movement.position);
|
||||
if (Cesium.defined(pickedObject) && pickedObject.id) {
|
||||
const entity = pickedObject.id;
|
||||
@@ -974,6 +1094,27 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
};
|
||||
}, [loading, handleDeviceSelect]);
|
||||
|
||||
useEffect(() => {
|
||||
const viewer = viewerRef.current;
|
||||
if (!viewer || !Cesium) return;
|
||||
if (!flyToPoint.candidateTarget && flyCandidateEntityRef.current) {
|
||||
viewer.entities.remove(flyCandidateEntityRef.current);
|
||||
flyCandidateEntityRef.current = null;
|
||||
}
|
||||
if (flyTargetEntityRef.current) {
|
||||
viewer.entities.remove(flyTargetEntityRef.current);
|
||||
flyTargetEntityRef.current = null;
|
||||
}
|
||||
const target = flyToPoint.currentTarget;
|
||||
if (target) {
|
||||
flyTargetEntityRef.current = viewer.entities.add({
|
||||
position: Cesium.Cartesian3.fromDegrees(target.longitude, target.latitude, target.candidateSurfaceHeight),
|
||||
point: { pixelSize: 15, color: Cesium.Color.ORANGE, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, heightReference: Cesium.HeightReference.CLAMP_TO_GROUND },
|
||||
label: { text: '当前飞行目标', font: '14px sans-serif', fillColor: Cesium.Color.ORANGE, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, style: Cesium.LabelStyle.FILL_AND_OUTLINE, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, pixelOffset: new Cesium.Cartesian2(0, -20) },
|
||||
});
|
||||
}
|
||||
}, [flyToPoint.candidateTarget, flyToPoint.currentTarget]);
|
||||
|
||||
// @ts-ignore
|
||||
return (
|
||||
<div style={{ width: '100%', height: '100%', position: 'relative' }}>
|
||||
@@ -1144,12 +1285,32 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
onClose={handleRightPanelClose}
|
||||
onMinimize={handleRightPanelMinimize}
|
||||
onControlClick={handleOpenControl}
|
||||
onTakeoffSuccess={handleTakeoffSuccess}
|
||||
onTaskPanelOpen={handleOpenTaskPanel}
|
||||
onRoutePlanningOpen={handleOpenRoutePlanning}
|
||||
onFlyToPointActivate={handleFlyToPointActivate}
|
||||
flyToPointState={flyToPoint.state}
|
||||
viewer={viewerRef.current}
|
||||
Cesium={Cesium}
|
||||
/>
|
||||
|
||||
{/* 指点飞行面板 */}
|
||||
<FlyToPointPanel
|
||||
visible={flyToPointStartVisible}
|
||||
state={flyToPoint.state}
|
||||
missionCode={flyToPoint.missionCode}
|
||||
candidateTarget={flyToPoint.candidateTarget}
|
||||
currentTarget={flyToPoint.currentTarget}
|
||||
distanceToTarget={flyToPoint.distanceToTarget}
|
||||
isAirborne={flyToPoint.isAirborne}
|
||||
isSending={flyToPoint.isSending}
|
||||
onConfirmStart={handleFlyToPointConfirm}
|
||||
onCancelStart={handleFlyToPointCancel}
|
||||
onConfirmFly={flyToPoint.confirmFly}
|
||||
onCancelTarget={flyToPoint.cancelTarget}
|
||||
onEndFlight={flyToPoint.endFlight}
|
||||
/>
|
||||
|
||||
{/* 任务管理面板 - 左下角独立渲染 */}
|
||||
<TaskPanel
|
||||
visible={taskPanelVisible}
|
||||
|
||||
@@ -142,6 +142,18 @@ export const deviceApi = {
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 切换直播镜头(如 zoom / wide / normal / ir)
|
||||
liveLensChange: async (params: { deviceSn: string; videoType: 'zoom' | 'wide' | 'normal' | 'ir' }): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/liveLensChange', { method: 'POST', data: params });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 设置变焦倍数(2~200)
|
||||
cameraFocalLengthSet: async (params: { deviceSn: string; zoomFactor: number }): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/cameraFocalLengthSet', { method: 'POST', data: params });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 订阅无人机遥测
|
||||
subscribeDroneTelemetry: async (deviceSn: string): Promise<{ success: boolean; message?: string }> => {
|
||||
try {
|
||||
|
||||
@@ -6,6 +6,8 @@ import { request } from 'umi';
|
||||
export enum MissionType {
|
||||
WAYLINE = 1, // 航线任务
|
||||
TAKEOFF = 2, // 一键起飞任务
|
||||
BOAT_ROUTE = 3, // 无人船航线任务
|
||||
FLY_TO_POINT = 4, // 指点飞行任务
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,6 +28,8 @@ export enum MissionStatus {
|
||||
export const MissionTypeMap: Record<number, string> = {
|
||||
[MissionType.WAYLINE]: '航线任务',
|
||||
[MissionType.TAKEOFF]: '一键起飞',
|
||||
[MissionType.BOAT_ROUTE]: '无人船航线',
|
||||
[MissionType.FLY_TO_POINT]: '指点飞行',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -274,3 +278,52 @@ export async function countMissionImage(missionCode: string) {
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== 指点飞行编排接口 ====================
|
||||
|
||||
/**
|
||||
* 开始指点飞行
|
||||
*/
|
||||
export async function startFlyToPoint(params: {
|
||||
deviceSn: string;
|
||||
dockLatitude?: number;
|
||||
dockLongitude?: number;
|
||||
dockHeight?: number;
|
||||
isAirborne?: boolean;
|
||||
}) {
|
||||
return request<API.Result<{ missionCode: string }>>('/api-order/mission/startFlyToPoint', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指点飞行目标点
|
||||
*/
|
||||
export async function flyToPointUpdate(params: {
|
||||
missionCode: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
height: number;
|
||||
maxSpeed?: number;
|
||||
clearanceStatus: 'VERIFIED' | 'UNVERIFIED';
|
||||
clearanceMeters?: number;
|
||||
candidateSurfaceHeight?: number;
|
||||
riskAcknowledged: boolean;
|
||||
riskReason?: string;
|
||||
}) {
|
||||
return request<API.Result<string>>('/api-order/mission/flyToPointUpdate', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束指点飞行
|
||||
*/
|
||||
export async function endFlyToPoint(missionCode: string) {
|
||||
return request<API.Result<string>>('/api-order/mission/endFlyToPoint', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user