feat:添加无人船慢速行驶指令
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,36 @@
|
|||||||
border: 1px solid rgba(34, 211, 238, 0.3);
|
border: 1px solid rgba(34, 211, 238, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.viewSwitchBar {
|
||||||
|
position: absolute;
|
||||||
|
top: 18px;
|
||||||
|
right: 18px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
z-index: 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewSwitchBtn {
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 14px;
|
||||||
|
border: 1px solid rgba(34, 211, 238, 0.35);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(8, 15, 28, 0.82);
|
||||||
|
color: #d8f6ff;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-color: rgba(34, 211, 238, 0.7);
|
||||||
|
color: #fff;
|
||||||
|
box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.18), 0 8px 22px rgba(0, 0, 0, 0.22);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.loadingSpinner {
|
.loadingSpinner {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,395 @@
|
|||||||
|
@bg-sidebar: #0f172a;
|
||||||
|
@bg-card: #1e293b;
|
||||||
|
@bg-deep: #0a0f1c;
|
||||||
|
@border-color: #1e3a5f;
|
||||||
|
@accent-cyan: #22d3ee;
|
||||||
|
@accent-orange: #f97316;
|
||||||
|
@text-primary: #ffffff;
|
||||||
|
@text-secondary: #94a3b8;
|
||||||
|
@text-dim: #64748b;
|
||||||
|
@font-mono: 'JetBrains Mono', 'Courier New', monospace;
|
||||||
|
@font-sans: 'Inter', -apple-system, sans-serif;
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
width: 340px;
|
||||||
|
height: 100%;
|
||||||
|
background: @bg-sidebar;
|
||||||
|
border-left: 1px solid @border-color;
|
||||||
|
padding: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(34, 211, 238, 0.22);
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
background: linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.96));
|
||||||
|
border: 1px solid @border-color;
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 14px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sectionHeader {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sectionTitle {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: @text-primary;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
font-family: @font-sans;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sectionTag {
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid rgba(34, 211, 238, 0.28);
|
||||||
|
background: rgba(34, 211, 238, 0.08);
|
||||||
|
color: @accent-cyan;
|
||||||
|
font-size: 10px;
|
||||||
|
font-family: @font-mono;
|
||||||
|
}
|
||||||
|
|
||||||
|
.videoCard {
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #050a14;
|
||||||
|
height: 196px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.videoPlaceholder {
|
||||||
|
min-height: 196px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: @text-secondary;
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at top, rgba(34, 211, 238, 0.10), transparent 52%),
|
||||||
|
linear-gradient(180deg, rgba(7, 11, 21, 0.96), rgba(4, 8, 15, 0.98));
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholderIcon {
|
||||||
|
font-size: 26px;
|
||||||
|
color: @accent-cyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholderTitle {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: @text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholderDesc {
|
||||||
|
font-size: 11px;
|
||||||
|
color: @text-dim;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockVideoCard {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at 50% 18%, rgba(34, 211, 238, 0.24), transparent 28%),
|
||||||
|
linear-gradient(180deg, #0a1830 0%, #08111f 38%, #06111a 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockVideoGlow {
|
||||||
|
position: absolute;
|
||||||
|
inset: -10% -20% auto;
|
||||||
|
height: 65%;
|
||||||
|
background: radial-gradient(circle, rgba(34, 211, 238, 0.18), transparent 60%);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockVideoScanline {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, transparent 0%, rgba(34, 211, 238, 0.1) 48%, transparent 100%),
|
||||||
|
repeating-linear-gradient(
|
||||||
|
180deg,
|
||||||
|
rgba(255, 255, 255, 0.02) 0,
|
||||||
|
rgba(255, 255, 255, 0.02) 2px,
|
||||||
|
transparent 2px,
|
||||||
|
transparent 6px
|
||||||
|
);
|
||||||
|
animation: videoSweep 4.2s linear infinite;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockVideoHud {
|
||||||
|
position: absolute;
|
||||||
|
top: 12px;
|
||||||
|
left: 12px;
|
||||||
|
right: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockVideoBadge,
|
||||||
|
.mockVideoMeta {
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(8, 15, 28, 0.68);
|
||||||
|
border: 1px solid rgba(34, 211, 238, 0.28);
|
||||||
|
color: @accent-cyan;
|
||||||
|
font-size: 10px;
|
||||||
|
font-family: @font-mono;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockVideoScene {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockHorizon {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 42%;
|
||||||
|
height: 1px;
|
||||||
|
background: rgba(255, 255, 255, 0.24);
|
||||||
|
box-shadow: 0 0 14px rgba(34, 211, 238, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockWave {
|
||||||
|
position: absolute;
|
||||||
|
left: -12%;
|
||||||
|
right: -12%;
|
||||||
|
bottom: 18%;
|
||||||
|
height: 44%;
|
||||||
|
border-radius: 42% 58% 0 0 / 20% 24% 0 0;
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(34, 211, 238, 0.22), rgba(8, 47, 73, 0.82)),
|
||||||
|
radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.18), transparent 45%);
|
||||||
|
animation: waveFloat 6s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockBoatMarker {
|
||||||
|
position: absolute;
|
||||||
|
right: 18px;
|
||||||
|
bottom: 28px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 7px 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(8, 15, 28, 0.72);
|
||||||
|
border: 1px solid rgba(34, 211, 238, 0.28);
|
||||||
|
color: @text-primary;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockBoatDot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: @accent-orange;
|
||||||
|
box-shadow: 0 0 0 5px rgba(249, 115, 22, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mockVideoFooter {
|
||||||
|
position: absolute;
|
||||||
|
left: 12px;
|
||||||
|
right: 12px;
|
||||||
|
bottom: 12px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
color: @text-secondary;
|
||||||
|
font-size: 10px;
|
||||||
|
font-family: @font-mono;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarCard {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarCanvas {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 220px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at center, rgba(34, 211, 238, 0.08), transparent 55%),
|
||||||
|
linear-gradient(180deg, rgba(6, 12, 24, 0.98), rgba(10, 15, 28, 0.98));
|
||||||
|
border: 1px solid rgba(34, 211, 238, 0.16);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarSvg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarRing {
|
||||||
|
fill: none;
|
||||||
|
stroke: rgba(148, 163, 184, 0.18);
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarAxis {
|
||||||
|
stroke: rgba(148, 163, 184, 0.14);
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarPoint {
|
||||||
|
fill: @accent-orange;
|
||||||
|
opacity: 0.92;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarSweep {
|
||||||
|
stroke: rgba(34, 211, 238, 0.58);
|
||||||
|
stroke-width: 1.5;
|
||||||
|
stroke-linecap: round;
|
||||||
|
filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.45));
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarEmpty {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
color: @text-secondary;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarMetrics {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricItem,
|
||||||
|
.metricMini {
|
||||||
|
background: rgba(10, 15, 28, 0.82);
|
||||||
|
border: 1px solid rgba(30, 58, 95, 0.7);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricRow {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricLabel {
|
||||||
|
font-size: 10px;
|
||||||
|
color: @text-dim;
|
||||||
|
font-family: @font-sans;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricValue {
|
||||||
|
font-size: 14px;
|
||||||
|
color: @text-primary;
|
||||||
|
font-family: @font-mono;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryGrid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryCard {
|
||||||
|
min-height: 86px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(30, 58, 95, 0.78);
|
||||||
|
background: rgba(10, 15, 28, 0.84);
|
||||||
|
padding: 12px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryIcon {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryLabel {
|
||||||
|
color: @text-dim;
|
||||||
|
font-size: 10px;
|
||||||
|
font-family: @font-sans;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryValue {
|
||||||
|
color: @text-primary;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.4;
|
||||||
|
font-family: @font-mono;
|
||||||
|
font-weight: 700;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1366px) {
|
||||||
|
.panel {
|
||||||
|
width: 300px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.videoCard {
|
||||||
|
height: 168px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lidarCanvas {
|
||||||
|
height: 190px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes videoSweep {
|
||||||
|
0% {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: translateY(100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes waveFloat {
|
||||||
|
0%, 100% {
|
||||||
|
transform: translateY(0) scaleX(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
transform: translateY(5px) scaleX(1.03);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
|
import {
|
||||||
|
VideoCameraOutlined,
|
||||||
|
RadarChartOutlined,
|
||||||
|
EnvironmentOutlined,
|
||||||
|
ThunderboltOutlined,
|
||||||
|
WifiOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import WhepPlayer from '@/pages/map3d/components/MapContainer/3d/BottomPanel/WhepPlayer';
|
||||||
|
import type { BoatRouteListVO, BoatTelemetryData } from '@/types/boatRoute';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
interface ExecRightPanelProps {
|
||||||
|
deviceInfo: any;
|
||||||
|
boatData: BoatTelemetryData | null;
|
||||||
|
activeRouteInfo: BoatRouteListVO | null;
|
||||||
|
sseConnected: boolean;
|
||||||
|
videoStreamUrl?: string;
|
||||||
|
isPreviewing?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LidarSample {
|
||||||
|
angle: number;
|
||||||
|
distance: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clampNumber = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));
|
||||||
|
|
||||||
|
const extractLidarSamples = (deviceInfo: any, boatData: BoatTelemetryData | null): LidarSample[] => {
|
||||||
|
const raw =
|
||||||
|
(boatData as any)?.lidarSamples ||
|
||||||
|
(boatData as any)?.lidarPoints ||
|
||||||
|
(boatData as any)?.lidarDistances ||
|
||||||
|
(deviceInfo as any)?.lidarSamples ||
|
||||||
|
(deviceInfo as any)?.lidarPoints ||
|
||||||
|
(deviceInfo as any)?.lidarDistances ||
|
||||||
|
[];
|
||||||
|
|
||||||
|
if (!Array.isArray(raw) || raw.length === 0) return [];
|
||||||
|
|
||||||
|
if (typeof raw[0] === 'number') {
|
||||||
|
return raw.map((distance: number, index: number) => ({
|
||||||
|
angle: (index / raw.length) * 360,
|
||||||
|
distance: Number(distance) || 0,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return raw
|
||||||
|
.map((item: any, index: number) => ({
|
||||||
|
angle: Number(item?.angle ?? item?.deg ?? item?.theta ?? (index / raw.length) * 360),
|
||||||
|
distance: Number(item?.distance ?? item?.range ?? item?.value ?? 0),
|
||||||
|
}))
|
||||||
|
.filter((item) => Number.isFinite(item.angle) && Number.isFinite(item.distance));
|
||||||
|
};
|
||||||
|
|
||||||
|
const createMockLidarSamples = (phase: number): LidarSample[] => (
|
||||||
|
Array.from({ length: 72 }, (_, index) => {
|
||||||
|
const angle = index * 5;
|
||||||
|
const wave = Math.sin((angle + phase * 28) * Math.PI / 180);
|
||||||
|
const ripple = Math.cos((angle * 2 + phase * 36) * Math.PI / 180);
|
||||||
|
const bump = (index % 9 === 0 ? 4.5 : 0) + (index % 13 === 0 ? 2.6 : 0);
|
||||||
|
const distance = clampNumber(16 + wave * 6 + ripple * 3 + bump, 3.6, 31);
|
||||||
|
return { angle, distance };
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const ExecRightPanel: React.FC<ExecRightPanelProps> = ({
|
||||||
|
deviceInfo,
|
||||||
|
boatData,
|
||||||
|
activeRouteInfo,
|
||||||
|
sseConnected,
|
||||||
|
videoStreamUrl,
|
||||||
|
isPreviewing = false,
|
||||||
|
}) => {
|
||||||
|
const [mockPhase, setMockPhase] = useState(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isPreviewing) return undefined;
|
||||||
|
const timer = window.setInterval(() => {
|
||||||
|
setMockPhase((value) => (value + 1) % 360);
|
||||||
|
}, 900);
|
||||||
|
return () => window.clearInterval(timer);
|
||||||
|
}, [isPreviewing]);
|
||||||
|
|
||||||
|
const realLidarSamples = useMemo(() => extractLidarSamples(deviceInfo, boatData), [deviceInfo, boatData]);
|
||||||
|
const lidarSamples = useMemo(
|
||||||
|
() => (isPreviewing ? createMockLidarSamples(mockPhase) : realLidarSamples),
|
||||||
|
[isPreviewing, mockPhase, realLidarSamples],
|
||||||
|
);
|
||||||
|
const hasBoatPosition = Number.isFinite(boatData?.longitude) && Number.isFinite(boatData?.latitude);
|
||||||
|
|
||||||
|
const lidarMetrics = useMemo(() => {
|
||||||
|
if (!lidarSamples.length) {
|
||||||
|
return {
|
||||||
|
minDistance: null,
|
||||||
|
frontDistance: null,
|
||||||
|
leftDistance: null,
|
||||||
|
rightDistance: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const pickClosest = (targetAngle: number) => {
|
||||||
|
const matched = lidarSamples.reduce((best, current) => {
|
||||||
|
const delta = Math.abs((((current.angle - targetAngle) % 360) + 540) % 360 - 180);
|
||||||
|
return delta < best.delta ? { delta, distance: current.distance } : best;
|
||||||
|
}, { delta: Number.POSITIVE_INFINITY, distance: 0 });
|
||||||
|
return matched.distance;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
minDistance: Math.min(...lidarSamples.map((item) => item.distance)),
|
||||||
|
frontDistance: pickClosest(0),
|
||||||
|
leftDistance: pickClosest(270),
|
||||||
|
rightDistance: pickClosest(90),
|
||||||
|
};
|
||||||
|
}, [lidarSamples]);
|
||||||
|
|
||||||
|
const lidarPoints = useMemo(() => {
|
||||||
|
if (!lidarSamples.length) return [];
|
||||||
|
const maxDistance = Math.max(10, ...lidarSamples.map((item) => item.distance));
|
||||||
|
const radius = 88;
|
||||||
|
|
||||||
|
return lidarSamples.slice(0, 72).map((sample) => {
|
||||||
|
const normalized = clampNumber(sample.distance / maxDistance, 0.08, 1);
|
||||||
|
const actualRadius = normalized * radius;
|
||||||
|
const angleRad = (sample.angle - 90) * Math.PI / 180;
|
||||||
|
return {
|
||||||
|
x: 110 + Math.cos(angleRad) * actualRadius,
|
||||||
|
y: 110 + Math.sin(angleRad) * actualRadius,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}, [lidarSamples]);
|
||||||
|
|
||||||
|
const statusItems = [
|
||||||
|
{
|
||||||
|
label: '设备状态',
|
||||||
|
value: isPreviewing ? '模拟预览' : (sseConnected ? '在线' : '离线'),
|
||||||
|
icon: <WifiOutlined />,
|
||||||
|
accent: isPreviewing ? '#22d3ee' : (sseConnected ? '#10b981' : '#ef4444'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '剩余电量',
|
||||||
|
value: `${boatData?.battery ?? (isPreviewing ? 86 : 0)}%`,
|
||||||
|
icon: <ThunderboltOutlined />,
|
||||||
|
accent: (boatData?.battery ?? 86) > 20 ? '#22d3ee' : '#f59e0b',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '当前位置',
|
||||||
|
value: hasBoatPosition ? `${boatData!.longitude.toFixed(4)}, ${boatData!.latitude.toFixed(4)}` : '--',
|
||||||
|
icon: <EnvironmentOutlined />,
|
||||||
|
accent: '#94a3b8',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const formatMeters = (distance: number | null) => (distance == null ? '--' : `${distance.toFixed(distance >= 10 ? 0 : 1)} m`);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.panel}>
|
||||||
|
<div className={styles.section}>
|
||||||
|
<div className={styles.sectionHeader}>
|
||||||
|
<span className={styles.sectionTitle}>
|
||||||
|
<VideoCameraOutlined />
|
||||||
|
视频回传
|
||||||
|
</span>
|
||||||
|
<span className={styles.sectionTag}>
|
||||||
|
{isPreviewing ? '模拟流' : (videoStreamUrl ? '实时流' : '未接入')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.videoCard}>
|
||||||
|
{isPreviewing ? (
|
||||||
|
<div className={styles.mockVideoCard}>
|
||||||
|
<div className={styles.mockVideoGlow} />
|
||||||
|
<div className={styles.mockVideoScanline} />
|
||||||
|
<div className={styles.mockVideoHud}>
|
||||||
|
<span className={styles.mockVideoBadge}>SIM CAM</span>
|
||||||
|
<span className={styles.mockVideoMeta}>1080P / 25 FPS</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.mockVideoScene}>
|
||||||
|
<div className={styles.mockHorizon} />
|
||||||
|
<div className={styles.mockWave} />
|
||||||
|
<div className={styles.mockBoatMarker}>
|
||||||
|
<span className={styles.mockBoatDot} />
|
||||||
|
<span>航线预览目标</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.mockVideoFooter}>
|
||||||
|
<span>模拟海况:2级</span>
|
||||||
|
<span>光照:良好</span>
|
||||||
|
<span>延迟:42ms</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : videoStreamUrl ? (
|
||||||
|
<WhepPlayer url={videoStreamUrl} autoPlay={true} muted={true} videoOnly={true} />
|
||||||
|
) : (
|
||||||
|
<div className={styles.videoPlaceholder}>
|
||||||
|
<VideoCameraOutlined className={styles.placeholderIcon} />
|
||||||
|
<div className={styles.placeholderTitle}>暂无视频流</div>
|
||||||
|
<div className={styles.placeholderDesc}>设备未配置 `videoStreamUrl` 或 `whepUrl`</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.section}>
|
||||||
|
<div className={styles.sectionHeader}>
|
||||||
|
<span className={styles.sectionTitle}>
|
||||||
|
<RadarChartOutlined />
|
||||||
|
激光雷达
|
||||||
|
</span>
|
||||||
|
<span className={styles.sectionTag}>
|
||||||
|
{isPreviewing ? `模拟 ${lidarSamples.length} 点` : (lidarSamples.length > 0 ? `${lidarSamples.length} 点` : '未接入')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.lidarCard}>
|
||||||
|
<div className={styles.lidarCanvas}>
|
||||||
|
<svg viewBox="0 0 220 220" className={styles.lidarSvg}>
|
||||||
|
<circle cx="110" cy="110" r="88" className={styles.lidarRing} />
|
||||||
|
<circle cx="110" cy="110" r="58" className={styles.lidarRing} />
|
||||||
|
<circle cx="110" cy="110" r="28" className={styles.lidarRing} />
|
||||||
|
<line x1="110" y1="14" x2="110" y2="206" className={styles.lidarAxis} />
|
||||||
|
<line x1="14" y1="110" x2="206" y2="110" className={styles.lidarAxis} />
|
||||||
|
<line
|
||||||
|
x1="110"
|
||||||
|
y1="110"
|
||||||
|
x2={110 + Math.cos((mockPhase - 90) * Math.PI / 180) * 96}
|
||||||
|
y2={110 + Math.sin((mockPhase - 90) * Math.PI / 180) * 96}
|
||||||
|
className={styles.lidarSweep}
|
||||||
|
/>
|
||||||
|
{lidarPoints.map((point, index) => (
|
||||||
|
<circle key={`${point.x}-${point.y}-${index}`} cx={point.x} cy={point.y} r="2.6" className={styles.lidarPoint} />
|
||||||
|
))}
|
||||||
|
</svg>
|
||||||
|
{lidarPoints.length === 0 && (
|
||||||
|
<div className={styles.lidarEmpty}>
|
||||||
|
<RadarChartOutlined className={styles.placeholderIcon} />
|
||||||
|
<span>暂无激光雷达数据</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.lidarMetrics}>
|
||||||
|
<div className={styles.metricItem}>
|
||||||
|
<span className={styles.metricLabel}>最近障碍距离</span>
|
||||||
|
<span className={styles.metricValue}>{formatMeters(lidarMetrics.minDistance)}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.metricRow}>
|
||||||
|
<div className={styles.metricMini}>
|
||||||
|
<span className={styles.metricLabel}>前方</span>
|
||||||
|
<span className={styles.metricValue}>{formatMeters(lidarMetrics.frontDistance)}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.metricMini}>
|
||||||
|
<span className={styles.metricLabel}>左侧</span>
|
||||||
|
<span className={styles.metricValue}>{formatMeters(lidarMetrics.leftDistance)}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.metricMini}>
|
||||||
|
<span className={styles.metricLabel}>右侧</span>
|
||||||
|
<span className={styles.metricValue}>{formatMeters(lidarMetrics.rightDistance)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.section}>
|
||||||
|
<div className={styles.sectionHeader}>
|
||||||
|
<span className={styles.sectionTitle}>执行摘要</span>
|
||||||
|
<span className={styles.sectionTag}>{activeRouteInfo?.routeName || '未选择航线'}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.summaryGrid}>
|
||||||
|
{statusItems.map((item) => (
|
||||||
|
<div key={item.label} className={styles.summaryCard}>
|
||||||
|
<div className={styles.summaryIcon} style={{ color: item.accent }}>{item.icon}</div>
|
||||||
|
<div className={styles.summaryLabel}>{item.label}</div>
|
||||||
|
<div className={styles.summaryValue}>{item.value}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<div className={styles.summaryCard}>
|
||||||
|
<div className={styles.summaryLabel}>规划总长</div>
|
||||||
|
<div className={styles.summaryValue}>
|
||||||
|
{activeRouteInfo ? `${(activeRouteInfo.totalDistance / 1000).toFixed(2)} km` : '--'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.summaryCard}>
|
||||||
|
<div className={styles.summaryLabel}>预计时长</div>
|
||||||
|
<div className={styles.summaryValue}>{activeRouteInfo?.totalDurationStr || '--'}</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.summaryCard}>
|
||||||
|
<div className={styles.summaryLabel}>航向 / 速度</div>
|
||||||
|
<div className={styles.summaryValue}>
|
||||||
|
{boatData ? `${Math.round(boatData.heading || 0)}° / ${boatData.speed?.toFixed(1) || '0.0'} m/s` : '--'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ExecRightPanel;
|
||||||
@@ -27,13 +27,11 @@ interface LeftPanelProps {
|
|||||||
sailingLoading: boolean;
|
sailingLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化距离 */
|
|
||||||
const formatDistance = (meters?: number) => {
|
const formatDistance = (meters?: number) => {
|
||||||
if (!meters || meters <= 0) return null;
|
if (!meters || meters <= 0) return null;
|
||||||
return meters >= 1000 ? `${(meters / 1000).toFixed(1)}km` : `${Math.round(meters)}m`;
|
return meters >= 1000 ? `${(meters / 1000).toFixed(1)}km` : `${Math.round(meters)}m`;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 格式化时间(秒 → "XX分钟") */
|
|
||||||
const formatDuration = (seconds?: number) => {
|
const formatDuration = (seconds?: number) => {
|
||||||
if (!seconds || seconds <= 0) return null;
|
if (!seconds || seconds <= 0) return null;
|
||||||
const min = Math.round(seconds / 60);
|
const min = Math.round(seconds / 60);
|
||||||
@@ -55,10 +53,10 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const battery = boatData?.battery ?? 0;
|
const battery = boatData?.battery ?? 0;
|
||||||
const isOnline = sseConnected;
|
const isOnline = sseConnected;
|
||||||
|
const hasBoatPosition = Number.isFinite(boatData?.longitude) && Number.isFinite(boatData?.latitude);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.panel}>
|
<div className={styles.panel}>
|
||||||
{/* ========== 设备状态卡片 ========== */}
|
|
||||||
<div className={`${styles.infoCard} ${styles.deviceCard}`}>
|
<div className={`${styles.infoCard} ${styles.deviceCard}`}>
|
||||||
<div className={styles.cardHeader}>
|
<div className={styles.cardHeader}>
|
||||||
<span className={styles.cardTitle}>设备状态</span>
|
<span className={styles.cardTitle}>设备状态</span>
|
||||||
@@ -74,7 +72,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
|
|||||||
GPS 信号
|
GPS 信号
|
||||||
</span>
|
</span>
|
||||||
<span className={`${styles.cardValue} ${styles.cardValueGreen}`}>
|
<span className={`${styles.cardValue} ${styles.cardValueGreen}`}>
|
||||||
{boatData?.longitude ? '强' : '弱'}
|
{hasBoatPosition ? '已定位' : '未定位'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -84,8 +82,8 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
|
|||||||
当前位置
|
当前位置
|
||||||
</span>
|
</span>
|
||||||
<span className={`${styles.cardValue} ${styles.cardValueCyan}`}>
|
<span className={`${styles.cardValue} ${styles.cardValueCyan}`}>
|
||||||
{boatData?.longitude
|
{hasBoatPosition
|
||||||
? `${boatData.longitude.toFixed(2)}°E ${boatData.latitude.toFixed(2)}°N`
|
? `${boatData!.longitude.toFixed(4)}°E ${boatData!.latitude.toFixed(4)}°N`
|
||||||
: '--'}
|
: '--'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -131,12 +129,10 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ========== 分隔线 ========== */}
|
|
||||||
<div className={styles.divider} />
|
<div className={styles.divider} />
|
||||||
|
|
||||||
{/* ========== 航线区域 ========== */}
|
|
||||||
<div className={styles.routeHeader}>
|
<div className={styles.routeHeader}>
|
||||||
<span className={styles.routeHeaderTitle}>浏览线路</span>
|
<span className={styles.routeHeaderTitle}>航线列表</span>
|
||||||
<span className={styles.routeCountBadge}>
|
<span className={styles.routeCountBadge}>
|
||||||
{routes.length} 条航线
|
{routes.length} 条航线
|
||||||
<DownOutlined style={{ fontSize: 8 }} />
|
<DownOutlined style={{ fontSize: 8 }} />
|
||||||
@@ -172,11 +168,13 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
<span className={`${styles.badge} ${styles.badgeGreen}`}>就绪</span>
|
<span className={`${styles.badge} ${styles.badgeGreen}`}>就绪</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles.routeMeta}>
|
<div className={styles.routeMeta}>
|
||||||
{wpCount}个航点{distance ? ` · 约${distance}` : ''}{duration ? ` · 预计${duration}` : ''}
|
{wpCount} 个航点
|
||||||
|
{distance ? ` · 约 ${distance}` : ''}
|
||||||
|
{duration ? ` · 预计 ${duration}` : ''}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 选中时显示操作按钮 */}
|
|
||||||
{isSelected && (
|
{isSelected && (
|
||||||
<div className={styles.routeActions} onClick={(e) => e.stopPropagation()}>
|
<div className={styles.routeActions} onClick={(e) => e.stopPropagation()}>
|
||||||
<button
|
<button
|
||||||
@@ -191,7 +189,12 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
|
|||||||
className={styles.btnExecute}
|
className={styles.btnExecute}
|
||||||
disabled={sailingLoading}
|
disabled={sailingLoading}
|
||||||
onClick={(e) => { e.stopPropagation(); onStartSailing(route.routeId); }}
|
onClick={(e) => { e.stopPropagation(); onStartSailing(route.routeId); }}
|
||||||
onTouchEnd={(e) => { if (sailingLoading) return; e.stopPropagation(); e.preventDefault(); onStartSailing(route.routeId); }}
|
onTouchEnd={(e) => {
|
||||||
|
if (sailingLoading) return;
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
onStartSailing(route.routeId);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<PlayCircleOutlined />
|
<PlayCircleOutlined />
|
||||||
{sailingLoading ? '启动中...' : '执行航线'}
|
{sailingLoading ? '启动中...' : '执行航线'}
|
||||||
@@ -203,6 +206,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{routes.length > 2 && <div className={styles.scrollHint}>上下滑动查看更多航线</div>}
|
{routes.length > 2 && <div className={styles.scrollHint}>上下滑动查看更多航线</div>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -189,6 +189,17 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.execRightPanel {
|
||||||
|
width: 340px;
|
||||||
|
height: 100%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
@media (max-width: 1366px) {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 沉浸模式标记 ========== */
|
/* ========== 沉浸模式标记 ========== */
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import LeftPanel from './components/LeftPanel';
|
|||||||
import CenterView from './components/CenterView';
|
import CenterView from './components/CenterView';
|
||||||
import ExecLeftPanel from './components/ExecLeftPanel';
|
import ExecLeftPanel from './components/ExecLeftPanel';
|
||||||
import ExecBottomStrip from './components/ExecBottomStrip';
|
import ExecBottomStrip from './components/ExecBottomStrip';
|
||||||
|
import ExecRightPanel from './components/ExecRightPanel';
|
||||||
import { useClientAuth } from './hooks/useClientAuth';
|
import { useClientAuth } from './hooks/useClientAuth';
|
||||||
import { useClientSSE } from './hooks/useClientSSE';
|
import { useClientSSE } from './hooks/useClientSSE';
|
||||||
import { useRouteData } from './hooks/useRouteData';
|
import { useRouteData } from './hooks/useRouteData';
|
||||||
@@ -26,7 +27,6 @@ import { useNavigationState } from './hooks/useNavigationState';
|
|||||||
import { useNavigationData } from './hooks/useNavigationData';
|
import { useNavigationData } from './hooks/useNavigationData';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
/** 船 Logo SVG */
|
|
||||||
const ShipLogoIcon: React.FC = () => (
|
const ShipLogoIcon: React.FC = () => (
|
||||||
<svg width="20" height="20" viewBox="0 0 36 36" fill="none">
|
<svg width="20" height="20" viewBox="0 0 36 36" fill="none">
|
||||||
<path d="M6 27L8.4 21H27.6L30 27C30 27 25.5 30 18 30C10.5 30 6 27 6 27Z" fill="white" fillOpacity="0.9" />
|
<path d="M6 27L8.4 21H27.6L30 27C30 27 25.5 30 18 30C10.5 30 6 27 6 27Z" fill="white" fillOpacity="0.9" />
|
||||||
@@ -36,7 +36,6 @@ const ShipLogoIcon: React.FC = () => (
|
|||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
||||||
/** 格式化秒数为 HH:MM:SS */
|
|
||||||
const formatElapsed = (totalSec: number) => {
|
const formatElapsed = (totalSec: number) => {
|
||||||
const h = Math.floor(totalSec / 3600).toString().padStart(2, '0');
|
const h = Math.floor(totalSec / 3600).toString().padStart(2, '0');
|
||||||
const m = Math.floor((totalSec % 3600) / 60).toString().padStart(2, '0');
|
const m = Math.floor((totalSec % 3600) / 60).toString().padStart(2, '0');
|
||||||
@@ -44,20 +43,54 @@ const formatElapsed = (totalSec: number) => {
|
|||||||
return `${h}:${m}:${s}`;
|
return `${h}:${m}:${s}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const calculateDistanceMeters = (
|
||||||
|
from: { longitude: number; latitude: number },
|
||||||
|
to: { longitude: number; latitude: number },
|
||||||
|
) => {
|
||||||
|
const earthRadius = 6371000;
|
||||||
|
const dLat = (to.latitude - from.latitude) * Math.PI / 180;
|
||||||
|
const dLon = (to.longitude - from.longitude) * Math.PI / 180;
|
||||||
|
const lat1 = from.latitude * Math.PI / 180;
|
||||||
|
const lat2 = to.latitude * Math.PI / 180;
|
||||||
|
const a = Math.sin(dLat / 2) ** 2
|
||||||
|
+ Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon / 2) ** 2;
|
||||||
|
return earthRadius * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||||
|
};
|
||||||
|
|
||||||
const ClientPage: React.FC = () => {
|
const ClientPage: React.FC = () => {
|
||||||
const [messageApi, messageContextHolder] = message.useMessage();
|
const [messageApi, messageContextHolder] = message.useMessage();
|
||||||
const [modalApi, modalContextHolder] = Modal.useModal();
|
const [modalApi, modalContextHolder] = Modal.useModal();
|
||||||
// ── 认证 ──
|
|
||||||
const { boatData: sseBoatData, sseConnected, loading: sseLoading, deviceOffline, connectSSE, disconnectSSE } = useClientSSE();
|
const {
|
||||||
|
boatData: sseBoatData,
|
||||||
|
sseConnected,
|
||||||
|
loading: sseLoading,
|
||||||
|
deviceOffline,
|
||||||
|
connectSSE,
|
||||||
|
disconnectSSE,
|
||||||
|
} = useClientSSE();
|
||||||
const { deviceSn, deviceInfo, handleLogout } = useClientAuth(disconnectSSE);
|
const { deviceSn, deviceInfo, handleLogout } = useClientAuth(disconnectSSE);
|
||||||
|
|
||||||
// ── 航线数据 ──
|
const {
|
||||||
const { routes, routeWaypointsMap, selectedRouteId, setSelectedRouteId, routeLoading } =
|
routes,
|
||||||
useRouteData(deviceSn);
|
routeWaypointsMap,
|
||||||
|
selectedRouteId,
|
||||||
|
setSelectedRouteId,
|
||||||
|
routeLoading,
|
||||||
|
} = useRouteData(deviceSn);
|
||||||
|
|
||||||
const boatData = sseBoatData;
|
const boatData = sseBoatData;
|
||||||
|
const hasBoatPosition = Number.isFinite(boatData?.longitude) && Number.isFinite(boatData?.latitude);
|
||||||
|
const videoStreamUrl = useMemo(() => {
|
||||||
|
const rawInfo = deviceInfo as any;
|
||||||
|
return rawInfo?.videoStreamUrl
|
||||||
|
|| rawInfo?.whepUrl
|
||||||
|
|| rawInfo?.streamUrl
|
||||||
|
|| rawInfo?.videoUrl
|
||||||
|
|| rawInfo?.liveStreamUrl
|
||||||
|
|| undefined;
|
||||||
|
}, [deviceInfo]);
|
||||||
|
|
||||||
// ── 沉浸模式状态机 ──
|
|
||||||
const {
|
const {
|
||||||
isPaused,
|
isPaused,
|
||||||
currentWaypointIndex,
|
currentWaypointIndex,
|
||||||
@@ -72,43 +105,85 @@ const ClientPage: React.FC = () => {
|
|||||||
handleResumeSailing,
|
handleResumeSailing,
|
||||||
handleStopSailing,
|
handleStopSailing,
|
||||||
handleStopPreview,
|
handleStopPreview,
|
||||||
handleEmergencyStop,
|
|
||||||
handlePreviewChange,
|
handlePreviewChange,
|
||||||
} = useNavigationState(deviceSn, selectedRouteId, setSelectedRouteId, routes, messageApi, modalApi);
|
} = useNavigationState(deviceSn, selectedRouteId, setSelectedRouteId, routes, messageApi, modalApi);
|
||||||
|
|
||||||
// ── SSE 连接 ──
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!deviceSn) return;
|
if (!deviceSn) return;
|
||||||
connectSSE(deviceSn);
|
connectSSE(deviceSn);
|
||||||
return () => { disconnectSSE(); };
|
return () => {
|
||||||
}, [deviceSn]);
|
disconnectSSE();
|
||||||
|
};
|
||||||
|
}, [deviceSn, connectSSE, disconnectSSE]);
|
||||||
|
|
||||||
// ── 沉浸模式计时器 ──
|
|
||||||
const [elapsed, setElapsed] = useState(0);
|
const [elapsed, setElapsed] = useState(0);
|
||||||
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
const [previewStartSignal, setPreviewStartSignal] = useState(0);
|
const [previewStartSignal, setPreviewStartSignal] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isImmersive && !isPaused) {
|
if (isImmersive && !isPaused) {
|
||||||
timerRef.current = setInterval(() => setElapsed((s) => s + 1), 1000);
|
timerRef.current = setInterval(() => setElapsed((seconds) => seconds + 1), 1000);
|
||||||
} else if (timerRef.current) {
|
} else if (timerRef.current) {
|
||||||
clearInterval(timerRef.current);
|
clearInterval(timerRef.current);
|
||||||
timerRef.current = null;
|
timerRef.current = null;
|
||||||
}
|
}
|
||||||
if (!isImmersive) setElapsed(0);
|
|
||||||
return () => { if (timerRef.current) clearInterval(timerRef.current); };
|
if (!isImmersive) {
|
||||||
|
setElapsed(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (timerRef.current) clearInterval(timerRef.current);
|
||||||
|
};
|
||||||
}, [isImmersive, isPaused]);
|
}, [isImmersive, isPaused]);
|
||||||
|
|
||||||
// ── 预览航线回调 ──
|
|
||||||
const handlePreviewRoute = useCallback((routeId: string) => {
|
const handlePreviewRoute = useCallback((routeId: string) => {
|
||||||
if (routeId !== selectedRouteId) {
|
if (routeId !== selectedRouteId) {
|
||||||
setSelectedRouteId(routeId);
|
setSelectedRouteId(routeId);
|
||||||
}
|
}
|
||||||
// 延迟递增信号,让 selectedRouteId 先生效触发航点加载
|
setTimeout(() => setPreviewStartSignal((signal) => signal + 1), 200);
|
||||||
setTimeout(() => setPreviewStartSignal((s) => s + 1), 200);
|
|
||||||
}, [selectedRouteId, setSelectedRouteId]);
|
}, [selectedRouteId, setSelectedRouteId]);
|
||||||
|
|
||||||
// ── 预先计算航线基础信息(不依赖 boatData) ──
|
const handleExecuteRoute = useCallback(async (routeId: string) => {
|
||||||
|
const firstWaypoint = routeWaypointsMap[routeId]?.[0];
|
||||||
|
if (!firstWaypoint) {
|
||||||
|
messageApi.warning('当前航线缺少起始航点,无法执行');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!hasBoatPosition) {
|
||||||
|
messageApi.warning('尚未收到无人船实时位置,暂时不能执行航线');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const distance = calculateDistanceMeters(
|
||||||
|
{ longitude: boatData!.longitude, latitude: boatData!.latitude },
|
||||||
|
{ longitude: firstWaypoint.longitude, latitude: firstWaypoint.latitude },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (distance > 200) {
|
||||||
|
modalApi.warning({
|
||||||
|
title: '无法执行航线',
|
||||||
|
centered: true,
|
||||||
|
width: 500,
|
||||||
|
okText: '知道了',
|
||||||
|
content: (
|
||||||
|
<div style={{ paddingTop: 8, textAlign: 'center', lineHeight: 1.9, fontSize: 16 }}>
|
||||||
|
<div>
|
||||||
|
无人船距离航线起点约
|
||||||
|
<span style={{ color: '#ff7875', fontWeight: 700, margin: '0 6px' }}>
|
||||||
|
{Math.round(distance)} 米
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>已超过 200 米,请先将无人船驶近起点后再执行。</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await handleStartSailing(routeId);
|
||||||
|
}, [routeWaypointsMap, boatData, hasBoatPosition, handleStartSailing, messageApi, modalApi]);
|
||||||
|
|
||||||
const activeWaypointsRaw = useMemo(() => {
|
const activeWaypointsRaw = useMemo(() => {
|
||||||
if (!activeRouteId) return [];
|
if (!activeRouteId) return [];
|
||||||
return routeWaypointsMap[activeRouteId] || [];
|
return routeWaypointsMap[activeRouteId] || [];
|
||||||
@@ -116,45 +191,40 @@ const ClientPage: React.FC = () => {
|
|||||||
|
|
||||||
const activeRouteInfoRaw = useMemo(() => {
|
const activeRouteInfoRaw = useMemo(() => {
|
||||||
if (!activeRouteId) return null;
|
if (!activeRouteId) return null;
|
||||||
return routes.find((r) => r.routeId === activeRouteId) || null;
|
return routes.find((route) => route.routeId === activeRouteId) || null;
|
||||||
}, [activeRouteId, routes]);
|
}, [activeRouteId, routes]);
|
||||||
|
|
||||||
// ── 预览模式假数据 ──
|
|
||||||
const effectiveBoatData = useMemo(() => {
|
const effectiveBoatData = useMemo(() => {
|
||||||
if (!isPreviewing) return boatData;
|
if (!isPreviewing) return boatData;
|
||||||
// 如果有真实 SSE 数据,优先使用
|
if (hasBoatPosition) return boatData;
|
||||||
if (boatData?.longitude) return boatData;
|
|
||||||
// 预览模式下根据航线航点和经过时间生成模拟遥测数据
|
|
||||||
if (activeWaypointsRaw.length === 0) return null;
|
if (activeWaypointsRaw.length === 0) return null;
|
||||||
|
|
||||||
const previewSpeed = 2; // m/s,与预览动画速度一致
|
const previewSpeed = 2;
|
||||||
const totalDist = activeRouteInfoRaw?.totalDistance || 1000;
|
const totalDist = activeRouteInfoRaw?.totalDistance || 1000;
|
||||||
const traveled = elapsed * previewSpeed;
|
const traveled = elapsed * previewSpeed;
|
||||||
const fraction = Math.min(traveled / totalDist, 0.99);
|
const fraction = Math.min(traveled / totalDist, 0.99);
|
||||||
const wpIdx = Math.min(
|
const waypointIdx = Math.min(
|
||||||
Math.floor(fraction * (activeWaypointsRaw.length - 1)),
|
Math.floor(fraction * (activeWaypointsRaw.length - 1)),
|
||||||
activeWaypointsRaw.length - 2,
|
activeWaypointsRaw.length - 2,
|
||||||
);
|
);
|
||||||
const wp = activeWaypointsRaw[wpIdx];
|
const waypoint = activeWaypointsRaw[waypointIdx];
|
||||||
const nextWp = activeWaypointsRaw[wpIdx + 1] || wp;
|
const nextWaypoint = activeWaypointsRaw[waypointIdx + 1] || waypoint;
|
||||||
|
|
||||||
// 航段内插值
|
const segFraction = (fraction * (activeWaypointsRaw.length - 1)) - waypointIdx;
|
||||||
const segFrac = (fraction * (activeWaypointsRaw.length - 1)) - wpIdx;
|
const longitude = waypoint.longitude + (nextWaypoint.longitude - waypoint.longitude) * segFraction;
|
||||||
const lon = wp.longitude + (nextWp.longitude - wp.longitude) * segFrac;
|
const latitude = waypoint.latitude + (nextWaypoint.latitude - waypoint.latitude) * segFraction;
|
||||||
const lat = wp.latitude + (nextWp.latitude - wp.latitude) * segFrac;
|
|
||||||
|
|
||||||
// 计算航向
|
const dLon = (nextWaypoint.longitude - waypoint.longitude) * Math.PI / 180;
|
||||||
const dLon = (nextWp.longitude - wp.longitude) * Math.PI / 180;
|
const lat1 = waypoint.latitude * Math.PI / 180;
|
||||||
const lat1 = wp.latitude * Math.PI / 180;
|
const lat2 = nextWaypoint.latitude * Math.PI / 180;
|
||||||
const lat2 = nextWp.latitude * Math.PI / 180;
|
|
||||||
const y = Math.sin(dLon) * Math.cos(lat2);
|
const y = Math.sin(dLon) * Math.cos(lat2);
|
||||||
const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
|
const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
|
||||||
const heading = ((Math.atan2(y, x) * 180 / Math.PI) + 360) % 360;
|
const heading = ((Math.atan2(y, x) * 180 / Math.PI) + 360) % 360;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
deviceSn: deviceSn || '',
|
deviceSn: deviceSn || '',
|
||||||
longitude: lon,
|
longitude,
|
||||||
latitude: lat,
|
latitude,
|
||||||
heading,
|
heading,
|
||||||
speed: previewSpeed,
|
speed: previewSpeed,
|
||||||
battery: 85,
|
battery: 85,
|
||||||
@@ -162,9 +232,8 @@ const ClientPage: React.FC = () => {
|
|||||||
status: 'preview',
|
status: 'preview',
|
||||||
recordTime: new Date().toISOString(),
|
recordTime: new Date().toISOString(),
|
||||||
} as import('@/types/boatRoute').BoatTelemetryData;
|
} as import('@/types/boatRoute').BoatTelemetryData;
|
||||||
}, [isPreviewing, boatData, activeWaypointsRaw, activeRouteInfoRaw, elapsed, deviceSn]);
|
}, [isPreviewing, boatData, hasBoatPosition, activeWaypointsRaw, activeRouteInfoRaw, elapsed, deviceSn]);
|
||||||
|
|
||||||
// ── 导航计算(使用 effectiveBoatData 以便预览模式也有数据) ──
|
|
||||||
const {
|
const {
|
||||||
activeWaypoints,
|
activeWaypoints,
|
||||||
activeRouteInfo,
|
activeRouteInfo,
|
||||||
@@ -181,192 +250,194 @@ const ClientPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<ConfigProvider theme={darkTheme}>
|
<ConfigProvider theme={darkTheme}>
|
||||||
<AntdApp>
|
<AntdApp>
|
||||||
{messageContextHolder}
|
{messageContextHolder}
|
||||||
{modalContextHolder}
|
{modalContextHolder}
|
||||||
<div className={`${styles.container} ${isImmersive ? styles.sailing : ''}`}>
|
<div className={`${styles.container} ${isImmersive ? styles.sailing : ''}`}>
|
||||||
|
{!isImmersive && (
|
||||||
{/* ========== 普通模式 - 顶部导航栏 ========== */}
|
<div className={styles.navBar}>
|
||||||
{!isImmersive && (
|
<div className={styles.navLogo}>
|
||||||
<div className={styles.navBar}>
|
<div className={styles.navLogoIcon}><ShipLogoIcon /></div>
|
||||||
<div className={styles.navLogo}>
|
<span className={styles.navLogoText}>WAVE PILOT</span>
|
||||||
<div className={styles.navLogoIcon}><ShipLogoIcon /></div>
|
|
||||||
<span className={styles.navLogoText}>WAVE PILOT</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={styles.navSpacer} />
|
|
||||||
|
|
||||||
<div className={styles.navTabs}>
|
|
||||||
<div className={`${styles.navTab} ${styles.navTabActive}`}>
|
|
||||||
<EnvironmentOutlined />
|
|
||||||
<span>航线管理</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.navTab}>
|
|
||||||
<EyeOutlined />
|
|
||||||
<span>实时监控</span>
|
|
||||||
</div>
|
|
||||||
<div className={styles.navTab}>
|
|
||||||
<HistoryOutlined />
|
|
||||||
<span>历史记录</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={styles.navSpacer} />
|
<div className={styles.navSpacer} />
|
||||||
|
|
||||||
<div className={styles.navRight}>
|
<div className={styles.navTabs}>
|
||||||
<WifiOutlined className={styles.navIconBtn} />
|
<div className={`${styles.navTab} ${styles.navTabActive}`}>
|
||||||
<ThunderboltOutlined className={styles.navIconBtn} />
|
<EnvironmentOutlined />
|
||||||
<div className={styles.devIndicator}>
|
<span>航线管理</span>
|
||||||
<span
|
</div>
|
||||||
className={styles.devDot}
|
<div className={styles.navTab}>
|
||||||
style={{ background: sseConnected ? '#10b981' : '#ff4d4f' }}
|
<EyeOutlined />
|
||||||
|
<span>实时监控</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.navTab}>
|
||||||
|
<HistoryOutlined />
|
||||||
|
<span>历史记录</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.navSpacer} />
|
||||||
|
|
||||||
|
<div className={styles.navRight}>
|
||||||
|
<WifiOutlined className={styles.navIconBtn} />
|
||||||
|
<ThunderboltOutlined className={styles.navIconBtn} />
|
||||||
|
<div className={styles.devIndicator}>
|
||||||
|
<span
|
||||||
|
className={styles.devDot}
|
||||||
|
style={{ background: sseConnected ? '#10b981' : '#ff4d4f' }}
|
||||||
|
/>
|
||||||
|
<span className={styles.devSn}>{deviceInfo.deviceName || deviceSn}</span>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
icon={<LogoutOutlined />}
|
||||||
|
onClick={handleLogout}
|
||||||
|
className={styles.navLogoutBtn}
|
||||||
|
size="small"
|
||||||
/>
|
/>
|
||||||
<span className={styles.devSn}>{deviceInfo.deviceName || deviceSn}</span>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
type="text"
|
|
||||||
icon={<LogoutOutlined />}
|
|
||||||
onClick={handleLogout}
|
|
||||||
className={styles.navLogoutBtn}
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ========== 沉浸模式 - 执行导航栏 ========== */}
|
|
||||||
{isImmersive && (
|
|
||||||
<div className={styles.execNav}>
|
|
||||||
<button
|
|
||||||
className={styles.execBackBtn}
|
|
||||||
onClick={isPreviewing ? handleStopPreview : handleStopSailing}
|
|
||||||
>
|
|
||||||
<LeftOutlined />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div className={styles.execTitleArea}>
|
|
||||||
<div className={styles.execTitle}>
|
|
||||||
{activeRouteInfo?.routeName || '航线'} · {modeLabel}
|
|
||||||
</div>
|
|
||||||
<div className={styles.execSubtitle}>
|
|
||||||
{deviceInfo.deviceName || deviceSn} · 已{isPreviewing ? '预览' : '执行'} {formatElapsed(elapsed)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className={styles.execBadge}>
|
{isImmersive && (
|
||||||
<span className={styles.execBadgeDot} />
|
<div className={styles.execNav}>
|
||||||
<span>{modeLabel} {modeTag}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={styles.execSpacer} />
|
|
||||||
|
|
||||||
<div className={styles.execRight}>
|
|
||||||
{isSailing && (
|
|
||||||
<button
|
|
||||||
className={styles.execPauseBtn}
|
|
||||||
onClick={isPaused ? handleResumeSailing : handlePauseSailing}
|
|
||||||
>
|
|
||||||
{isPaused ? <CaretRightOutlined /> : <PauseOutlined />}
|
|
||||||
<span>{isPaused ? '继续' : '暂停'}</span>
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<button
|
<button
|
||||||
className={styles.execStopBtn}
|
className={styles.execBackBtn}
|
||||||
onClick={isPreviewing ? handleStopPreview : handleStopSailing}
|
onClick={isPreviewing ? handleStopPreview : handleStopSailing}
|
||||||
>
|
>
|
||||||
<StopOutlined />
|
<LeftOutlined />
|
||||||
<span>终止</span>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ========== 主体区域 ========== */}
|
<div className={styles.execTitleArea}>
|
||||||
<div className={styles.mainBody}>
|
<div className={styles.execTitle}>
|
||||||
|
{activeRouteInfo?.routeName || '航线'} · {modeLabel}
|
||||||
{/* 设备离线遮罩 */}
|
|
||||||
{deviceOffline && !sseConnected && (
|
|
||||||
<div className={styles.offlineOverlay}>
|
|
||||||
<div className={styles.offlineCard}>
|
|
||||||
<DisconnectOutlined className={styles.offlineIcon} />
|
|
||||||
<div className={styles.offlineTitle}>设备不在线</div>
|
|
||||||
<div className={styles.offlineDesc}>
|
|
||||||
无法订阅设备 <span className={styles.offlineSn}>{deviceInfo.deviceName || deviceSn}</span> 的实时数据
|
|
||||||
<br />
|
|
||||||
{sseLoading ? '正在重新连接...' : '请检查设备是否已开机并接入网络'}
|
|
||||||
</div>
|
</div>
|
||||||
{sseLoading ? (
|
<div className={styles.execSubtitle}>
|
||||||
<Spin size="small" style={{ marginTop: 16 }} />
|
{deviceInfo.deviceName || deviceSn} · {isPreviewing ? '预览' : '执行'} · {formatElapsed(elapsed)}
|
||||||
) : (
|
</div>
|
||||||
<Button
|
</div>
|
||||||
icon={<ReloadOutlined />}
|
|
||||||
onClick={() => connectSSE(deviceSn)}
|
<div className={styles.execBadge}>
|
||||||
style={{ marginTop: 16, borderColor: 'rgba(34,211,238,0.4)', color: '#22d3ee' }}
|
<span className={styles.execBadgeDot} />
|
||||||
ghost
|
<span>{modeLabel} {modeTag}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.execSpacer} />
|
||||||
|
|
||||||
|
<div className={styles.execRight}>
|
||||||
|
{isSailing && (
|
||||||
|
<button
|
||||||
|
className={styles.execPauseBtn}
|
||||||
|
onClick={isPaused ? handleResumeSailing : handlePauseSailing}
|
||||||
>
|
>
|
||||||
重试连接
|
{isPaused ? <CaretRightOutlined /> : <PauseOutlined />}
|
||||||
</Button>
|
<span>{isPaused ? '继续' : '暂停'}</span>
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
|
<button
|
||||||
|
className={styles.execStopBtn}
|
||||||
|
onClick={isPreviewing ? handleStopPreview : handleStopSailing}
|
||||||
|
>
|
||||||
|
<StopOutlined />
|
||||||
|
<span>终止</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 左侧边栏 - 普通模式 */}
|
<div className={styles.mainBody}>
|
||||||
{!isImmersive && (
|
{deviceOffline && !sseConnected && (
|
||||||
<div className={styles.leftPanel}>
|
<div className={styles.offlineOverlay}>
|
||||||
<LeftPanel
|
<div className={styles.offlineCard}>
|
||||||
routes={routes}
|
<DisconnectOutlined className={styles.offlineIcon} />
|
||||||
routeWaypointsMap={routeWaypointsMap}
|
<div className={styles.offlineTitle}>设备不在线</div>
|
||||||
loading={routeLoading}
|
<div className={styles.offlineDesc}>
|
||||||
selectedRouteId={selectedRouteId}
|
无法订阅设备 <span className={styles.offlineSn}>{deviceInfo.deviceName || deviceSn}</span> 的实时数据
|
||||||
onSelectRoute={setSelectedRouteId}
|
<br />
|
||||||
deviceInfo={deviceInfo}
|
{sseLoading ? '正在重新连接...' : '请检查设备是否已开机并接入网络'}
|
||||||
boatData={boatData}
|
</div>
|
||||||
sseConnected={sseConnected}
|
{sseLoading ? (
|
||||||
onStartSailing={handleStartSailing}
|
<Spin size="small" style={{ marginTop: 16 }} />
|
||||||
onPreviewRoute={handlePreviewRoute}
|
) : (
|
||||||
sailingLoading={sailingLoading}
|
<Button
|
||||||
/>
|
icon={<ReloadOutlined />}
|
||||||
</div>
|
onClick={() => connectSSE(deviceSn)}
|
||||||
)}
|
style={{ marginTop: 16, borderColor: 'rgba(34,211,238,0.4)', color: '#22d3ee' }}
|
||||||
|
ghost
|
||||||
|
>
|
||||||
|
重试连接
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* 左侧面板 - 沉浸模式 (仪表盘 + 航点列表) */}
|
{!isImmersive && (
|
||||||
{isImmersive && (
|
<div className={styles.leftPanel}>
|
||||||
<ExecLeftPanel
|
<LeftPanel
|
||||||
boatData={effectiveBoatData}
|
routes={routes}
|
||||||
waypoints={activeWaypoints}
|
routeWaypointsMap={routeWaypointsMap}
|
||||||
currentWaypointIndex={currentWaypointIndex}
|
loading={routeLoading}
|
||||||
/>
|
selectedRouteId={selectedRouteId}
|
||||||
)}
|
onSelectRoute={setSelectedRouteId}
|
||||||
|
deviceInfo={deviceInfo}
|
||||||
|
boatData={boatData}
|
||||||
|
sseConnected={sseConnected}
|
||||||
|
onStartSailing={handleExecuteRoute}
|
||||||
|
onPreviewRoute={handlePreviewRoute}
|
||||||
|
sailingLoading={sailingLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* 地图区域 */}
|
|
||||||
<div className={styles.centerView}>
|
|
||||||
<CenterView
|
|
||||||
deviceSn={deviceSn}
|
|
||||||
routes={routes}
|
|
||||||
selectedRouteId={selectedRouteId}
|
|
||||||
boatData={boatData}
|
|
||||||
isSailing={isSailing}
|
|
||||||
sailingLoading={sailingLoading}
|
|
||||||
previewStartSignal={previewStartSignal}
|
|
||||||
previewStopSignal={previewStopSignal}
|
|
||||||
onStartSailing={handleStartSailing}
|
|
||||||
onPreviewChange={handlePreviewChange}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 沉浸模式 - 底部航线信息条 */}
|
|
||||||
{isImmersive && (
|
{isImmersive && (
|
||||||
<ExecBottomStrip
|
<ExecLeftPanel
|
||||||
progress={progress}
|
boatData={effectiveBoatData}
|
||||||
|
waypoints={activeWaypoints}
|
||||||
currentWaypointIndex={currentWaypointIndex}
|
currentWaypointIndex={currentWaypointIndex}
|
||||||
totalWaypoints={activeWaypoints.length}
|
|
||||||
remainingDistance={remainingDistance}
|
|
||||||
estimatedRemainingTime={estimatedRemainingTime}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<div className={styles.centerView}>
|
||||||
|
<CenterView
|
||||||
|
deviceSn={deviceSn}
|
||||||
|
routes={routes}
|
||||||
|
selectedRouteId={selectedRouteId}
|
||||||
|
boatData={boatData}
|
||||||
|
isSailing={isSailing}
|
||||||
|
sailingLoading={sailingLoading}
|
||||||
|
previewStartSignal={previewStartSignal}
|
||||||
|
previewStopSignal={previewStopSignal}
|
||||||
|
onStartSailing={handleStartSailing}
|
||||||
|
onPreviewChange={handlePreviewChange}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{isSailing && (
|
||||||
|
<ExecBottomStrip
|
||||||
|
progress={progress}
|
||||||
|
currentWaypointIndex={currentWaypointIndex}
|
||||||
|
totalWaypoints={activeWaypoints.length}
|
||||||
|
remainingDistance={remainingDistance}
|
||||||
|
estimatedRemainingTime={estimatedRemainingTime}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isImmersive && (
|
||||||
|
<div className={styles.execRightPanel}>
|
||||||
|
<ExecRightPanel
|
||||||
|
deviceInfo={deviceInfo}
|
||||||
|
boatData={effectiveBoatData}
|
||||||
|
activeRouteInfo={activeRouteInfo}
|
||||||
|
sseConnected={sseConnected}
|
||||||
|
videoStreamUrl={videoStreamUrl}
|
||||||
|
isPreviewing={isPreviewing}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</AntdApp>
|
</AntdApp>
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
+17
-1
@@ -18,6 +18,11 @@ interface UseCesiumRouteLibraryRendererOptions {
|
|||||||
routes: RouteLibraryRenderItem[];
|
routes: RouteLibraryRenderItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RouteSurfaceGeometry {
|
||||||
|
polyline: any[];
|
||||||
|
waypointPositions: any[];
|
||||||
|
}
|
||||||
|
|
||||||
export function useCesiumRouteLibraryRenderer(options: UseCesiumRouteLibraryRendererOptions) {
|
export function useCesiumRouteLibraryRenderer(options: UseCesiumRouteLibraryRendererOptions) {
|
||||||
const { viewerRef, routes } = options;
|
const { viewerRef, routes } = options;
|
||||||
|
|
||||||
@@ -28,7 +33,7 @@ export function useCesiumRouteLibraryRenderer(options: UseCesiumRouteLibraryRend
|
|||||||
const routesRef = useRef<RouteLibraryRenderItem[]>(routes);
|
const routesRef = useRef<RouteLibraryRenderItem[]>(routes);
|
||||||
|
|
||||||
// 贴近模型表面,避免航线“悬浮�?
|
// 贴近模型表面,避免航线“悬浮�?
|
||||||
const ROUTE_RENDER_HEIGHT_OFFSET = 0.05;
|
const ROUTE_RENDER_HEIGHT_OFFSET = 1.2;
|
||||||
|
|
||||||
const getCesium = useCallback(() => (window as any).Cesium, []);
|
const getCesium = useCallback(() => (window as any).Cesium, []);
|
||||||
|
|
||||||
@@ -614,7 +619,18 @@ export function useCesiumRouteLibraryRenderer(options: UseCesiumRouteLibraryRend
|
|||||||
}
|
}
|
||||||
}, [viewerRef, getCesium, calculateBounds]);
|
}, [viewerRef, getCesium, calculateBounds]);
|
||||||
|
|
||||||
|
const getRouteSurfaceGeometry = useCallback((routeId: string): RouteSurfaceGeometry | null => {
|
||||||
|
const cached = surfaceCacheRef.current.get(routeId);
|
||||||
|
if (!cached) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
polyline: Array.isArray(cached.polyline) ? cached.polyline.filter(Boolean) : [],
|
||||||
|
waypointPositions: Array.isArray(cached.waypointPositions) ? cached.waypointPositions.filter(Boolean) : [],
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
flyToRoute,
|
flyToRoute,
|
||||||
|
getRouteSurfaceGeometry,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user