feat:平板页面

This commit is contained in:
2026-04-13 19:17:47 +08:00
parent 90ef9cf146
commit bca4d3ae43
37 changed files with 2987 additions and 652 deletions
+11 -1
View File
@@ -89,7 +89,17 @@
"Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/controller/*.java)", "Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/controller/*.java)",
"Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/service/*.java)", "Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/service/*.java)",
"Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/entity/*.java)", "Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/entity/*.java)",
"Bash(xargs wc:*)" "Bash(xargs wc:*)",
"Bash(ls -la zlt-web/yingyan/.env*)",
"Bash(ls -d zlt-web/*/)",
"Bash(git rm:*)",
"Bash(claude mcp:*)",
"WebFetch(domain:pixso.cn)",
"Bash(awk '{print $2}')",
"Bash(python -c \"print\\('hello'\\)\")",
"Bash(grep -r \"RightPanel\" src/pages/client/index.tsx)",
"Bash(grep \"statusBar\\\\|statusDot\" src/pages/client/index.tsx)",
"Bash(grep \"routeActions\\\\|routeActionsTitle\" src/pages/client/components/CenterView/index.tsx)"
], ],
"deny": [], "deny": [],
"ask": [] "ask": []
+6
View File
@@ -10,3 +10,9 @@ nacos/
# Claude Code specific # Claude Code specific
.claude/agents/ .claude/agents/
.claude/team-collaboration-matrix.md .claude/team-collaboration-matrix.md
# Cesium static assets (auto-generated by npm install)
zlt-web/react-web-next/public/cesium/
zlt-web/yingyan/public/cesium/
+7
View File
@@ -107,6 +107,13 @@
<version>4.12.0</version> <version>4.12.0</version>
</dependency> </dependency>
<!-- Jsoup HTML解析器 -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.17.2</version>
</dependency>
<!-- WebSocket支持(客户端和服务端) --> <!-- WebSocket支持(客户端和服务端) -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@@ -3,7 +3,9 @@ package com.central.device.controller;
import com.central.common.model.PageResult; import com.central.common.model.PageResult;
import com.central.common.model.Result; import com.central.common.model.Result;
import com.central.device.model.IotCard; import com.central.device.model.IotCard;
import com.central.device.model.vo.IccidFlowVO;
import com.central.device.service.IIotCardService; import com.central.device.service.IIotCardService;
import com.central.device.util.http.SimpleHttpRequest;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
@@ -11,8 +13,16 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -125,4 +135,112 @@ public class IotCardController {
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
} }
/**
* 查询物联网卡流量信息
*/
@Operation(summary = "查询物联网卡流量信息")
@Parameter(name = "iccid", description = "ICCID卡号", required = true, in = ParameterIn.QUERY)
@GetMapping("/flow-info")
public Result<IccidFlowVO> queryFlowInfo(@RequestParam String iccid) {
try {
// 构建第三方查询URL
String url = String.format(
"http://api.slwul.com/yjiot/wxapi/action/searchcharge?appId=wx22f2a856e6286b28&openId=oA7vc59BnABsWZeXZzI6pbX0j0EM&iccid=%s&wx_exhibition_fieid=iccid",
iccid
);
// 发起HTTP请求获取HTML页面
SimpleHttpRequest request = new SimpleHttpRequest(url);
byte[] responseBytes = request.get().asBytes();
String htmlContent = new String(responseBytes, "UTF-8");
// 解析HTML并提取关键数据
IccidFlowVO flowVO = parseHtmlToVO(htmlContent, iccid);
return Result.succeed(flowVO, "查询成功");
} catch (Exception e) {
log.error("查询物联网卡流量信息失败, iccid={}", iccid, e);
return Result.failed("查询失败: " + e.getMessage());
}
}
/**
* 解析HTML页面为实体对象
*/
private IccidFlowVO parseHtmlToVO(String htmlContent, String iccid) {
IccidFlowVO flowVO = new IccidFlowVO();
flowVO.setIccid(iccid);
try {
Document doc = Jsoup.parse(htmlContent);
// 解析激活状态和实名状态
Elements statusButtons = doc.select(".weui_card_btn_left button");
if (statusButtons.size() >= 1) {
flowVO.setActiveStatus(statusButtons.get(0).text().trim());
}
if (statusButtons.size() >= 2) {
flowVO.setRealNameStatus(statusButtons.get(1).text().trim());
}
// 解析总流量
Element totalFlowElement = doc.select(".weui_card_data_left span").first();
if (totalFlowElement != null) {
String totalFlowText = totalFlowElement.text().replace("MB", "").trim();
flowVO.setTotalFlow(new BigDecimal(totalFlowText));
}
// 解析截止时间
Element expireTimeElement = doc.select(".weui_card_remain_days").first();
if (expireTimeElement != null) {
flowVO.setExpireTime(expireTimeElement.text().trim());
}
// 解析剩余流量
Element remainFlowElement = doc.select(".weui_card_remain_data span").first();
if (remainFlowElement != null) {
String remainFlowText = remainFlowElement.text().replace("MB", "").trim();
flowVO.setRemainFlow(new BigDecimal(remainFlowText));
}
// 解析当前套餐列表
List<IccidFlowVO.FlowPackage> packageList = new ArrayList<>();
Elements packageElements = doc.select(".currqrycard .qry");
for (Element pkgElement : packageElements) {
IccidFlowVO.FlowPackage pkg = new IccidFlowVO.FlowPackage();
// 解析套餐名称和状态
Elements spans = pkgElement.select("span");
if (spans.size() >= 1) {
pkg.setPackageName(spans.get(0).text().trim());
}
if (spans.size() >= 2) {
pkg.setStatus(spans.get(1).text().trim());
}
// 解析生效时间和截止时间
Element timeElement = pkgElement.select("p.weui_card_font_color").first();
if (timeElement != null) {
String timeText = timeElement.text();
// 格式:生效时间2025-10-01~截止时间2026-09-30
if (timeText.contains("生效时间") && timeText.contains("截止时间")) {
String[] timeParts = timeText.replace("生效时间", "").split("~截止时间");
if (timeParts.length == 2) {
pkg.setStartTime(timeParts[0].trim());
pkg.setEndTime(timeParts[1].trim());
}
}
}
packageList.add(pkg);
}
flowVO.setPackageList(packageList);
} catch (Exception e) {
log.error("解析HTML失败", e);
}
return flowVO;
}
} }
@@ -0,0 +1,81 @@
package com.central.device.model.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* 物联网卡流量查询VO
*
* @author system
* @date 2026-04-10
*/
@Data
public class IccidFlowVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ICCID卡号
*/
private String iccid;
/**
* 激活状态:已激活/未激活
*/
private String activeStatus;
/**
* 实名状态:免实名/已实名/未实名
*/
private String realNameStatus;
/**
* 总流量(MB)
*/
private BigDecimal totalFlow;
/**
* 剩余流量(MB)
*/
private BigDecimal remainFlow;
/**
* 截止时间
*/
private String expireTime;
/**
* 套餐列表
*/
private List<FlowPackage> packageList;
/**
* 流量套餐信息
*/
@Data
public static class FlowPackage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 套餐名称
*/
private String packageName;
/**
* 套餐状态:使用中/已到期
*/
private String status;
/**
* 生效时间
*/
private String startTime;
/**
* 截止时间
*/
private String endTime;
}
}
@@ -133,6 +133,7 @@ public class TencentAuthenticationProvider extends BaseAuthenticationProvider {
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers); HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(securityProperties.getTencent().getJscode2sessionUrl(), HttpMethod.POST, requestEntity, String.class); ResponseEntity<String> responseEntity = restTemplate.exchange(securityProperties.getTencent().getJscode2sessionUrl(), HttpMethod.POST, requestEntity, String.class);
log.info("微信jscode2session响应, statusCode:{}, body:{}", responseEntity.getStatusCode(), responseEntity.getBody());
if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody().contains("openid")) { if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody().contains("openid")) {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
+4
View File
@@ -43,3 +43,7 @@ screenshot
# maven # maven
target target
build build
zlt-web/react-web-next/public/cesium/
zlt-web/yingyan/public/cesium/
+1 -1
View File
@@ -16,7 +16,7 @@ REACT_APP_AMAP_KEY=7df3685709e341daed76e877e417e5be
# 如需使用Cesium Ion的高级功能(如全球地形、卫星影像),可申请Token # 如需使用Cesium Ion的高级功能(如全球地形、卫星影像),可申请Token
# 申请地址: https://cesium.com/ion/signup (国内可访问) # 申请地址: https://cesium.com/ion/signup (国内可访问)
# 注意: 不配置此项不影响3D地图基本功能 # 注意: 不配置此项不影响3D地图基本功能
REACT_APP_CESIUM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5NjhjNDBlMS02OTBiLTQ5OWMtYjk3Mi04NjdiM2I4N2E4NDYiLCJpZCI6MzYxMzMzLCJpYXQiOjE3NjM0NDIxOTh9.PxIgncOzYVrDY17SWVJWD7U-9A1Wnomac8GEdcAYOeM REACT_APP_CESIUM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNDNmZDVhOC0xMDFjLTQ4YmUtYmQ1YS0zYjdjNTFjMzVlYjMiLCJpZCI6MjU5LCJpYXQiOjE3NzQ0MTY4MDN9.aymrLJz62c7X0uDN4EBrgR6wWDlkoUAhlwzs8e5Hb2U
# ========== WebSocket服务配置 ========== # ========== WebSocket服务配置 ==========
-1
View File
@@ -4,7 +4,6 @@
- 为“每个页面”统一增加“租户 + 包含子租户”查询控制; - 为“每个页面”统一增加“租户 + 包含子租户”查询控制;
- 优化主题与布局,使界面更现代、更一致; - 优化主题与布局,使界面更现代、更一致;
- 通过组件化与约定,降低后续页面维护成本。 - 通过组件化与约定,降低后续页面维护成本。
## 目录结构 ## 目录结构
## 构建与部署(多环境) ## 构建与部署(多环境)
+1 -1
View File
@@ -30,7 +30,7 @@
"tsc": "tsc --noEmit" "tsc": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@ant-design/plots": "^2.6.5", "@ant-design/plots": "^1.2.6",
"@ant-design/pro-components": "1.1.1", "@ant-design/pro-components": "1.1.1",
"@ant-design/pro-layout": "^7.22.7", "@ant-design/pro-layout": "^7.22.7",
"antd": "^4.20.0", "antd": "^4.20.0",
+1 -1
View File
@@ -6,7 +6,7 @@
REACT_APP_AMAP_KEY=7df3685709e341daed76e877e417e5be REACT_APP_AMAP_KEY=7df3685709e341daed76e877e417e5be
# Cesium Ion Token # Cesium Ion Token
REACT_APP_CESIUM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5NjhjNDBlMS02OTBiLTQ5OWMtYjk3Mi04NjdiM2I4N2E4NDYiLCJpZCI6MzYxMzMzLCJpYXQiOjE3NjM0NDIxOTh9.PxIgncOzYVrDY17SWVJWD7U-9A1Wnomac8GEdcAYOeM REACT_APP_CESIUM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNDNmZDVhOC0xMDFjLTQ4YmUtYmQ1YS0zYjdjNTFjMzVlYjMiLCJpZCI6MjU5LCJpYXQiOjE3NzQ0MTY4MDN9.aymrLJz62c7X0uDN4EBrgR6wWDlkoUAhlwzs8e5Hb2U
# ========== WebSocket服务配置 ========== # ========== WebSocket服务配置 ==========
+33
View File
@@ -0,0 +1,33 @@
The following component and style files are available. Fetch each URL to get the file content, then save to your project at the specified path:
[
{
"id": "Frame_3_74.css",
"path": "src/styles/Frame_3_74.css",
"type": "extra",
"url": "http://localhost:3667/code/Frame_3_74.css"
},
{
"id": "index.tsx",
"path": "src/router/index.tsx",
"type": "extra",
"url": "http://localhost:3667/code/index.tsx"
},
{
"id": "StaticWrapper.tsx",
"path": "src/router/components/StaticWrapper.tsx",
"type": "extra",
"url": "http://localhost:3667/code/StaticWrapper.tsx"
},
{
"id": "global.css",
"path": "src/assets/styles/global.css",
"type": "extra",
"url": "http://localhost:3667/code/global.css"
},
{
"id": "main.tsx",
"path": "src/main.tsx",
"type": "extra",
"url": "http://localhost:3667/code/main.tsx"
}
]
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

+151 -35
View File
@@ -1,13 +1,51 @@
/* ===== 登录页 - 基于 Pixso 设计稿 ===== */
.container { .container {
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
background: linear-gradient(135deg, #0a1628 0%, #0d2137 50%, #0a1628 100%); background: #0a0f1c;
position: relative; position: relative;
overflow: hidden;
} }
/* ---------- 装饰圆 ---------- */
.decoCircle1 {
position: absolute;
width: 500px;
height: 500px;
border-radius: 50%;
background: rgba(14, 116, 144, 0.12);
top: -120px;
left: -100px;
pointer-events: none;
}
.decoCircle2 {
position: absolute;
width: 400px;
height: 400px;
border-radius: 50%;
background: rgba(14, 116, 144, 0.15);
bottom: -80px;
right: -40px;
pointer-events: none;
}
.decoCircle3 {
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
background: rgba(34, 211, 238, 0.08);
top: 80px;
right: 120px;
pointer-events: none;
}
/* ---------- 管理后台入口 ---------- */
.backEntry { .backEntry {
position: absolute; position: absolute;
top: 16px; top: 16px;
@@ -15,57 +53,135 @@
z-index: 10; z-index: 10;
} }
.backBtn {
color: rgba(255, 255, 255, 0.45) !important;
font-size: 13px !important;
&:hover {
color: rgba(255, 255, 255, 0.7) !important;
}
}
/* ---------- 登录卡片 ---------- */
.card { .card {
width: 400px; width: 460px;
padding: 48px 40px; padding: 48px 40px;
background: rgba(15, 25, 40, 0.9); background: rgba(30, 41, 59, 0.95);
border: 1px solid rgba(0, 212, 255, 0.2); border: 1px solid #1e3a5f;
border-radius: 12px; border-radius: 16px;
backdrop-filter: blur(20px); position: relative;
z-index: 2;
}
/* ---------- Logo 区域 ---------- */
.logoSection {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
}
.logoCircle {
width: 64px;
height: 64px;
border-radius: 50%;
background: linear-gradient(135deg, #0e7490, #22d3ee);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 8px;
} }
.title { .title {
font-family: 'JetBrains Mono', 'Courier New', monospace;
font-size: 28px; font-size: 28px;
font-weight: 600; font-weight: 700;
color: #fff; color: #ffffff;
letter-spacing: 8px;
text-align: center; text-align: center;
margin-bottom: 8px; margin: 0;
} }
.subtitle { .subtitle {
font-size: 14px; font-size: 14px;
color: rgba(255, 255, 255, 0.5); color: rgba(255, 255, 255, 0.5);
text-align: center; text-align: center;
margin-bottom: 32px; margin: 0;
} }
.card :global(.ant-input-affix-wrapper) { /* ---------- 分隔线 ---------- */
background: rgba(255, 255, 255, 0.05); .divider {
border-color: rgba(255, 255, 255, 0.15); height: 1px;
color: #fff; background: linear-gradient(90deg, transparent, rgba(30, 58, 95, 0.6), transparent);
margin: 28px 0;
} }
.card :global(.ant-input-affix-wrapper:hover), /* ---------- 表单 ---------- */
.card :global(.ant-input-affix-wrapper-focused) { .form {
border-color: #00d4ff; .fieldLabel {
font-family: 'Inter', -apple-system, sans-serif;
font-size: 13px;
font-weight: 600;
color: rgba(148, 163, 184, 1);
margin-bottom: 8px;
}
:global(.ant-input-affix-wrapper) {
height: 48px;
background: #0f172a;
border: 1px solid #22d3ee;
border-radius: 8px;
padding: 0 16px;
color: #fff;
transition: all 0.2s;
&:hover,
&:focus,
&-focused {
border-color: #22d3ee;
box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.15);
}
}
:global(.ant-input) {
background: transparent;
color: #fff;
font-family: 'JetBrains Mono', 'Courier New', monospace;
font-size: 13px;
margin-left: 4px;
&::placeholder {
color: #475569;
font-family: 'JetBrains Mono', 'Courier New', monospace;
}
}
:global(.ant-btn-primary) {
height: 52px;
font-size: 16px;
font-weight: 700;
border: none;
border-radius: 10px;
background: linear-gradient(90deg, #0e7490, #22d3ee);
letter-spacing: 2px;
transition: all 0.25s;
&:hover {
background: linear-gradient(90deg, #0d6b83, #2ae0f0);
box-shadow: 0 4px 20px rgba(34, 211, 238, 0.3);
}
}
:global(.ant-form-item-explain-error) {
color: #f87171;
font-size: 12px;
}
} }
.card :global(.ant-input) { /* ---------- 响应式 ---------- */
background: transparent; @media (max-width: 520px) {
color: #fff; .card {
} width: calc(100vw - 32px);
padding: 36px 24px;
.card :global(.ant-input::placeholder) { }
color: rgba(255, 255, 255, 0.3); .title {
} font-size: 22px;
letter-spacing: 4px;
.card :global(.ant-btn-primary) { }
height: 48px;
font-size: 16px;
background: linear-gradient(135deg, #00d4ff, #0099cc);
border: none;
}
.card :global(.ant-btn-primary:hover) {
background: linear-gradient(135deg, #33ddff, #00aadd);
} }
@@ -1,10 +1,44 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Form, Input, Button, message } from 'antd'; import { Form, Input, Button, message } from 'antd';
import { ApiOutlined, DesktopOutlined } from '@ant-design/icons'; import { DesktopOutlined, LoginOutlined } from '@ant-design/icons';
import { history } from 'umi'; import { history } from 'umi';
import { checkDeviceSn } from '../services/clientApi'; import { checkDeviceSn } from '../services/clientApi';
import styles from './index.less'; import styles from './index.less';
/** 船图标 SVG */
const ShipIcon: React.FC = () => (
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<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"
/>
<rect x="15" y="8" width="6" height="13" rx="1" fill="white" fillOpacity="0.9" />
<rect x="11" y="14" width="14" height="7" rx="1" fill="white" fillOpacity="0.7" />
<rect x="16.5" y="4" width="3" height="6" rx="1" fill="white" fillOpacity="0.8" />
</svg>
);
/** SN 图标 SVG (CPU/芯片风格) */
const SnIcon: React.FC = () => (
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="3" width="12" height="12" rx="2" stroke="#22d3ee" strokeWidth="1.5" />
<rect x="6" y="6" width="6" height="6" rx="1" stroke="#22d3ee" strokeWidth="1.2" />
<line x1="9" y1="0.75" x2="9" y2="3" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="9" y1="15" x2="9" y2="17.25" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="0.75" y1="9" x2="3" y2="9" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="15" y1="9" x2="17.25" y2="9" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="5.25" y1="0.75" x2="5.25" y2="3" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="12.75" y1="0.75" x2="12.75" y2="3" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="5.25" y1="15" x2="5.25" y2="17.25" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="12.75" y1="15" x2="12.75" y2="17.25" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="0.75" y1="5.25" x2="3" y2="5.25" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="0.75" y1="12.75" x2="3" y2="12.75" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="15" y1="5.25" x2="17.25" y2="5.25" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
<line x1="15" y1="12.75" x2="17.25" y2="12.75" stroke="#22d3ee" strokeWidth="1.5" strokeLinecap="round" />
</svg>
);
const ClientLogin: React.FC = () => { const ClientLogin: React.FC = () => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -27,30 +61,49 @@ const ClientLogin: React.FC = () => {
return ( return (
<div className={styles.container}> <div className={styles.container}>
{/* 装饰圆 */}
<div className={styles.decoCircle1} />
<div className={styles.decoCircle2} />
<div className={styles.decoCircle3} />
{/* 管理后台入口 */}
<div className={styles.backEntry}> <div className={styles.backEntry}>
<Button <Button
type="link" type="link"
icon={<DesktopOutlined />} icon={<DesktopOutlined />}
onClick={() => history.push('/user/login')} onClick={() => history.push('/user/login')}
style={{ color: 'rgba(255,255,255,0.7)', fontSize: 14 }} className={styles.backBtn}
> >
管理后台登录 管理后台登录
</Button> </Button>
</div> </div>
{/* 登录卡片 */}
<div className={styles.card}> <div className={styles.card}>
<div className={styles.title}>设备客户端</div> {/* Logo 区域 */}
<div className={styles.subtitle}>请输入设备SN号登录</div> <div className={styles.logoSection}>
<Form onFinish={onFinish} size="large"> <div className={styles.logoCircle}>
<ShipIcon />
</div>
<h1 className={styles.title}>WAVE PILOT</h1>
<p className={styles.subtitle}>无人船智能控制系统</p>
</div>
<div className={styles.divider} />
{/* 表单区域 */}
<Form onFinish={onFinish} size="large" className={styles.form}>
<div className={styles.fieldLabel}>设备序列号 (SN)</div>
<Form.Item name="deviceSn" rules={[{ required: true, message: '请输入设备SN' }]}> <Form.Item name="deviceSn" rules={[{ required: true, message: '请输入设备SN' }]}>
<Input <Input
prefix={<ApiOutlined style={{ color: 'rgba(255,255,255,0.4)' }} />} prefix={<SnIcon />}
placeholder="请输入设备SN号" placeholder="请输入设备SN码,如: USV-2024-XXXXX"
autoComplete="off" autoComplete="off"
/> />
</Form.Item> </Form.Item>
<Form.Item> <Form.Item>
<Button type="primary" htmlType="submit" loading={loading} block> <Button type="primary" htmlType="submit" loading={loading} block icon={<LoginOutlined />}>
登录 连接设备
</Button> </Button>
</Form.Item> </Form.Item>
</Form> </Form>
@@ -25,7 +25,7 @@
transform: translateX(-50%); transform: translateX(-50%);
color: #fff; color: #fff;
font-size: 14px; font-size: 14px;
background: linear-gradient(135deg, rgba(0, 100, 150, 0.85) 0%, rgba(0, 60, 100, 0.85) 100%); background: linear-gradient(135deg, rgba(15, 23, 42, 0.90) 0%, rgba(14, 116, 144, 0.60) 100%);
padding: 10px 20px; padding: 10px 20px;
border-radius: 20px; border-radius: 20px;
z-index: 800; z-index: 800;
@@ -33,14 +33,14 @@
align-items: center; align-items: center;
gap: 10px; gap: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
border: 1px solid rgba(0, 240, 255, 0.3); border: 1px solid rgba(34, 211, 238, 0.3);
} }
.loadingSpinner { .loadingSpinner {
width: 16px; width: 16px;
height: 16px; height: 16px;
border: 2px solid rgba(255, 255, 255, 0.3); border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: #00f0ff; border-top-color: #22d3ee;
border-radius: 50%; border-radius: 50%;
animation: spin 1s linear infinite; animation: spin 1s linear infinite;
} }
@@ -51,51 +51,31 @@
} }
} }
.routeActions { /* ========== 地图底部信息栏 ========== */
.mapBottomBar {
position: absolute; position: absolute;
bottom: 24px; bottom: 0;
left: 50%; left: 0;
transform: translateX(-50%); right: 0;
background: linear-gradient(135deg, rgba(8, 22, 36, 0.94) 0%, rgba(15, 35, 58, 0.9) 100%); height: 56px;
padding: 12px 18px; background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(10, 15, 28, 1));
border-radius: 16px;
z-index: 830;
display: flex; display: flex;
align-items: center; align-items: flex-end;
justify-content: center;
gap: 12px; gap: 12px;
box-shadow: padding-bottom: 14px;
0 16px 34px rgba(0, 0, 0, 0.35), z-index: 10;
inset 0 1px 0 rgba(255, 255, 255, 0.08), pointer-events: none;
inset 0 0 0 1px rgba(73, 174, 255, 0.1);
border: 1px solid rgba(79, 188, 255, 0.28);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
} }
.routeActionsTitle { .mapBottomText {
color: #dff3ff; font-family: 'JetBrains Mono', 'Courier New', monospace;
font-size: 14px; font-size: 12px;
font-weight: 700; font-weight: 500;
max-width: 180px; color: #94a3b8;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
letter-spacing: 0.4px;
} }
@media (max-width: 960px) { .mapBottomSep {
.routeActions { font-size: 12px;
left: 12px; color: #1e3a5f;
right: 12px;
bottom: 12px;
transform: none;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
}
.routeActionsTitle {
max-width: 100%;
width: 100%;
}
} }
@@ -1,6 +1,5 @@
import React, { useEffect, useRef, useState, useCallback, useMemo } from 'react'; import React, { useEffect, useRef, useState, useCallback } from 'react';
import { message, Button, Space } from 'antd'; import { message } from 'antd';
import { PlayCircleOutlined, EyeOutlined, StopOutlined } from '@ant-design/icons';
import { useTilesetLoader } from '@/pages/map3d/components/MapContainer/3d/hooks/useTilesetLoader'; import { useTilesetLoader } from '@/pages/map3d/components/MapContainer/3d/hooks/useTilesetLoader';
import { useCesiumRouteLibraryRenderer } from '@/pages/map3d/components/RouteEditor/hooks/useCesiumRouteLibraryRenderer'; import { useCesiumRouteLibraryRenderer } from '@/pages/map3d/components/RouteEditor/hooks/useCesiumRouteLibraryRenderer';
import { useRoutePreview } from '../../hooks/useRoutePreview'; import { useRoutePreview } from '../../hooks/useRoutePreview';
@@ -20,12 +19,13 @@ interface CenterViewProps {
onModelCenter?: (lon: number, lat: number) => void; onModelCenter?: (lon: number, lat: number) => void;
isSailing?: boolean; isSailing?: boolean;
sailingLoading?: boolean; sailingLoading?: boolean;
previewStartSignal?: number;
previewStopSignal?: number; previewStopSignal?: number;
onStartSailing?: (routeId: string) => Promise<void>; onStartSailing?: (routeId: string) => Promise<void>;
onPreviewChange?: (previewing: boolean) => void; onPreviewChange?: (previewing: boolean) => void;
} }
const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRouteId, boatData, onModelCenter, isSailing, sailingLoading, previewStopSignal, onStartSailing, onPreviewChange }) => { const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRouteId, boatData, onModelCenter, isSailing, sailingLoading, previewStartSignal, previewStopSignal, onStartSailing, onPreviewChange }) => {
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
const viewerRef = useRef<any>(null); const viewerRef = useRef<any>(null);
const [viewerReady, setViewerReady] = useState(false); const [viewerReady, setViewerReady] = useState(false);
@@ -33,6 +33,7 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
const boatEntityRef = useRef<any>(null); const boatEntityRef = useRef<any>(null);
const trackPositionsRef = useRef<any[]>([]); const trackPositionsRef = useRef<any[]>([]);
const terrainLoadedRef = useRef(false); const terrainLoadedRef = useRef(false);
const sailingCameraStateRef = useRef<any>(null);
const { loadTileset, unloadAllTilesets } = useTilesetLoader(); const { loadTileset, unloadAllTilesets } = useTilesetLoader();
const { isPreviewing, startPreview, stopPreview } = useRoutePreview({ viewerRef }); const { isPreviewing, startPreview, stopPreview } = useRoutePreview({ viewerRef });
@@ -44,7 +45,7 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
const lastPreviewStopSignalRef = useRef(previewStopSignal); const lastPreviewStopSignalRef = useRef(previewStopSignal);
// 外部停止通道:例如 HUD 点击“结束预览”时由父组件递增信号 // 外部停止通道:例如 HUD 点击”结束预览”时由父组件递增信号
useEffect(() => { useEffect(() => {
if (previewStopSignal == null) return; if (previewStopSignal == null) return;
if (lastPreviewStopSignalRef.current === previewStopSignal) return; if (lastPreviewStopSignalRef.current === previewStopSignal) return;
@@ -55,6 +56,25 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
} }
}, [previewStopSignal, isPreviewing, stopPreview]); }, [previewStopSignal, isPreviewing, stopPreview]);
// 外部启动预览通道:LeftPanel 点击”预览航线”时由父组件递增信号
const lastPreviewStartSignalRef = useRef(previewStartSignal);
useEffect(() => {
if (previewStartSignal == null) return;
if (lastPreviewStartSignalRef.current === previewStartSignal) return;
lastPreviewStartSignalRef.current = previewStartSignal;
// 延迟执行,等航线航点数据加载完成
const timer = setTimeout(() => {
const waypoints = routeDetailCacheRef.current.get(selectedRouteId || '');
if (waypoints && waypoints.length >= 2) {
startPreview(waypoints, 2);
} else {
message.warning('航点数据不足或未加载,无法预览');
}
}, 300);
return () => clearTimeout(timer);
}, [previewStartSignal, selectedRouteId, startPreview]);
// 航线渲染数据(含航点) // 航线渲染数据(含航点)
const [routeRenderItems, setRouteRenderItems] = useState<any[]>([]); const [routeRenderItems, setRouteRenderItems] = useState<any[]>([]);
// 缓存已加载的航线详情 // 缓存已加载的航线详情
@@ -81,7 +101,7 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
const cesiumBaseUrl = process.env.CESIUM_BASE_URL || '/'; const cesiumBaseUrl = process.env.CESIUM_BASE_URL || '/';
Cesium.buildModuleUrl.setBaseUrl(`${cesiumBaseUrl}cesium/`); Cesium.buildModuleUrl.setBaseUrl(`${cesiumBaseUrl}cesium/`);
// 设置 Ion Token,避免使用内置过期 token 导致 401 // 设置 Cesium Ion Token
const cesiumToken = process.env.REACT_APP_CESIUM_TOKEN; const cesiumToken = process.env.REACT_APP_CESIUM_TOKEN;
if (cesiumToken) { if (cesiumToken) {
Cesium.Ion.defaultAccessToken = cesiumToken; Cesium.Ion.defaultAccessToken = cesiumToken;
@@ -307,6 +327,7 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
latitude: wp.latitude, latitude: wp.latitude,
speed: wp.speed, speed: wp.speed,
stayDuration: wp.stayDuration, stayDuration: wp.stayDuration,
pointName: wp.pointName,
})); }));
routeDetailCacheRef.current.set(selectedRouteId, waypoints); routeDetailCacheRef.current.set(selectedRouteId, waypoints);
} }
@@ -396,7 +417,100 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
viewer.scene.requestRender(); viewer.scene.requestRender();
}, [viewerReady, boatData]); }, [viewerReady, boatData]);
// 预览选中航线 // 执行航线时第一视角跟踪(与预览模式相同的追踪相机)
useEffect(() => {
if (!viewerReady || !Cesium) return;
const viewer = viewerRef.current;
if (!viewer || viewer.isDestroyed()) return;
if (isSailing) {
// 首次进入执行模式:保存相机并定位到航线起点
if (!sailingCameraStateRef.current) {
sailingCameraStateRef.current = {
position: viewer.camera.position.clone(),
heading: viewer.camera.heading,
pitch: viewer.camera.pitch,
roll: viewer.camera.roll,
};
// 从缓存获取航线航点,定位到起点
const waypoints = routeDetailCacheRef.current.get(selectedRouteId || '');
if (waypoints && waypoints.length >= 2) {
const wp0 = waypoints[0];
const wp1 = waypoints[1];
// 计算起点到第二航点的航向
const dLon = (wp1.longitude - wp0.longitude) * Math.PI / 180;
const lat1 = wp0.latitude * Math.PI / 180;
const lat2 = wp1.latitude * Math.PI / 180;
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 headingRad = Math.atan2(y, x);
try {
const startPos = Cesium.Cartesian3.fromDegrees(wp0.longitude, wp0.latitude, 2);
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(startPos);
const localUp = new Cesium.Cartesian3(0, 0, 0.8);
const target = Cesium.Matrix4.multiplyByPoint(enu, localUp, new Cesium.Cartesian3());
viewer.camera.lookAt(
target,
new Cesium.HeadingPitchRange(headingRad, Cesium.Math.toRadians(-20), 22),
);
viewer.scene.requestRender();
} catch { /* ignore */ }
return; // 首帧用起点位置,后续帧跟随 boatData
}
}
// 后续帧:跟随实际船位
if (boatData?.longitude && boatData?.latitude) {
try {
const headingRad = Cesium.Math.toRadians(boatData.heading || 0);
const position = Cesium.Cartesian3.fromDegrees(boatData.longitude, boatData.latitude, 2);
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(position);
const localUp = new Cesium.Cartesian3(0, 0, 0.8);
const target = Cesium.Matrix4.multiplyByPoint(enu, localUp, new Cesium.Cartesian3());
viewer.camera.lookAt(
target,
new Cesium.HeadingPitchRange(headingRad, Cesium.Math.toRadians(-20), 22),
);
viewer.scene.requestRender();
} catch {
try {
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(boatData.longitude, boatData.latitude, 25),
orientation: {
heading: Cesium.Math.toRadians(boatData.heading || 0),
pitch: Cesium.Math.toRadians(-20),
roll: 0,
},
});
} catch { /* ignore */ }
}
}
}
// 退出执行模式:恢复相机
if (!isSailing && sailingCameraStateRef.current) {
try {
if (Cesium?.Matrix4) {
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
}
} catch { /* ignore */ }
try {
viewer.camera.setView({
destination: sailingCameraStateRef.current.position,
orientation: {
heading: sailingCameraStateRef.current.heading,
pitch: sailingCameraStateRef.current.pitch,
roll: sailingCameraStateRef.current.roll,
},
});
} catch { /* ignore */ }
sailingCameraStateRef.current = null;
}
}, [viewerReady, isSailing, boatData, selectedRouteId]);
// 预览选中航线(供外部调用,通过 ref 或直接调用)
const handlePreviewRoute = useCallback(async () => { const handlePreviewRoute = useCallback(async () => {
if (!selectedRouteId) return; if (!selectedRouteId) return;
const waypoints = routeDetailCacheRef.current.get(selectedRouteId); const waypoints = routeDetailCacheRef.current.get(selectedRouteId);
@@ -407,19 +521,6 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
await startPreview(waypoints, 2); await startPreview(waypoints, 2);
}, [selectedRouteId, startPreview]); }, [selectedRouteId, startPreview]);
// 执行航线
const handleExecuteRoute = useCallback(() => {
if (selectedRouteId && onStartSailing) {
onStartSailing(selectedRouteId);
}
}, [selectedRouteId, onStartSailing]);
// 获取选中航线名称
const selectedRouteName = useMemo(() => {
if (!selectedRouteId) return '';
return routes.find((r) => r.routeId === selectedRouteId)?.routeName || '';
}, [selectedRouteId, routes]);
return ( return (
<div className={styles.wrapper}> <div className={styles.wrapper}>
<div ref={containerRef} className={styles.cesiumContainer} /> <div ref={containerRef} className={styles.cesiumContainer} />
@@ -432,34 +533,16 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
</div> </div>
)} )}
{/* 选中线路时显示操作按钮(非航行模式) */} {/* 地图底部信息栏 */}
{selectedRouteId && !isPreviewing && !isSailing && ( <div className={styles.mapBottomBar}>
<div className={styles.routeActions}> <span className={styles.mapBottomText}>
<div className={styles.routeActionsTitle}>{selectedRouteName}</div> 当前坐标: {boatData?.longitude ? `${boatData.longitude.toFixed(4)}°E, ${boatData.latitude.toFixed(4)}°N` : '--'}
<Space> </span>
<Button <span className={styles.mapBottomSep}>|</span>
type="primary" <span className={styles.mapBottomText}>比例尺: 1:5000</span>
icon={<EyeOutlined />} <span className={styles.mapBottomSep}>|</span>
onClick={handlePreviewRoute} <span className={styles.mapBottomText}>高程: 3D模式</span>
size="small" </div>
>
预览线路
</Button>
<Button
icon={<PlayCircleOutlined />}
onClick={handleExecuteRoute}
loading={sailingLoading}
disabled={sailingLoading}
size="small"
style={{ borderColor: '#00ff88', color: sailingLoading ? undefined : '#00ff88' }}
>
{sailingLoading ? '启动中...' : '开始航行'}
</Button>
</Space>
</div>
)}
{/* 预览停止操作已收敛至 NavigationHUD,此处不再重复渲染 */}
</div> </div>
); );
}; };
@@ -66,6 +66,40 @@
100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
} }
@media (max-width: 1280px) {
.emergencyBtn {
width: 130px;
height: 50px;
top: 18px;
right: 18px;
}
.text {
font-size: 14px;
}
.icon {
font-size: 17px;
}
}
@media (max-width: 1024px) {
.emergencyBtn {
width: 120px;
height: 46px;
top: 16px;
right: 16px;
}
.text {
font-size: 13px;
}
.icon {
font-size: 16px;
}
}
@media (max-width: 960px) { @media (max-width: 960px) {
.emergencyBtn { .emergencyBtn {
top: 14px; top: 14px;
@@ -0,0 +1,98 @@
/* ExecBottomStrip - 沉浸模式底部信息条 */
@bg-card: #1e293b;
@border-color: #1e3a5f;
@accent-cyan: #22d3ee;
@text-primary: #ffffff;
@text-secondary: #94a3b8;
@text-dim: #64748b;
@font-mono: 'JetBrains Mono', 'Courier New', monospace;
@font-sans: 'Inter', -apple-system, sans-serif;
.strip {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 80px;
background: rgba(0, 0, 0, 0.85);
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
display: flex;
align-items: center;
justify-content: center;
gap: 60px;
padding: 0 40px;
z-index: 40;
}
/* ── 航线进度区 ── */
.progressSect {
display: flex;
flex-direction: column;
gap: 8px;
width: 300px;
}
.progressTop {
display: flex;
align-items: center;
justify-content: space-between;
}
.progressLabel {
font-family: @font-sans;
font-size: 12px;
font-weight: 500;
color: @text-secondary;
}
.progressValue {
font-family: @font-mono;
font-size: 12px;
font-weight: 500;
color: @accent-cyan;
}
.progressBarBg {
width: 100%;
height: 8px;
background: @bg-card;
border-radius: 4px;
overflow: hidden;
}
.progressBarFill {
height: 100%;
background: linear-gradient(90deg, @accent-cyan, #10b981);
border-radius: 4px;
transition: width 0.5s ease;
}
/* ── 数据区 ── */
.dataSect {
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
}
.dataTitle {
font-family: @font-sans;
font-size: 11px;
font-weight: 500;
color: @text-dim;
}
.dataValue {
font-family: @font-mono;
font-size: 22px;
font-weight: 700;
color: @text-primary;
line-height: 1.2;
}
.dataSub {
font-family: @font-sans;
font-size: 10px;
color: @text-dim;
}
@@ -0,0 +1,64 @@
import React from 'react';
import styles from './index.less';
export interface ExecBottomStripProps {
progress: number;
currentWaypointIndex: number;
totalWaypoints: number;
remainingDistance: number;
estimatedRemainingTime: number;
}
/** 格式化距离 */
const fmtDist = (m: number) => (m >= 1000 ? `${(m / 1000).toFixed(2)}km` : `${Math.round(m)}m`);
/** 格式化时间为 MM:SS */
const fmtTime = (s: number) => {
const safe = Math.max(0, Math.floor(s));
const mm = Math.floor(safe / 60).toString().padStart(2, '0');
const ss = (safe % 60).toString().padStart(2, '0');
return `${mm}:${ss}`;
};
const ExecBottomStrip: React.FC<ExecBottomStripProps> = ({
progress,
currentWaypointIndex,
totalWaypoints,
remainingDistance,
estimatedRemainingTime,
}) => {
const pct = Math.min(100, Math.max(0, progress));
return (
<div className={styles.strip}>
{/* 航线进度 */}
<div className={styles.progressSect}>
<div className={styles.progressTop}>
<span className={styles.progressLabel}>航线进度</span>
<span className={styles.progressValue}>
{currentWaypointIndex + 1}/{totalWaypoints} 航点 · {pct.toFixed(1)}%
</span>
</div>
<div className={styles.progressBarBg}>
<div className={styles.progressBarFill} style={{ width: `${pct}%` }} />
</div>
</div>
{/* 预计剩余 */}
<div className={styles.dataSect}>
<div className={styles.dataTitle}>预计剩余</div>
<div className={styles.dataValue}>{fmtTime(estimatedRemainingTime)}</div>
<div className={styles.dataSub}>分:秒</div>
</div>
{/* 剩余距离 */}
<div className={styles.dataSect}>
<div className={styles.dataTitle}>剩余距离</div>
<div className={styles.dataValue}>{fmtDist(remainingDistance)}</div>
<div className={styles.dataSub}>距离</div>
</div>
</div>
);
};
export default ExecBottomStrip;
@@ -0,0 +1,389 @@
/* ExecLeftPanel - 沉浸模式左侧面板 */
@bg-page: #0a0f1c;
@bg-sidebar: #0f172a;
@bg-card: #1e293b;
@border-color: #1e3a5f;
@accent-cyan: #22d3ee;
@color-green: #10b981;
@color-amber: #f59e0b;
@text-primary: #ffffff;
@text-secondary: #94a3b8;
@text-dim: #64748b;
@text-muted: #475569;
@font-mono: 'JetBrains Mono', 'Courier New', monospace;
@font-sans: 'Inter', -apple-system, sans-serif;
.panel {
width: 260px;
height: 100%;
background: @bg-sidebar;
border-right: 1px solid @border-color;
display: flex;
flex-direction: column;
padding: 14px;
gap: 12px;
overflow: hidden;
flex-shrink: 0;
}
/* ── 仪表盘标题 ── */
.dashTitle {
font-family: @font-mono;
font-size: 10px;
font-weight: 600;
color: @text-dim;
letter-spacing: 1px;
}
/* ── 仪表盘卡片 ── */
.dashCard {
background: @bg-card;
border: 1px solid @border-color;
border-radius: 12px;
padding: 14px;
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
flex-shrink: 0;
}
.speedRow {
display: flex;
justify-content: center;
}
.speedGauge {
width: 130px;
height: 130px;
position: relative;
}
.speedOverlay {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.speedVal {
font-family: @font-mono;
font-size: 26px;
font-weight: 700;
color: @accent-cyan;
line-height: 1;
}
.speedUnit {
font-family: @font-mono;
font-size: 10px;
color: @text-dim;
margin-top: 2px;
}
.speedLabel {
font-family: @font-sans;
font-size: 11px;
font-weight: 500;
color: @text-dim;
text-align: center;
width: 100%;
}
.dashDiv {
width: 100%;
height: 1px;
background: @border-color;
}
/* ── 指标行 ── */
.metricRow {
display: flex;
gap: 8px;
width: 100%;
}
.metricCard {
flex: 1;
background: @bg-page;
border-radius: 8px;
padding: 12px;
display: flex;
flex-direction: column;
gap: 6px;
}
.metricIcon {
font-size: 14px;
color: @text-dim;
line-height: 1;
}
.metricVal {
font-family: @font-mono;
font-size: 15px;
font-weight: 700;
color: @text-primary;
line-height: 1.2;
}
.metricLabel {
font-family: @font-sans;
font-size: 10px;
color: @text-dim;
}
/* ── 航点列表头 ── */
.wpHeader {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
.wpHeaderTitle {
font-family: @font-mono;
font-size: 10px;
font-weight: 600;
color: @text-dim;
}
.wpCountBadge {
display: flex;
align-items: center;
gap: 4px;
padding: 2px 8px;
background: @bg-card;
border: 1px solid @border-color;
border-radius: 10px;
span {
font-family: @font-mono;
font-size: 10px;
font-weight: 500;
color: @text-secondary;
}
}
/* ── 航点滚动列表 ── */
.wpScroll {
flex: 1;
min-height: 0; /* 关键:允许 flex 子项缩小以启用 overflow 滚动 */
overflow-y: auto;
overflow-x: hidden;
background: @bg-card;
border-radius: 8px;
padding: 4px 0;
&::-webkit-scrollbar {
width: 3px;
}
&::-webkit-scrollbar-thumb {
background: rgba(34, 211, 238, 0.25);
border-radius: 2px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
}
.wpItem {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 12px;
min-height: 46px;
transition: background 0.15s;
}
.wpCurrent {
background: rgba(34, 211, 238, 0.06);
}
.wpDot {
width: 24px;
height: 24px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
font-size: 10px;
}
.wpDot_done {
background: @color-green;
color: #fff;
}
.wpDot_current {
background: @accent-cyan;
color: #fff;
}
.wpDot_upcoming {
background: @bg-page;
color: @text-muted;
}
.wpDot_last {
background: rgba(245, 158, 11, 0.15);
color: @color-amber;
}
.wpDotNum {
font-family: @font-mono;
font-size: 11px;
font-weight: 500;
}
.wpInfo {
flex: 1;
min-width: 0;
}
.wpName {
font-family: @font-sans;
font-size: 12px;
color: @text-secondary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.wpCurrent & {
color: @text-primary;
}
}
.wpCoord {
font-family: @font-mono;
font-size: 10px;
color: @text-muted;
margin-top: 2px;
.wpCurrent & {
color: @accent-cyan;
}
}
.wpTag {
font-family: @font-mono;
font-size: 10px;
font-weight: 500;
flex-shrink: 0;
}
.wpDivider {
height: 1px;
background: @border-color;
margin: 0 12px;
}
.scrollHint {
text-align: center;
font-family: @font-sans;
font-size: 10px;
color: @text-muted;
padding: 8px 0;
}
/* ── 平板适配 ── */
@media (max-width: 1024px) {
.panel {
width: 220px;
padding: 10px;
gap: 8px;
}
.dashCard {
padding: 10px;
gap: 6px;
}
.speedGauge {
width: 90px;
height: 90px;
svg {
width: 90px;
height: 90px;
}
}
.speedVal {
font-size: 20px;
}
.speedUnit {
font-size: 9px;
}
.metricCard {
padding: 8px;
gap: 4px;
}
.metricVal {
font-size: 13px;
}
.metricLabel {
font-size: 9px;
}
.wpItem {
padding: 6px 10px;
min-height: 40px;
gap: 8px;
}
.wpDot {
width: 20px;
height: 20px;
font-size: 9px;
}
.wpName {
font-size: 11px;
}
.wpCoord {
font-size: 9px;
}
}
@media (max-height: 700px) {
.dashCard {
padding: 8px;
gap: 4px;
}
.speedGauge {
width: 80px;
height: 80px;
svg {
width: 80px;
height: 80px;
}
}
.speedVal {
font-size: 18px;
}
.speedLabel {
font-size: 10px;
}
.metricCard {
padding: 6px;
gap: 3px;
}
.metricVal {
font-size: 12px;
}
}
@@ -0,0 +1,180 @@
import React, { useMemo, useEffect, useRef } from 'react';
import {
CompassOutlined,
ThunderboltOutlined,
WifiOutlined,
AimOutlined,
FlagOutlined,
CheckOutlined,
SendOutlined,
} from '@ant-design/icons';
import type { BoatTelemetryData, BoatWaypointVO } from '@/types/boatRoute';
import styles from './index.less';
export interface ExecLeftPanelProps {
boatData: BoatTelemetryData | null;
waypoints: BoatWaypointVO[];
currentWaypointIndex: number;
}
/** 速度圆弧 SVG (270度弧, 从底部左侧开始顺时针) */
const SpeedGauge: React.FC<{ speed: number; maxSpeed?: number }> = ({ speed, maxSpeed = 10 }) => {
const r = 52;
const cx = 65;
const cy = 65;
const circumference = 2 * Math.PI * r; // ~326.7
const arcLen = (270 / 360) * circumference; // ~245
const gapLen = circumference - arcLen;
// strokeDashoffset: 让弧线从左下角 (225°) 开始
const offset = -(gapLen / 2) - (circumference * (135 / 360));
const fillRatio = Math.min(speed / maxSpeed, 1);
return (
<svg width="130" height="130" viewBox="0 0 130 130">
<circle
cx={cx} cy={cy} r={r}
fill="none" stroke="#1e3a5f" strokeWidth="4"
strokeDasharray={`${arcLen} ${gapLen}`}
strokeDashoffset={offset}
strokeLinecap="round"
/>
<circle
cx={cx} cy={cy} r={r}
fill="none" stroke="#22d3ee" strokeWidth="4"
strokeDasharray={`${arcLen * fillRatio} ${circumference - arcLen * fillRatio}`}
strokeDashoffset={offset}
strokeLinecap="round"
style={{ transition: 'stroke-dasharray 0.6s ease' }}
/>
</svg>
);
};
const ExecLeftPanel: React.FC<ExecLeftPanelProps> = ({ boatData, waypoints, currentWaypointIndex }) => {
const speed = boatData?.speed ?? 0;
const heading = boatData?.heading ?? 0;
const battery = boatData?.battery ?? 0;
const signal = boatData?.signalStrength ?? 0;
// 航点列表滚动容器
const scrollRef = useRef<HTMLDivElement>(null);
const currentWpRef = useRef<HTMLDivElement>(null);
// 航点条目(带状态)
const wpItems = useMemo(() => {
return waypoints.map((wp, i) => {
let status: 'done' | 'current' | 'upcoming' | 'last' = 'upcoming';
if (i < currentWaypointIndex) status = 'done';
else if (i === currentWaypointIndex) status = 'current';
if (i === waypoints.length - 1 && status === 'upcoming') status = 'last';
return { ...wp, idx: i, status };
});
}, [waypoints, currentWaypointIndex]);
// 当前航点变化时自动滚动到可见
useEffect(() => {
if (currentWpRef.current && scrollRef.current) {
const container = scrollRef.current;
const el = currentWpRef.current;
const top = el.offsetTop - container.offsetTop;
container.scrollTo({ top: Math.max(0, top - 60), behavior: 'smooth' });
}
}, [currentWaypointIndex]);
return (
<div className={styles.panel}>
{/* 仪表盘标题 */}
<div className={styles.dashTitle}>仪表盘</div>
{/* 仪表盘卡片 */}
<div className={styles.dashCard}>
<div className={styles.speedRow}>
<div className={styles.speedGauge}>
<SpeedGauge speed={speed} />
<div className={styles.speedOverlay}>
<span className={styles.speedVal}>{speed.toFixed(1)}</span>
<span className={styles.speedUnit}>knots</span>
</div>
</div>
</div>
<div className={styles.speedLabel}>当前航速</div>
<div className={styles.dashDiv} />
{/* 指标行1: 航向 + 电量 */}
<div className={styles.metricRow}>
<div className={styles.metricCard}>
<CompassOutlined className={styles.metricIcon} />
<div className={styles.metricVal}>{Math.round(heading)}°</div>
<div className={styles.metricLabel}>航向</div>
</div>
<div className={styles.metricCard}>
<ThunderboltOutlined className={styles.metricIcon} />
<div className={styles.metricVal}>{battery}%</div>
<div className={styles.metricLabel}>电量</div>
</div>
</div>
{/* 指标行2: 信号 + 坐标 */}
<div className={styles.metricRow}>
<div className={styles.metricCard}>
<WifiOutlined className={styles.metricIcon} />
<div className={styles.metricVal}>{signal}%</div>
<div className={styles.metricLabel}>信号</div>
</div>
<div className={styles.metricCard}>
<AimOutlined className={styles.metricIcon} />
<div className={styles.metricVal}>{boatData?.longitude?.toFixed(2) ?? '--'}°</div>
<div className={styles.metricLabel}>经度</div>
</div>
</div>
</div>
{/* 航点列表头 */}
<div className={styles.wpHeader}>
<span className={styles.wpHeaderTitle}>航点列表</span>
<div className={styles.wpCountBadge}>
<span>{waypoints.length} 航点</span>
</div>
</div>
{/* 航点滚动列表 */}
<div className={styles.wpScroll} ref={scrollRef}>
{wpItems.length === 0 && (
<div className={styles.scrollHint}>暂无航点数据</div>
)}
{wpItems.map((wp) => (
<React.Fragment key={wp.waypointId || wp.idx}>
<div
className={`${styles.wpItem} ${wp.status === 'current' ? styles.wpCurrent : ''}`}
ref={wp.status === 'current' ? currentWpRef : undefined}
>
<div className={`${styles.wpDot} ${styles[`wpDot_${wp.status}`]}`}>
{wp.status === 'done' && <CheckOutlined style={{ fontSize: 10 }} />}
{wp.status === 'current' && <SendOutlined style={{ fontSize: 10 }} />}
{wp.status === 'last' && <FlagOutlined style={{ fontSize: 10 }} />}
{wp.status === 'upcoming' && <span className={styles.wpDotNum}>{wp.idx + 1}</span>}
</div>
<div className={styles.wpInfo}>
<div className={styles.wpName}>
{wp.pointName || `航点${wp.waypointIndex + 1}`}
</div>
<div className={styles.wpCoord}>
{wp.longitude.toFixed(2)}°E {wp.latitude.toFixed(2)}°N
</div>
</div>
{wp.status === 'done' && <span className={styles.wpTag} style={{ color: '#10b981' }}>完成</span>}
{wp.status === 'current' && <span className={styles.wpTag} style={{ color: '#22d3ee' }}>前往</span>}
</div>
<div className={styles.wpDivider} />
</React.Fragment>
))}
{wpItems.length > 6 && (
<div className={styles.scrollHint}>上下滑动查看更多航点</div>
)}
</div>
</div>
);
};
export default ExecLeftPanel;
@@ -1,247 +1,374 @@
/* ========== 玻璃拟态变量 ========== */ /* ===== 左侧面板 - 基于 Pixso 设计稿 ===== */
@glass-border: rgba(65, 170, 255, 0.28);
@glass-border-light: rgba(92, 211, 255, 0.18); /* ========== 设计令牌 ========== */
@accent-cyan: #00d4ff; @bg-sidebar: #0f172a;
@accent-blue: #0096ff; @bg-card: #1e293b;
@text-primary: #eaf6ff; @border-color: #1e3a5f;
@text-secondary: rgba(255, 255, 255, 0.55); @accent-cyan: #22d3ee;
@text-dim: rgba(255, 255, 255, 0.35); @accent-teal: #0e7490;
@card-bg: linear-gradient(145deg, rgba(10, 24, 48, 0.7), rgba(8, 18, 38, 0.5)); @color-green: #10b981;
@card-bg-active: linear-gradient(145deg, rgba(0, 80, 160, 0.2), rgba(0, 120, 200, 0.1)); @color-amber: #f59e0b;
@card-shadow: 0 2px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06); @color-blue: #3b82f6;
@card-shadow-active: 0 2px 20px rgba(0, 112, 212, 0.2), inset 0 1px 0 rgba(0, 180, 255, 0.12); @text-primary: #ffffff;
@text-secondary: #94a3b8;
@text-dim: #64748b;
@font-mono: 'JetBrains Mono', 'Courier New', monospace;
@font-sans: 'Inter', -apple-system, sans-serif;
@transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); @transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
.panel { .panel {
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} padding: 16px;
/* ========== 头部 ========== */
.header {
padding: 20px 16px 16px;
border-bottom: 1px solid @glass-border-light;
display: flex;
align-items: center;
gap: 12px; gap: 12px;
position: relative;
// 底部渐变高光
&::after {
content: '';
position: absolute;
bottom: -1px;
left: 16px;
right: 16px;
height: 1px;
background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.2), transparent);
}
} }
.headerIcon { /* ========== 信息卡片通用 ========== */
width: 38px; .infoCard {
height: 38px; padding: 14px;
border-radius: 10px; border-radius: 10px;
background: linear-gradient(135deg, rgba(0, 100, 200, 0.35), rgba(0, 180, 255, 0.15)); flex-shrink: 0;
backdrop-filter: blur(8px); }
border: 1px solid rgba(0, 150, 255, 0.25);
.cardHeader {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: space-between;
color: @accent-cyan; margin-bottom: 12px;
font-size: 16px;
flex-shrink: 0;
box-shadow: 0 2px 8px rgba(0, 100, 200, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
} }
.headerTitle { .cardTitle {
font-size: 15px; font-family: @font-mono;
font-size: 10px;
font-weight: 600; font-weight: 600;
color: @text-primary;
line-height: 1.3;
letter-spacing: 0.5px;
}
.headerSub {
font-size: 11px;
color: @text-dim; color: @text-dim;
letter-spacing: 0.3px; text-transform: uppercase;
letter-spacing: 1px;
} }
.count { .badge {
margin-left: auto; display: inline-flex;
background: linear-gradient(135deg, rgba(0, 100, 200, 0.25), rgba(0, 150, 255, 0.15)); align-items: center;
border: 1px solid rgba(0, 150, 255, 0.2); gap: 4px;
color: @accent-cyan; padding: 2px 8px;
font-size: 12px; border-radius: 4px;
font-weight: 700; font-family: @font-mono;
font-family: 'Rajdhani', 'DIN', monospace; font-size: 10px;
padding: 2px 12px; font-weight: 600;
border-radius: 10px; }
.badgeGreen {
background: rgba(16, 185, 129, 0.12);
color: @color-green;
}
.badgeAmber {
background: rgba(245, 158, 11, 0.12);
color: @color-amber;
}
.badgeBlue {
background: rgba(59, 130, 246, 0.12);
color: @color-blue;
}
.badgeDot {
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0; flex-shrink: 0;
letter-spacing: 0.5px;
} }
/* ========== 列表 ========== */ .cardRow {
.list { display: flex;
align-items: center;
justify-content: space-between;
padding: 4px 0;
}
.cardLabel {
display: flex;
align-items: center;
gap: 6px;
font-family: @font-sans;
font-size: 12px;
color: @text-secondary;
}
.cardLabelIcon {
font-size: 13px;
color: @text-dim;
}
.cardValue {
font-family: @font-mono;
font-size: 12px;
font-weight: 600;
}
.cardValueCyan {
color: @accent-cyan;
}
.cardValueGreen {
color: @color-green;
}
.cardValueAmber {
color: @color-amber;
}
.cardValueDim {
color: @text-dim;
font-weight: 500;
}
/* ========== 设备状态卡片 ========== */
.deviceCard {
background: @bg-card;
border: 1px solid @border-color;
}
/* ========== 任务信息卡片 ========== */
.taskCard {
background: rgba(34, 211, 238, 0.05);
border: 1px solid rgba(34, 211, 238, 0.25);
}
/* ========== 电池/信号条 ========== */
.progressBar {
width: 60px;
height: 6px;
background: @bg-sidebar;
border-radius: 3px;
overflow: hidden;
flex-shrink: 0;
}
.progressFill {
height: 100%;
border-radius: 3px;
transition: width 0.3s;
}
.barGroup {
display: flex;
align-items: center;
gap: 6px;
}
/* ========== 分隔线 ========== */
.divider {
height: 1px;
background: @border-color;
flex-shrink: 0;
}
/* ========== 航线区域 ========== */
.routeHeader {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
.routeHeaderTitle {
font-family: @font-mono;
font-size: 10px;
font-weight: 600;
color: @text-dim;
letter-spacing: 1px;
}
.routeCountBadge {
display: flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
background: @bg-card;
border: 1px solid @border-color;
border-radius: 10px;
font-family: @font-mono;
font-size: 10px;
font-weight: 500;
color: @text-secondary;
}
.routeScrollArea {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
padding: 12px 10px; position: relative;
min-height: 0;
}
.routeList {
display: flex;
flex-direction: column;
gap: 8px;
}
.scrollHint {
text-align: center;
font-family: @font-sans;
font-size: 10px;
color: @text-dim;
padding: 8px 0 4px;
} }
.center { .center {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 200px; height: 120px;
} }
/* ========== 线路卡片 ========== */ /* ========== 航线卡片 ========== */
.routeCard { .routeCard {
padding: 14px 16px; padding: 12px 14px;
margin-bottom: 8px;
border-radius: 10px; border-radius: 10px;
cursor: pointer; cursor: pointer;
transition: @transition-fast; transition: @transition-fast;
border: 1px solid rgba(255, 255, 255, 0.05); background: @bg-card;
background: @card-bg; border: 1px solid @border-color;
backdrop-filter: blur(6px);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
position: relative;
overflow: hidden;
// 左侧指示条
&::before {
content: '';
position: absolute;
left: 0;
top: 20%;
bottom: 20%;
width: 2px;
background: transparent;
border-radius: 1px;
transition: @transition-fast;
}
&:hover { &:hover {
background: linear-gradient(145deg, rgba(0, 80, 160, 0.12), rgba(0, 120, 200, 0.06)); border-color: rgba(34, 211, 238, 0.4);
border-color: rgba(0, 150, 255, 0.25);
box-shadow: @card-shadow;
transform: translateX(2px);
&::before {
background: rgba(0, 180, 255, 0.4);
}
} }
} }
.routeCardActive { .routeCardActive {
background: @card-bg-active; background: rgba(34, 211, 238, 0.06);
border-color: rgba(0, 150, 255, 0.4); border-color: @accent-cyan;
box-shadow: @card-shadow-active;
&::before {
background: linear-gradient(180deg, @accent-cyan, @accent-blue);
width: 3px;
top: 12%;
bottom: 12%;
}
.routeName {
color: @accent-cyan;
text-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}
} }
.routeName { .routeCardTop {
font-size: 15px;
font-weight: 600;
color: rgba(255, 255, 255, 0.92);
margin-bottom: 8px;
transition: @transition-fast;
letter-spacing: 0.3px;
}
/* ========== 标签行 ========== */
.tagRow {
display: flex; display: flex;
flex-wrap: wrap; align-items: center;
justify-content: space-between;
margin-bottom: 6px;
}
.routeNameRow {
display: flex;
align-items: center;
gap: 6px; gap: 6px;
margin-bottom: 10px; min-width: 0;
} }
.tag { .routeIcon {
display: inline-flex; font-size: 14px;
align-items: center; color: @accent-cyan;
gap: 4px;
font-size: 11px;
color: @text-secondary;
background: rgba(0, 100, 180, 0.1);
border: 1px solid rgba(0, 150, 255, 0.1);
padding: 2px 8px;
border-radius: 4px;
font-family: 'Rajdhani', 'DIN', sans-serif;
letter-spacing: 0.3px;
}
.tagIcon {
font-size: 10px;
color: rgba(0, 180, 255, 0.65);
}
/* ========== 航点路径 ========== */
.waypointPath {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 5px;
padding: 10px 0 4px;
border-top: 1px solid rgba(65, 170, 255, 0.1);
}
.waypointDot {
width: 6px;
height: 6px;
border-radius: 50%;
background: @accent-cyan;
box-shadow: 0 0 4px rgba(0, 212, 255, 0.4);
flex-shrink: 0; flex-shrink: 0;
} }
.waypointName { .routeName {
font-size: 12px; font-family: @font-sans;
color: rgba(255, 255, 255, 0.7); font-size: 13px;
letter-spacing: 0.2px; font-weight: 700;
color: @text-primary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
.waypointArrow { .routeCardActive .routeName {
font-weight: 700;
}
.routeMeta {
font-family: @font-sans;
font-size: 11px; font-size: 11px;
color: rgba(0, 180, 255, 0.45); color: @text-dim;
margin: 0 1px;
} }
/* ========== 开始航行按钮 ========== */ /* ========== 航线操作按钮 ========== */
.startBtn { .routeActions {
margin-top: 12px; display: flex;
height: 38px; gap: 8px;
border-radius: 8px; margin-top: 10px;
position: relative;
z-index: 2;
}
.btnPreview {
flex: 1;
height: 44px;
min-height: 44px;
border-radius: 7px;
background: @bg-card;
border: 1px solid @accent-cyan;
color: @accent-cyan;
font-family: @font-sans;
font-size: 13px;
font-weight: 600; font-weight: 600;
font-size: 14px; cursor: pointer;
letter-spacing: 1.5px;
background: linear-gradient(135deg, #0070d4, #0096ff);
border: 1px solid rgba(0, 150, 255, 0.3);
box-shadow: 0 2px 12px rgba(0, 112, 212, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
transition: @transition-fast; transition: @transition-fast;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
touch-action: manipulation;
position: relative;
z-index: 2;
&:hover { &:hover {
background: linear-gradient(135deg, #0080e8, #00a8ff); background: rgba(34, 211, 238, 0.08);
box-shadow: 0 4px 20px rgba(0, 112, 212, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
transform: translateY(-1px);
} }
&:active { &:active {
transform: translateY(0); background: rgba(34, 211, 238, 0.15);
box-shadow: 0 1px 6px rgba(0, 112, 212, 0.3);
} }
} }
.btnExecute {
flex: 1;
height: 44px;
min-height: 44px;
border-radius: 7px;
background: linear-gradient(90deg, @accent-teal, @accent-cyan);
border: none;
color: @text-primary;
font-family: @font-sans;
font-size: 13px;
font-weight: 700;
cursor: pointer;
transition: @transition-fast;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
touch-action: manipulation;
position: relative;
z-index: 2;
&:hover {
box-shadow: 0 2px 12px rgba(34, 211, 238, 0.3);
}
&:active {
box-shadow: 0 2px 16px rgba(34, 211, 238, 0.45);
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
/* ========== 滚动条 ========== */
.routeScrollArea::-webkit-scrollbar {
width: 3px;
}
.routeScrollArea::-webkit-scrollbar-thumb {
background: rgba(34, 211, 238, 0.2);
border-radius: 2px;
&:hover {
background: rgba(34, 211, 238, 0.35);
}
}
.routeScrollArea::-webkit-scrollbar-track {
background: transparent;
}
@@ -1,12 +1,16 @@
import React, { useMemo } from 'react'; import React from 'react';
import { Spin, Empty } from 'antd'; import { Spin, Empty } from 'antd';
import { import {
ClockCircleOutlined,
EnvironmentOutlined, EnvironmentOutlined,
SendOutlined, AimOutlined,
NodeIndexOutlined, ThunderboltOutlined,
WifiOutlined,
PlayCircleOutlined,
EyeOutlined,
CompassOutlined,
DownOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import type { BoatRouteListVO, BoatWaypointVO } from '@/types/boatRoute'; import type { BoatRouteListVO, BoatWaypointVO, BoatTelemetryData } from '@/types/boatRoute';
import styles from './index.less'; import styles from './index.less';
interface LeftPanelProps { interface LeftPanelProps {
@@ -15,8 +19,20 @@ interface LeftPanelProps {
loading: boolean; loading: boolean;
selectedRouteId: string | null; selectedRouteId: string | null;
onSelectRoute: (routeId: string | null) => void; onSelectRoute: (routeId: string | null) => void;
deviceInfo: any;
boatData: BoatTelemetryData | null;
sseConnected: boolean;
onStartSailing: (routeId: string) => Promise<void>;
onPreviewRoute: (routeId: string) => void;
sailingLoading: boolean;
} }
/** 格式化距离 */
const formatDistance = (meters?: number) => {
if (!meters || meters <= 0) return null;
return meters >= 1000 ? `${(meters / 1000).toFixed(1)}km` : `${Math.round(meters)}m`;
};
/** 格式化时间(秒 → "XX分钟") */ /** 格式化时间(秒 → "XX分钟") */
const formatDuration = (seconds?: number) => { const formatDuration = (seconds?: number) => {
if (!seconds || seconds <= 0) return null; if (!seconds || seconds <= 0) return null;
@@ -24,98 +40,170 @@ const formatDuration = (seconds?: number) => {
return min > 0 ? `${min}分钟` : '<1分钟'; return min > 0 ? `${min}分钟` : '<1分钟';
}; };
/** 格式化距离 */
const formatDistance = (meters?: number) => {
if (!meters || meters <= 0) return null;
return meters >= 1000 ? `${(meters / 1000).toFixed(1)}km` : `${Math.round(meters)}m`;
};
const LeftPanel: React.FC<LeftPanelProps> = ({ const LeftPanel: React.FC<LeftPanelProps> = ({
routes, routes,
routeWaypointsMap, routeWaypointsMap,
loading, loading,
selectedRouteId, selectedRouteId,
onSelectRoute, onSelectRoute,
deviceInfo,
boatData,
sseConnected,
onStartSailing,
onPreviewRoute,
sailingLoading,
}) => { }) => {
const battery = boatData?.battery ?? 0;
const isOnline = sseConnected;
return ( return (
<div className={styles.panel}> <div className={styles.panel}>
<div className={styles.header}> {/* ========== 设备状态卡片 ========== */}
<div className={styles.headerIcon}> <div className={`${styles.infoCard} ${styles.deviceCard}`}>
<SendOutlined /> <div className={styles.cardHeader}>
<span className={styles.cardTitle}>设备状态</span>
<span className={`${styles.badge} ${isOnline ? styles.badgeGreen : styles.badgeAmber}`}>
<span className={styles.badgeDot} style={{ background: isOnline ? '#10b981' : '#f59e0b' }} />
{isOnline ? '在线' : '离线'}
</span>
</div> </div>
<div>
<div className={styles.headerTitle}>游览线路</div> <div className={styles.cardRow}>
<div className={styles.headerSub}>选择线路开始游览</div> <span className={styles.cardLabel}>
<AimOutlined className={styles.cardLabelIcon} />
GPS 信号
</span>
<span className={`${styles.cardValue} ${styles.cardValueGreen}`}>
{boatData?.longitude ? '强' : '弱'}
</span>
</div>
<div className={styles.cardRow}>
<span className={styles.cardLabel}>
<CompassOutlined className={styles.cardLabelIcon} />
当前位置
</span>
<span className={`${styles.cardValue} ${styles.cardValueCyan}`}>
{boatData?.longitude
? `${boatData.longitude.toFixed(2)}°E ${boatData.latitude.toFixed(2)}°N`
: '--'}
</span>
</div>
<div className={styles.cardRow}>
<span className={styles.cardLabel}>
<ThunderboltOutlined className={styles.cardLabelIcon} />
电池电量
</span>
<div className={styles.barGroup}>
<div className={styles.progressBar}>
<div
className={styles.progressFill}
style={{
width: `${battery}%`,
background: battery > 20 ? '#10b981' : '#ff4d4f',
}}
/>
</div>
<span className={`${styles.cardValue} ${styles.cardValueGreen}`}>{battery}%</span>
</div>
</div>
<div className={styles.cardRow}>
<span className={styles.cardLabel}>
<WifiOutlined className={styles.cardLabelIcon} />
通信信号
</span>
<div className={styles.barGroup}>
<div className={styles.progressBar}>
<div
className={styles.progressFill}
style={{
width: `${boatData?.signalStrength ?? 0}%`,
background: '#10b981',
}}
/>
</div>
<span className={`${styles.cardValue} ${styles.cardValueGreen}`}>
{isOnline ? '4G LTE' : '无信号'}
</span>
</div>
</div> </div>
<span className={styles.count}>{routes.length}</span>
</div> </div>
<div className={styles.list}> {/* ========== 分隔线 ========== */}
<div className={styles.divider} />
{/* ========== 航线区域 ========== */}
<div className={styles.routeHeader}>
<span className={styles.routeHeaderTitle}>浏览线路</span>
<span className={styles.routeCountBadge}>
{routes.length} 条航线
<DownOutlined style={{ fontSize: 8 }} />
</span>
</div>
<div className={styles.routeScrollArea}>
{loading ? ( {loading ? (
<div className={styles.center}><Spin /></div> <div className={styles.center}><Spin /></div>
) : routes.length === 0 ? ( ) : routes.length === 0 ? (
<div className={styles.center}> <div className={styles.center}>
<Empty description="暂无游览线路" image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty description="暂无航线" image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div> </div>
) : ( ) : (
routes.map((route) => { <div className={styles.routeList}>
const isSelected = selectedRouteId === route.routeId; {routes.map((route) => {
const waypoints = routeWaypointsMap[route.routeId] || []; const isSelected = selectedRouteId === route.routeId;
const duration = formatDuration(route.totalDuration); const waypoints = routeWaypointsMap[route.routeId] || [];
const distance = formatDistance(route.totalDistance); const duration = formatDuration(route.totalDuration);
const distance = formatDistance(route.totalDistance);
const wpCount = route.waypointCount || waypoints.length;
// 构建航点路径名称列表 return (
const waypointNames = waypoints <div
.filter((wp) => wp.pointName) key={route.routeId}
.map((wp) => wp.pointName); className={`${styles.routeCard} ${isSelected ? styles.routeCardActive : ''}`}
onClick={() => onSelectRoute(isSelected ? null : route.routeId)}
return ( >
<div <div className={styles.routeCardTop}>
key={route.routeId} <div className={styles.routeNameRow}>
className={`${styles.routeCard} ${isSelected ? styles.routeCardActive : ''}`} <EnvironmentOutlined className={styles.routeIcon} />
onClick={() => onSelectRoute(isSelected ? null : route.routeId)} <span className={styles.routeName}>{route.routeName}</span>
> </div>
{/* 线路名称 */} <span className={`${styles.badge} ${styles.badgeGreen}`}>就绪</span>
<div className={styles.routeName}>{route.routeName}</div>
{/* 时长 + 距离 标签 */}
<div className={styles.tagRow}>
{duration && (
<span className={styles.tag}>
<ClockCircleOutlined className={styles.tagIcon} />
{duration}
</span>
)}
{distance && (
<span className={styles.tag}>
<EnvironmentOutlined className={styles.tagIcon} />
{distance}
</span>
)}
<span className={styles.tag}>
<NodeIndexOutlined className={styles.tagIcon} />
{route.waypointCount || waypoints.length}个景点
</span>
</div>
{/* 航点路径 */}
{waypointNames.length > 0 && (
<div className={styles.waypointPath}>
{waypointNames.map((name, idx) => (
<React.Fragment key={idx}>
<span className={styles.waypointDot} />
<span className={styles.waypointName}>{name}</span>
{idx < waypointNames.length - 1 && (
<span className={styles.waypointArrow}>→</span>
)}
</React.Fragment>
))}
</div> </div>
)} <div className={styles.routeMeta}>
</div> {wpCount}个航点{distance ? ` · 约${distance}` : ''}{duration ? ` · 预计${duration}` : ''}
); </div>
})
{/* 选中时显示操作按钮 */}
{isSelected && (
<div className={styles.routeActions} onClick={(e) => e.stopPropagation()}>
<button
className={styles.btnPreview}
onClick={(e) => { e.stopPropagation(); onPreviewRoute(route.routeId); }}
onTouchEnd={(e) => { e.stopPropagation(); e.preventDefault(); onPreviewRoute(route.routeId); }}
>
<EyeOutlined />
预览航线
</button>
<button
className={styles.btnExecute}
disabled={sailingLoading}
onClick={(e) => { e.stopPropagation(); onStartSailing(route.routeId); }}
onTouchEnd={(e) => { if (sailingLoading) return; e.stopPropagation(); e.preventDefault(); onStartSailing(route.routeId); }}
>
<PlayCircleOutlined />
{sailingLoading ? '启动中...' : '执行航线'}
</button>
</div>
)}
</div>
);
})}
</div>
)} )}
{routes.length > 2 && <div className={styles.scrollHint}>上下滑动查看更多航线</div>}
</div> </div>
</div> </div>
); );
@@ -23,8 +23,26 @@
font-family: 'Rajdhani', 'DIN', 'Avenir Next', 'PingFang SC', sans-serif; font-family: 'Rajdhani', 'DIN', 'Avenir Next', 'PingFang SC', sans-serif;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
overflow: hidden; overflow: hidden;
// 侧边栏垂直布局模式
:global(.navigationPanel) & {
position: static;
transform: none;
width: 100%;
max-width: none;
display: flex;
flex-direction: column;
gap: 12px;
border-radius: 0;
padding: 0;
background: transparent;
border: none;
box-shadow: none;
}
} }
.sidebarLayout {}
.hudContainer::before { .hudContainer::before {
content: ''; content: '';
position: absolute; position: absolute;
@@ -60,6 +78,15 @@
.actionCluster { .actionCluster {
position: relative; position: relative;
z-index: 1; z-index: 1;
// 侧边栏垂直布局模式
:global(.navigationPanel) & {
background: linear-gradient(145deg, rgba(10, 24, 48, 0.7), rgba(8, 18, 38, 0.5));
border: 1px solid rgba(65, 170, 255, 0.28);
border-radius: 12px;
padding: 14px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
} }
.primaryCluster { .primaryCluster {
@@ -68,6 +95,11 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 8px; gap: 8px;
:global(.navigationPanel) & {
flex-direction: row;
justify-content: space-between;
}
} }
.speedDial { .speedDial {
@@ -138,6 +170,10 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
gap: 10px; gap: 10px;
:global(.navigationPanel) & {
gap: 8px;
}
} }
.routeHeader { .routeHeader {
@@ -145,6 +181,12 @@
align-items: baseline; align-items: baseline;
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 12px;
:global(.navigationPanel) & {
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
} }
.routeTitle { .routeTitle {
@@ -154,12 +196,20 @@
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
:global(.navigationPanel) & {
font-size: 16px;
}
} }
.routeProgress { .routeProgress {
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
color: #7fd9ff; color: #7fd9ff;
:global(.navigationPanel) & {
font-size: 13px;
}
} }
.routeProgressTrack { .routeProgressTrack {
@@ -187,6 +237,13 @@
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 16px; gap: 16px;
:global(.navigationPanel) & {
flex-direction: column;
align-items: stretch;
gap: 8px;
padding: 8px 10px;
}
} }
.waypointMain { .waypointMain {
@@ -194,18 +251,30 @@
align-items: center; align-items: center;
gap: 10px; gap: 10px;
min-width: 0; min-width: 0;
:global(.navigationPanel) & {
gap: 8px;
}
} }
.navArrow { .navArrow {
font-size: 20px; font-size: 20px;
color: #59cbff; color: #59cbff;
filter: drop-shadow(0 0 6px rgba(89, 203, 255, 0.7)); filter: drop-shadow(0 0 6px rgba(89, 203, 255, 0.7));
:global(.navigationPanel) & {
font-size: 16px;
}
} }
.infoLabel { .infoLabel {
font-size: 11px; font-size: 11px;
letter-spacing: 0.6px; letter-spacing: 0.6px;
color: rgba(195, 226, 255, 0.7); color: rgba(195, 226, 255, 0.7);
:global(.navigationPanel) & {
font-size: 10px;
}
} }
.waypointName { .waypointName {
@@ -216,11 +285,21 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
max-width: 220px; max-width: 220px;
:global(.navigationPanel) & {
font-size: 14px;
max-width: 100%;
}
} }
.waypointStats { .waypointStats {
display: flex; display: flex;
gap: 20px; gap: 20px;
:global(.navigationPanel) & {
flex-direction: column;
gap: 6px;
}
} }
.infoValue { .infoValue {
@@ -228,6 +307,10 @@
font-size: 17px; font-size: 17px;
color: #8de5ff; color: #8de5ff;
font-weight: 700; font-weight: 700;
:global(.navigationPanel) & {
font-size: 15px;
}
} }
.emptyWaypoint { .emptyWaypoint {
@@ -240,10 +323,19 @@
.summaryRow { .summaryRow {
display: flex; display: flex;
gap: 28px; gap: 28px;
:global(.navigationPanel) & {
flex-direction: column;
gap: 8px;
}
} }
.summaryItem { .summaryItem {
min-width: 92px; min-width: 92px;
:global(.navigationPanel) & {
min-width: 0;
}
} }
.summaryValue { .summaryValue {
@@ -251,6 +343,10 @@
font-size: 15px; font-size: 15px;
font-weight: 700; font-weight: 700;
color: #e6f5ff; color: #e6f5ff;
:global(.navigationPanel) & {
font-size: 14px;
}
} }
.statusCluster { .statusCluster {
@@ -258,6 +354,10 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
gap: 10px; gap: 10px;
:global(.navigationPanel) & {
gap: 8px;
}
} }
.compassCard, .compassCard,
@@ -266,6 +366,10 @@
padding: 8px 10px; padding: 8px 10px;
background: rgba(12, 29, 48, 0.78); background: rgba(12, 29, 48, 0.78);
border: 1px solid rgba(106, 176, 238, 0.22); border: 1px solid rgba(106, 176, 238, 0.22);
:global(.navigationPanel) & {
padding: 8px;
}
} }
.cardTitle { .cardTitle {
@@ -274,6 +378,10 @@
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
:global(.navigationPanel) & {
font-size: 11px;
}
} }
.compassDial { .compassDial {
@@ -284,6 +392,11 @@
border: 1px solid rgba(141, 208, 255, 0.3); border: 1px solid rgba(141, 208, 255, 0.3);
background: radial-gradient(circle at center, rgba(68, 157, 226, 0.25) 0%, rgba(8, 23, 38, 0.8) 70%); background: radial-gradient(circle at center, rgba(68, 157, 226, 0.25) 0%, rgba(8, 23, 38, 0.8) 70%);
position: relative; position: relative;
:global(.navigationPanel) & {
width: 60px;
height: 60px;
}
} }
.compassRotor { .compassRotor {
@@ -321,6 +434,10 @@
font-size: 13px; font-size: 13px;
font-weight: 700; font-weight: 700;
color: #ecf8ff; color: #ecf8ff;
:global(.navigationPanel) & {
font-size: 12px;
}
} }
.powerCard { .powerCard {
@@ -340,6 +457,10 @@
font-size: 13px; font-size: 13px;
font-weight: 700; font-weight: 700;
color: #f7fbff; color: #f7fbff;
:global(.navigationPanel) & {
font-size: 12px;
}
} }
.powerTrack { .powerTrack {
@@ -369,6 +490,10 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
gap: 10px; gap: 10px;
:global(.navigationPanel) & {
gap: 8px;
}
} }
.actionBtn { .actionBtn {
@@ -385,6 +510,11 @@
gap: 8px; gap: 8px;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
:global(.navigationPanel) & {
height: 38px;
font-size: 13px;
}
} }
.actionBtn:active { .actionBtn:active {
@@ -410,6 +540,123 @@
filter: brightness(1.06); filter: brightness(1.06);
} }
@media (max-width: 1400px) {
.hudContainer {
// 平板通用方案:紧凑的2行布局
grid-template-columns: auto 1fr auto;
grid-template-rows: auto auto;
gap: 10px;
padding: 10px 12px;
max-width: calc(100% - 100px);
}
.primaryCluster {
grid-column: 1;
grid-row: 1 / 3;
}
.centerCluster {
grid-column: 2;
grid-row: 1 / 3;
}
.statusCluster {
grid-column: 3;
grid-row: 1;
}
.actionCluster {
grid-column: 3;
grid-row: 2;
}
.speedDial {
width: 90px;
height: 90px;
}
.speedValue {
font-size: 28px;
}
.routeTitle {
font-size: 17px;
}
.waypointName {
font-size: 14px;
max-width: 200px;
}
.compassDial {
width: 60px;
height: 60px;
}
.compassTick {
transform-origin: 50% 25px;
}
.actionBtn {
height: 36px;
font-size: 13px;
}
}
@media (max-width: 1280px) {
.hudContainer {
max-width: calc(100% - 80px);
gap: 8px;
padding: 10px;
}
.speedDial {
width: 80px;
height: 80px;
}
.speedValue {
font-size: 26px;
}
.speedUnit {
font-size: 11px;
}
.routeTitle {
font-size: 16px;
}
.waypointName {
font-size: 13px;
max-width: 180px;
}
.compassDial {
width: 56px;
height: 56px;
}
.compassTick {
transform-origin: 50% 23px;
height: 6px;
}
.compassNeedle {
top: 6px;
border-bottom: 12px solid #ff8f66;
}
.compassValue {
font-size: 12px;
}
.actionBtn {
height: 34px;
font-size: 12px;
}
}
@media (max-width: 1240px) { @media (max-width: 1240px) {
.hudContainer { .hudContainer {
grid-template-columns: 154px 1fr 200px 154px; grid-template-columns: 154px 1fr 200px 154px;
@@ -429,6 +676,71 @@
} }
} }
@media (max-width: 1024px) {
.hudContainer {
max-width: calc(100% - 60px);
bottom: 16px;
gap: 6px;
padding: 8px 10px;
}
.speedDial {
width: 70px;
height: 70px;
}
.speedValue {
font-size: 24px;
}
.modeChip {
font-size: 10px;
padding: 2px 8px;
}
.routeTitle {
font-size: 15px;
}
.waypointName {
font-size: 13px;
max-width: 150px;
}
.infoValue {
font-size: 14px;
}
.compassDial {
width: 52px;
height: 52px;
}
.compassTick {
transform-origin: 50% 21px;
height: 5px;
}
.compassNeedle {
top: 5px;
border-bottom: 10px solid #ff8f66;
}
.compassValue {
font-size: 11px;
}
.powerCard {
gap: 3px;
}
.actionBtn {
height: 32px;
font-size: 12px;
gap: 6px;
}
}
@media (max-width: 960px) { @media (max-width: 960px) {
.hudContainer { .hudContainer {
left: 12px; left: 12px;
@@ -464,4 +776,33 @@
.actionBtn { .actionBtn {
flex: 1; flex: 1;
} }
.hudContainer.sidebarLayout {
left: auto;
right: auto;
bottom: auto;
transform: none;
width: 100%;
max-height: none;
overflow: visible;
}
.hudContainer.sidebarLayout .statusCluster,
.hudContainer.sidebarLayout .actionCluster {
flex-direction: column;
align-items: stretch;
justify-content: center;
}
.hudContainer.sidebarLayout .centerCluster {
order: 0;
}
.hudContainer.sidebarLayout .summaryRow {
justify-content: flex-start;
}
.hudContainer.sidebarLayout .actionBtn {
flex: none;
}
} }
@@ -31,6 +31,7 @@ export interface NavigationHUDProps {
onPause: () => void; onPause: () => void;
onResume: () => void; onResume: () => void;
onStop: () => void; onStop: () => void;
layout?: 'bottom' | 'sidebar';
} }
/** 格式化距离 */ /** 格式化距离 */
@@ -75,6 +76,7 @@ const NavigationHUD: React.FC<NavigationHUDProps> = ({
onPause, onPause,
onResume, onResume,
onStop, onStop,
layout = 'bottom',
}) => { }) => {
const maxSpeed = 12; const maxSpeed = 12;
const clampedSpeed = Math.max(0, Math.min(speed, maxSpeed)); const clampedSpeed = Math.max(0, Math.min(speed, maxSpeed));
@@ -97,9 +99,12 @@ const NavigationHUD: React.FC<NavigationHUDProps> = ({
const actionText = previewing ? '结束预览' : isPaused ? '继续航行' : '暂停航行'; const actionText = previewing ? '结束预览' : isPaused ? '继续航行' : '暂停航行';
const actionIcon = previewing ? <StopOutlined /> : isPaused ? <PlayCircleOutlined /> : <PauseCircleOutlined />; const actionIcon = previewing ? <StopOutlined /> : isPaused ? <PlayCircleOutlined /> : <PauseCircleOutlined />;
const actionHandler = previewing ? onStop : isPaused ? onResume : onPause; const actionHandler = previewing ? onStop : isPaused ? onResume : onPause;
const isSidebar = layout === 'sidebar';
return ( return (
<div className={`${styles.hudContainer} ${previewing ? styles.previewMode : styles.sailingMode}`}> <div
className={`${styles.hudContainer} ${previewing ? styles.previewMode : styles.sailingMode} ${isSidebar ? styles.sidebarLayout : ''}`}
>
<div className={styles.primaryCluster}> <div className={styles.primaryCluster}>
<div className={styles.speedDial}> <div className={styles.speedDial}>
<svg viewBox="0 0 120 120" className={styles.speedSvg}> <svg viewBox="0 0 120 120" className={styles.speedSvg}>
@@ -3,7 +3,8 @@
top: 20px; top: 20px;
left: 20px; left: 20px;
z-index: 910; z-index: 910;
width: 340px; width: 320px;
max-width: calc(100% - 40px);
border-radius: 20px; border-radius: 20px;
padding: 14px; padding: 14px;
background: background:
@@ -342,6 +343,42 @@
color: rgba(206, 228, 246, 0.72); color: rgba(206, 228, 246, 0.72);
} }
@media (max-width: 1280px) {
.overlay {
width: 300px;
padding: 12px;
}
.title {
font-size: 20px;
}
.waypointList {
max-height: 240px;
}
}
@media (max-width: 1024px) {
.overlay {
width: 280px;
padding: 10px;
top: 16px;
left: 16px;
}
.title {
font-size: 18px;
}
.progressCard {
padding: 10px;
}
.waypointList {
max-height: 200px;
}
}
@media (max-width: 960px) { @media (max-width: 960px) {
.overlay { .overlay {
width: calc(100% - 24px); width: calc(100% - 24px);
@@ -32,6 +32,15 @@
height: 1px; height: 1px;
background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.15), transparent); background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.15), transparent);
} }
// 平板适配:缩小内边距
@media (max-width: 1280px) {
padding: 12px;
}
@media (max-width: 1024px) {
padding: 10px;
}
} }
.sectionTitle { .sectionTitle {
@@ -66,6 +75,17 @@
border-radius: 12px; border-radius: 12px;
border: 1px solid rgba(0, 100, 200, 0.15); border: 1px solid rgba(0, 100, 200, 0.15);
box-shadow: @card-shadow; box-shadow: @card-shadow;
// 平板适配:缩小罗盘尺寸
@media (max-width: 1280px) {
padding: 10px;
margin-bottom: 10px;
}
@media (max-width: 1024px) {
padding: 8px;
margin-bottom: 8px;
}
} }
.compass { .compass {
@@ -73,6 +93,17 @@
height: 180px; height: 180px;
position: relative; position: relative;
filter: drop-shadow(0 0 8px rgba(0, 150, 255, 0.15)); filter: drop-shadow(0 0 8px rgba(0, 150, 255, 0.15));
// 平板适配:缩小罗盘
@media (max-width: 1280px) {
width: 150px;
height: 150px;
}
@media (max-width: 1024px) {
width: 130px;
height: 130px;
}
} }
.compassSvg { .compassSvg {
@@ -102,6 +133,15 @@
font-family: 'Rajdhani', 'DIN', monospace; font-family: 'Rajdhani', 'DIN', monospace;
text-shadow: 0 0 12px rgba(0, 212, 255, 0.3); text-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
letter-spacing: 1px; letter-spacing: 1px;
// 平板适配:缩小字体
@media (max-width: 1280px) {
font-size: 20px;
}
@media (max-width: 1024px) {
font-size: 18px;
}
} }
/* ========== 左转/右转 ========== */ /* ========== 左转/右转 ========== */
@@ -249,6 +289,17 @@
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
// 平板适配:缩小内边距
@media (max-width: 1280px) {
padding: 12px;
margin-bottom: 8px;
}
@media (max-width: 1024px) {
padding: 10px;
margin-bottom: 6px;
}
} }
/* 三级玻璃层次 */ /* 三级玻璃层次 */
@@ -21,6 +21,7 @@ export function useRoutePreview({ viewerRef }: UseRoutePreviewOptions): UseRoute
const previewAnimationRef = useRef<number | null>(null); const previewAnimationRef = useRef<number | null>(null);
const savedCameraStateRef = useRef<any>(null); const savedCameraStateRef = useRef<any>(null);
const previewBoatPartsRef = useRef<{ hull?: any; cabin?: any; mast?: any; marker?: any } | null>(null); const previewBoatPartsRef = useRef<{ hull?: any; cabin?: any; mast?: any; marker?: any } | null>(null);
const previewRouteEntityRef = useRef<any>(null);
const getCesium = useCallback(() => (window as any).Cesium, []); const getCesium = useCallback(() => (window as any).Cesium, []);
@@ -64,6 +65,18 @@ export function useRoutePreview({ viewerRef }: UseRoutePreviewOptions): UseRoute
} }
} }
// 清理预览航线实体
if (previewRouteEntityRef.current) {
try {
const viewer = viewerRef?.current;
if (viewer && !viewer.isDestroyed?.()) {
viewer.entities.remove(previewRouteEntityRef.current);
}
} catch { /* ignore */ } finally {
previewRouteEntityRef.current = null;
}
}
// 恢复相机 // 恢复相机
if (savedCameraStateRef.current && viewerRef?.current) { if (savedCameraStateRef.current && viewerRef?.current) {
const viewer = viewerRef.current; const viewer = viewerRef.current;
@@ -179,6 +192,23 @@ export function useRoutePreview({ viewerRef }: UseRoutePreviewOptions): UseRoute
setIsPreviewing(true); setIsPreviewing(true);
message.info('开始航线预览,按ESC退出'); message.info('开始航线预览,按ESC退出');
// 添加可见的预览航线实体(确保第一视角能看到整条航线)
try {
const routeEntity = viewer.entities.add({
polyline: {
positions: polylinePositions,
width: 6,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.4,
color: Cesium.Color.fromCssColorString('#22d3ee').withAlpha(0.9),
}),
depthFailMaterial: Cesium.Color.fromCssColorString('#22d3ee').withAlpha(0.5),
clampToGround: false,
},
});
previewRouteEntityRef.current = routeEntity;
} catch { /* ignore */ }
const chaseRange = 22; const chaseRange = 22;
const chasePitch = -20; const chasePitch = -20;
const ellipsoid = Cesium.Ellipsoid?.WGS84; const ellipsoid = Cesium.Ellipsoid?.WGS84;
@@ -463,6 +493,16 @@ export function useRoutePreview({ viewerRef }: UseRoutePreviewOptions): UseRoute
previewBoatPartsRef.current = null; previewBoatPartsRef.current = null;
} }
} }
if (previewRouteEntityRef.current) {
try {
const viewer = viewerRef?.current;
if (viewer && !viewer.isDestroyed?.()) {
viewer.entities.remove(previewRouteEntityRef.current);
}
} catch { /* ignore */ } finally {
previewRouteEntityRef.current = null;
}
}
if (savedCameraStateRef.current && viewerRef?.current) { if (savedCameraStateRef.current && viewerRef?.current) {
const viewer = viewerRef.current; const viewer = viewerRef.current;
const Cesium = (window as any).Cesium; const Cesium = (window as any).Cesium;
+328 -134
View File
@@ -1,147 +1,341 @@
/* ========== 全局变量 ========== */ /* ===== 客户端主页 - 基于 Pixso 设计稿 02-Home ===== */
@glass-bg: linear-gradient(135deg, rgba(7, 20, 40, 0.92), rgba(12, 28, 52, 0.88));
@glass-border: rgba(65, 170, 255, 0.28);
@glass-blur: blur(16px);
@glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
@accent-cyan: #00d4ff;
@accent-blue: #0096ff;
@text-primary: #eaf6ff;
@text-secondary: rgba(255, 255, 255, 0.55);
@transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
/* ========== 设计令牌 ========== */
@bg-page: #0a0f1c;
@bg-sidebar: #0f172a;
@bg-card: #1e293b;
@border-color: #1e3a5f;
@accent-cyan: #22d3ee;
@accent-teal: #0e7490;
@color-green: #10b981;
@color-amber: #f59e0b;
@color-blue: #3b82f6;
@text-primary: #ffffff;
@text-secondary: #94a3b8;
@text-dim: #64748b;
@font-mono: 'JetBrains Mono', 'Courier New', monospace;
@font-sans: 'Inter', -apple-system, sans-serif;
@transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
/* ========== 容器 ========== */
.container { .container {
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
display: flex; display: flex;
background: #060e1a; flex-direction: column;
background: @bg-page;
color: @text-primary; color: @text-primary;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
} }
.leftPanel { /* ========== 顶部导航栏 ========== */
width: 290px; .navBar {
height: calc(100vh - 40px); height: 60px;
background: @glass-bg;
backdrop-filter: @glass-blur;
-webkit-backdrop-filter: @glass-blur;
border-right: 1px solid @glass-border;
box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04), 4px 0 20px rgba(0, 0, 0, 0.3);
overflow-y: auto;
flex-shrink: 0; flex-shrink: 0;
transition: @transition-smooth;
position: relative;
// 顶部高光线
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.3), transparent);
}
}
.centerView {
flex: 1;
height: calc(100vh - 40px);
position: relative;
transition: @transition-smooth;
}
.rightPanel {
width: 320px;
height: calc(100vh - 40px);
background: @glass-bg;
backdrop-filter: @glass-blur;
-webkit-backdrop-filter: @glass-blur;
border-left: 1px solid @glass-border;
box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.04), -4px 0 20px rgba(0, 0, 0, 0.3);
overflow-y: auto;
flex-shrink: 0;
transition: @transition-smooth;
position: relative;
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.3), transparent);
}
}
/* ========== 沉浸模式 ========== */
.sailing {
.leftPanel {
width: 0;
opacity: 0;
overflow: hidden;
border-right: none;
padding: 0;
box-shadow: none;
}
.rightPanel {
width: 0;
opacity: 0;
overflow: hidden;
border-left: none;
padding: 0;
box-shadow: none;
}
.centerView {
height: 100vh;
}
.statusBar {
opacity: 0;
pointer-events: none;
transform: translateY(100%);
}
}
/* ========== 底部状态栏 ========== */
.statusBar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 40px;
background: linear-gradient(180deg, rgba(7, 16, 32, 0.92), rgba(5, 12, 24, 0.96));
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border-top: 1px solid @glass-border;
box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 20px; padding: 0 20px;
font-size: 12px; background: @bg-sidebar;
color: @text-secondary; border-bottom: 1px solid @border-color;
z-index: 100; z-index: 100;
transition: @transition-smooth; gap: 16px;
font-family: 'Rajdhani', 'DIN', 'Roboto Mono', monospace;
letter-spacing: 0.5px;
} }
.statusDot { .navLogo {
display: flex;
align-items: center;
gap: 10px;
flex-shrink: 0;
}
.navLogoIcon {
width: 36px;
height: 36px;
border-radius: 8px;
background: linear-gradient(135deg, @accent-teal, @accent-cyan);
display: flex;
align-items: center;
justify-content: center;
}
.navLogoText {
font-family: @font-mono;
font-size: 15px;
font-weight: 700;
color: @text-primary;
letter-spacing: 3px;
white-space: nowrap;
}
.navSpacer {
flex: 1;
}
.navTabs {
display: flex;
gap: 4px;
flex-shrink: 0;
}
.navTab {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 16px;
border-radius: 8px;
border: 1px solid transparent;
background: transparent;
color: @text-dim;
font-family: @font-sans;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: @transition-fast;
white-space: nowrap;
&:hover {
color: @text-secondary;
background: rgba(255, 255, 255, 0.03);
}
}
.navTabActive {
background: rgba(34, 211, 238, 0.10);
border-color: @accent-cyan;
color: @accent-cyan;
font-weight: 600;
}
.navRight {
display: flex;
align-items: center;
gap: 12px;
flex-shrink: 0;
}
.navIconBtn {
color: @text-dim;
font-size: 16px;
cursor: pointer;
transition: color 0.2s;
&:hover {
color: @text-secondary;
}
}
.devIndicator {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 12px;
background: #131c2e;
border: 1px solid @border-color;
border-radius: 6px;
}
.devDot {
width: 8px; width: 8px;
height: 8px; height: 8px;
border-radius: 50%; border-radius: 50%;
margin-right: 8px; flex-shrink: 0;
display: inline-block;
box-shadow: 0 0 6px currentColor;
animation: statusPulse 2s ease-in-out infinite; animation: statusPulse 2s ease-in-out infinite;
} }
@keyframes statusPulse { .devSn {
0%, 100% { opacity: 1; } font-family: @font-mono;
50% { opacity: 0.5; } font-size: 12px;
font-weight: 500;
color: @text-secondary;
white-space: nowrap;
}
.navLogoutBtn {
color: @text-dim !important;
font-size: 14px !important;
&:hover {
color: @text-secondary !important;
}
}
/* ========== 主体区域 ========== */
.mainBody {
flex: 1;
display: flex;
overflow: hidden;
}
/* ========== 左侧边栏 ========== */
.leftPanel {
width: 280px;
height: 100%;
background: @bg-sidebar;
border-right: 1px solid @border-color;
overflow: hidden;
flex-shrink: 0;
transition: @transition-fast;
@media (max-width: 1280px) {
width: 260px;
}
@media (max-width: 1024px) {
width: 240px;
}
}
/* ========== 地图区域 ========== */
.centerView {
flex: 1;
height: 100%;
position: relative;
}
/* ========== 沉浸模式标记 ========== */
.sailing {
/* TSX 通过条件渲染控制显隐,此类仅作标记 */
}
/* ========== 沉浸模式 - 执行导航栏 ========== */
.execNav {
height: 64px;
flex-shrink: 0;
display: flex;
align-items: center;
padding: 0 20px;
background: @bg-sidebar;
border-bottom: 1px solid @border-color;
z-index: 100;
gap: 16px;
}
.execBackBtn {
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
background: @bg-card;
border: 1px solid @border-color;
border-radius: 8px;
color: @text-secondary;
font-size: 14px;
cursor: pointer;
flex-shrink: 0;
transition: @transition-fast;
&:hover {
background: lighten(@bg-card, 5%);
color: @text-primary;
}
}
.execTitleArea {
display: flex;
flex-direction: column;
gap: 2px;
flex-shrink: 0;
}
.execTitle {
font-family: @font-sans;
font-size: 16px;
font-weight: 700;
color: @text-primary;
line-height: 1.2;
white-space: nowrap;
}
.execSubtitle {
font-family: @font-mono;
font-size: 11px;
font-weight: 500;
color: @text-dim;
line-height: 1.2;
white-space: nowrap;
}
.execBadge {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
background: rgba(34, 211, 238, 0.15);
border: 1px solid @accent-cyan;
border-radius: 6px;
flex-shrink: 0;
span {
font-family: @font-mono;
font-size: 11px;
font-weight: 600;
color: @accent-cyan;
white-space: nowrap;
}
}
.execBadgeDot {
width: 8px;
height: 8px;
border-radius: 50%;
background: @accent-cyan;
flex-shrink: 0;
animation: statusPulse 2s ease-in-out infinite;
}
.execSpacer {
flex: 1;
}
.execRight {
display: flex;
align-items: center;
gap: 10px;
flex-shrink: 0;
}
.execPauseBtn {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
width: 74px;
height: 36px;
background: rgba(245, 158, 11, 0.10);
border: 1px solid @color-amber;
border-radius: 8px;
color: @color-amber;
font-family: @font-sans;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: @transition-fast;
&:hover {
background: rgba(245, 158, 11, 0.20);
}
}
.execStopBtn {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
width: 74px;
height: 36px;
background: rgba(239, 68, 68, 0.10);
border: 1px solid #ef4444;
border-radius: 8px;
color: #ef4444;
font-family: @font-sans;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: @transition-fast;
&:hover {
background: rgba(239, 68, 68, 0.20);
}
} }
/* ========== 设备离线遮罩 ========== */ /* ========== 设备离线遮罩 ========== */
@@ -165,7 +359,7 @@
background: linear-gradient(135deg, rgba(14, 30, 56, 0.95), rgba(8, 18, 36, 0.98)); background: linear-gradient(135deg, rgba(14, 30, 56, 0.95), rgba(8, 18, 36, 0.98));
border: 1px solid rgba(255, 80, 80, 0.3); border: 1px solid rgba(255, 80, 80, 0.3);
border-radius: 12px; border-radius: 12px;
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04); box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
text-align: center; text-align: center;
max-width: 360px; max-width: 360px;
} }
@@ -174,14 +368,12 @@
font-size: 40px; font-size: 40px;
color: #ff4d4f; color: #ff4d4f;
margin-bottom: 16px; margin-bottom: 16px;
opacity: 0.9;
} }
.offlineTitle { .offlineTitle {
font-size: 20px; font-size: 20px;
font-weight: 600; font-weight: 600;
color: #fff; color: #fff;
letter-spacing: 1px;
margin-bottom: 12px; margin-bottom: 12px;
} }
@@ -193,26 +385,28 @@
.offlineSn { .offlineSn {
color: @accent-cyan; color: @accent-cyan;
font-family: 'Rajdhani', monospace; font-family: @font-mono;
} }
/* ========== 滚动条 ========== */ /* ========== 滚动条 ========== */
.leftPanel::-webkit-scrollbar, .leftPanel::-webkit-scrollbar {
.rightPanel::-webkit-scrollbar {
width: 3px; width: 3px;
} }
.leftPanel::-webkit-scrollbar-thumb, .leftPanel::-webkit-scrollbar-thumb {
.rightPanel::-webkit-scrollbar-thumb { background: rgba(34, 211, 238, 0.25);
background: rgba(0, 212, 255, 0.25);
border-radius: 2px; border-radius: 2px;
&:hover { &:hover {
background: rgba(0, 212, 255, 0.4); background: rgba(34, 211, 238, 0.4);
} }
} }
.leftPanel::-webkit-scrollbar-track, .leftPanel::-webkit-scrollbar-track {
.rightPanel::-webkit-scrollbar-track {
background: transparent; background: transparent;
} }
/* ========== 动画 ========== */
@keyframes statusPulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
+297 -116
View File
@@ -1,13 +1,24 @@
import React, { useEffect } from 'react'; import React, { useEffect, useCallback, useState, useRef, useMemo } from 'react';
import { ConfigProvider, Button, Spin } from 'antd'; import { ConfigProvider, Button, Spin } from 'antd';
import { LogoutOutlined, DisconnectOutlined, ReloadOutlined } from '@ant-design/icons'; import {
LogoutOutlined,
DisconnectOutlined,
ReloadOutlined,
WifiOutlined,
ThunderboltOutlined,
EnvironmentOutlined,
HistoryOutlined,
EyeOutlined,
LeftOutlined,
PauseOutlined,
CaretRightOutlined,
StopOutlined,
} from '@ant-design/icons';
import { darkTheme } from '@/theme'; import { darkTheme } from '@/theme';
import LeftPanel from './components/LeftPanel'; import LeftPanel from './components/LeftPanel';
import CenterView from './components/CenterView'; import CenterView from './components/CenterView';
import RightPanel from './components/RightPanel'; import ExecLeftPanel from './components/ExecLeftPanel';
import NavigationHUD from './components/NavigationHUD'; import ExecBottomStrip from './components/ExecBottomStrip';
import NavigationOverlay from './components/NavigationOverlay';
import EmergencyButton from './components/EmergencyButton';
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';
@@ -15,6 +26,24 @@ 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 = () => (
<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" />
<rect x="15" y="8" width="6" height="13" rx="1" fill="white" fillOpacity="0.9" />
<rect x="11" y="14" width="14" height="7" rx="1" fill="white" fillOpacity="0.7" />
<rect x="16.5" y="4" width="3" height="6" rx="1" fill="white" fillOpacity="0.8" />
</svg>
);
/** 格式化秒数为 HH:MM:SS */
const formatElapsed = (totalSec: number) => {
const h = Math.floor(totalSec / 3600).toString().padStart(2, '0');
const m = Math.floor((totalSec % 3600) / 60).toString().padStart(2, '0');
const s = (totalSec % 60).toString().padStart(2, '0');
return `${h}:${m}:${s}`;
};
const ClientPage: React.FC = () => { const ClientPage: React.FC = () => {
// ── 认证 ── // ── 认证 ──
const { boatData: sseBoatData, sseConnected, loading: sseLoading, deviceOffline, connectSSE, disconnectSSE } = useClientSSE(); const { boatData: sseBoatData, sseConnected, loading: sseLoading, deviceOffline, connectSSE, disconnectSSE } = useClientSSE();
@@ -45,16 +74,6 @@ const ClientPage: React.FC = () => {
handlePreviewChange, handlePreviewChange,
} = useNavigationState(deviceSn, selectedRouteId, setSelectedRouteId, routes); } = useNavigationState(deviceSn, selectedRouteId, setSelectedRouteId, routes);
// ── 导航计算 ──
const {
activeWaypoints,
activeRouteInfo,
nextWaypoint,
remainingDistance,
estimatedRemainingTime,
progress,
} = useNavigationData(activeRouteId, routes, routeWaypointsMap, boatData, currentWaypointIndex);
// ── SSE 连接 ── // ── SSE 连接 ──
useEffect(() => { useEffect(() => {
if (!deviceSn) return; if (!deviceSn) return;
@@ -62,123 +81,285 @@ const ClientPage: React.FC = () => {
return () => { disconnectSSE(); }; return () => { disconnectSSE(); };
}, [deviceSn]); }, [deviceSn]);
// ── 沉浸模式计时器 ──
const [elapsed, setElapsed] = useState(0);
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
const [previewStartSignal, setPreviewStartSignal] = useState(0);
useEffect(() => {
if (isImmersive && !isPaused) {
timerRef.current = setInterval(() => setElapsed((s) => s + 1), 1000);
} else if (timerRef.current) {
clearInterval(timerRef.current);
timerRef.current = null;
}
if (!isImmersive) setElapsed(0);
return () => { if (timerRef.current) clearInterval(timerRef.current); };
}, [isImmersive, isPaused]);
// ── 预览航线回调 ──
const handlePreviewRoute = useCallback((routeId: string) => {
if (routeId !== selectedRouteId) {
setSelectedRouteId(routeId);
}
// 延迟递增信号,让 selectedRouteId 先生效触发航点加载
setTimeout(() => setPreviewStartSignal((s) => s + 1), 200);
}, [selectedRouteId, setSelectedRouteId]);
// ── 预先计算航线基础信息(不依赖 boatData) ──
const activeWaypointsRaw = useMemo(() => {
if (!activeRouteId) return [];
return routeWaypointsMap[activeRouteId] || [];
}, [activeRouteId, routeWaypointsMap]);
const activeRouteInfoRaw = useMemo(() => {
if (!activeRouteId) return null;
return routes.find((r) => r.routeId === activeRouteId) || null;
}, [activeRouteId, routes]);
// ── 预览模式假数据 ──
const effectiveBoatData = useMemo(() => {
if (!isPreviewing) return boatData;
// 如果有真实 SSE 数据,优先使用
if (boatData?.longitude) return boatData;
// 预览模式下根据航线航点和经过时间生成模拟遥测数据
if (activeWaypointsRaw.length === 0) return null;
const previewSpeed = 2; // m/s,与预览动画速度一致
const totalDist = activeRouteInfoRaw?.totalDistance || 1000;
const traveled = elapsed * previewSpeed;
const fraction = Math.min(traveled / totalDist, 0.99);
const wpIdx = Math.min(
Math.floor(fraction * (activeWaypointsRaw.length - 1)),
activeWaypointsRaw.length - 2,
);
const wp = activeWaypointsRaw[wpIdx];
const nextWp = activeWaypointsRaw[wpIdx + 1] || wp;
// 航段内插值
const segFrac = (fraction * (activeWaypointsRaw.length - 1)) - wpIdx;
const lon = wp.longitude + (nextWp.longitude - wp.longitude) * segFrac;
const lat = wp.latitude + (nextWp.latitude - wp.latitude) * segFrac;
// 计算航向
const dLon = (nextWp.longitude - wp.longitude) * Math.PI / 180;
const lat1 = wp.latitude * Math.PI / 180;
const lat2 = nextWp.latitude * Math.PI / 180;
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 heading = ((Math.atan2(y, x) * 180 / Math.PI) + 360) % 360;
return {
deviceSn: deviceSn || '',
longitude: lon,
latitude: lat,
heading,
speed: previewSpeed,
battery: 85,
signalStrength: 92,
status: 'preview',
recordTime: new Date().toISOString(),
} as import('@/types/boatRoute').BoatTelemetryData;
}, [isPreviewing, boatData, activeWaypointsRaw, activeRouteInfoRaw, elapsed, deviceSn]);
// ── 导航计算(使用 effectiveBoatData 以便预览模式也有数据) ──
const {
activeWaypoints,
activeRouteInfo,
progress,
remainingDistance,
estimatedRemainingTime,
} = useNavigationData(activeRouteId, routes, routeWaypointsMap, effectiveBoatData, currentWaypointIndex);
if (!deviceInfo) return null; if (!deviceInfo) return null;
// ── 渲染 ── const modeLabel = isPreviewing ? '预览中' : '执行中';
const modeTag = isPreviewing ? 'PREVIEW' : 'RUNNING';
return ( return (
<ConfigProvider theme={darkTheme}> <ConfigProvider theme={darkTheme}>
<div className={`${styles.container} ${isImmersive ? styles.sailing : ''}`}> <div className={`${styles.container} ${isImmersive ? styles.sailing : ''}`}>
{/* 设备离线遮罩 */}
{deviceOffline && !sseConnected && ( {/* ========== 普通模式 - 顶部导航栏 ========== */}
<div className={styles.offlineOverlay}> {!isImmersive && (
<div className={styles.offlineCard}> <div className={styles.navBar}>
<DisconnectOutlined className={styles.offlineIcon} /> <div className={styles.navLogo}>
<div className={styles.offlineTitle}>设备不在线</div> <div className={styles.navLogoIcon}><ShipLogoIcon /></div>
<div className={styles.offlineDesc}> <span className={styles.navLogoText}>WAVE PILOT</span>
无法订阅设备 <span className={styles.offlineSn}>{deviceInfo.deviceName || deviceSn}</span> 的实时数据 </div>
<br />
{sseLoading ? '正在重新连接...' : '请检查设备是否已开机并接入网络'} <div className={styles.navSpacer} />
<div className={styles.navTabs}>
<div className={`${styles.navTab} ${styles.navTabActive}`}>
<EnvironmentOutlined />
<span>航线管理</span>
</div> </div>
{sseLoading ? ( <div className={styles.navTab}>
<Spin size="small" style={{ marginTop: 16 }} /> <EyeOutlined />
) : ( <span>实时监控</span>
<Button </div>
icon={<ReloadOutlined />} <div className={styles.navTab}>
onClick={() => connectSSE(deviceSn)} <HistoryOutlined />
style={{ marginTop: 16, borderColor: 'rgba(0,212,255,0.4)', color: '#00d4ff' }} <span>历史记录</span>
ghost </div>
> </div>
重试连接
</Button> <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"
/>
</div> </div>
</div> </div>
)} )}
{/* 左侧游览线路 */}
<div className={styles.leftPanel}>
<LeftPanel
routes={routes}
routeWaypointsMap={routeWaypointsMap}
loading={routeLoading}
selectedRouteId={selectedRouteId}
onSelectRoute={setSelectedRouteId}
/>
</div>
{/* 中间三维视图 */} {/* ========== 沉浸模式 - 执行导航栏 ========== */}
<div className={styles.centerView}> {isImmersive && (
<CenterView <div className={styles.execNav}>
deviceSn={deviceSn} <button
routes={routes} className={styles.execBackBtn}
selectedRouteId={selectedRouteId} onClick={isPreviewing ? handleStopPreview : handleStopSailing}
boatData={boatData} >
isSailing={isSailing} <LeftOutlined />
sailingLoading={sailingLoading} </button>
previewStopSignal={previewStopSignal}
onStartSailing={handleStartSailing}
onPreviewChange={handlePreviewChange}
/>
{/* 沉浸模式浮层(航行或预览) */} <div className={styles.execTitleArea}>
{isImmersive && ( <div className={styles.execTitle}>
<> {activeRouteInfo?.routeName || '航线'} · {modeLabel}
{!!activeRouteId && ( </div>
<NavigationOverlay <div className={styles.execSubtitle}>
mode={isPreviewing ? 'preview' : 'sailing'} {deviceInfo.deviceName || deviceSn} · 已{isPreviewing ? '预览' : '执行'} {formatElapsed(elapsed)}
routeName={activeRouteInfo?.routeName || ''} </div>
waypoints={activeWaypoints.map((wp) => ({ </div>
name: wp.pointName || `航点${wp.waypointIndex + 1}`,
waypointIndex: wp.waypointIndex, <div className={styles.execBadge}>
}))} <span className={styles.execBadgeDot} />
currentWaypointIndex={boatData?.currentWaypointIndex ?? currentWaypointIndex} <span>{modeLabel} {modeTag}</span>
totalDistance={activeRouteInfo?.totalDistance ?? 0} </div>
remainingDistance={remainingDistance}
estimatedRemainingTime={estimatedRemainingTime} <div className={styles.execSpacer} />
progress={progress}
/> <div className={styles.execRight}>
)}
{isSailing && ( {isSailing && (
<EmergencyButton onEmergencyStop={handleEmergencyStop} deviceSn={deviceSn} /> <button
className={styles.execPauseBtn}
onClick={isPaused ? handleResumeSailing : handlePauseSailing}
>
{isPaused ? <CaretRightOutlined /> : <PauseOutlined />}
<span>{isPaused ? '继续' : '暂停'}</span>
</button>
)} )}
<NavigationHUD <button
mode={isPreviewing ? 'preview' : 'sailing'} className={styles.execStopBtn}
routeName={activeRouteInfo?.routeName || ''} onClick={isPreviewing ? handleStopPreview : handleStopSailing}
speed={boatData?.speed ?? 0} >
heading={boatData?.heading ?? 0} <StopOutlined />
battery={boatData?.battery ?? 0} <span>终止</span>
signalStrength={boatData?.signalStrength} </button>
nextWaypoint={nextWaypoint} </div>
</div>
)}
{/* ========== 主体区域 ========== */}
<div className={styles.mainBody}>
{/* 设备离线遮罩 */}
{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>
{sseLoading ? (
<Spin size="small" style={{ marginTop: 16 }} />
) : (
<Button
icon={<ReloadOutlined />}
onClick={() => connectSSE(deviceSn)}
style={{ marginTop: 16, borderColor: 'rgba(34,211,238,0.4)', color: '#22d3ee' }}
ghost
>
重试连接
</Button>
)}
</div>
</div>
)}
{/* 左侧边栏 - 普通模式 */}
{!isImmersive && (
<div className={styles.leftPanel}>
<LeftPanel
routes={routes}
routeWaypointsMap={routeWaypointsMap}
loading={routeLoading}
selectedRouteId={selectedRouteId}
onSelectRoute={setSelectedRouteId}
deviceInfo={deviceInfo}
boatData={boatData}
sseConnected={sseConnected}
onStartSailing={handleStartSailing}
onPreviewRoute={handlePreviewRoute}
sailingLoading={sailingLoading}
/>
</div>
)}
{/* 左侧面板 - 沉浸模式 (仪表盘 + 航点列表) */}
{isImmersive && (
<ExecLeftPanel
boatData={effectiveBoatData}
waypoints={activeWaypoints}
currentWaypointIndex={currentWaypointIndex}
/>
)}
{/* 地图区域 */}
<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 && (
<ExecBottomStrip
progress={progress}
currentWaypointIndex={currentWaypointIndex}
totalWaypoints={activeWaypoints.length}
remainingDistance={remainingDistance} remainingDistance={remainingDistance}
estimatedRemainingTime={estimatedRemainingTime} estimatedRemainingTime={estimatedRemainingTime}
progress={progress}
isPaused={isPaused && isSailing}
onPause={handlePauseSailing}
onResume={handleResumeSailing}
onStop={isPreviewing ? handleStopPreview : handleStopSailing}
/> />
</> )}
)} </div>
</div>
{/* 右侧设备信息 */}
<div className={styles.rightPanel}>
<RightPanel deviceInfo={deviceInfo} boatData={boatData} sseConnected={sseConnected} />
</div>
{/* 底部状态栏 */}
<div className={styles.statusBar}>
<span className={styles.statusDot} style={{ background: sseConnected ? '#00ff88' : '#ff4d4f' }} />
<span>{sseConnected ? 'SSE 已连接' : 'SSE 未连接'}</span>
<span style={{ marginLeft: 16 }}>设备: {deviceInfo.deviceName || deviceSn}</span>
<Button
type="text"
icon={<LogoutOutlined />}
onClick={handleLogout}
style={{ marginLeft: 'auto', color: 'rgba(255,255,255,0.6)', fontSize: 12 }}
size="small"
>
退出
</Button>
</div> </div>
</div> </div>
</ConfigProvider> </ConfigProvider>
@@ -734,7 +734,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
const cesiumBaseUrl = process.env.CESIUM_BASE_URL || '/'; const cesiumBaseUrl = process.env.CESIUM_BASE_URL || '/';
Cesium.buildModuleUrl.setBaseUrl(`${cesiumBaseUrl}cesium/`); Cesium.buildModuleUrl.setBaseUrl(`${cesiumBaseUrl}cesium/`);
// 设置 Cesium Ion Access Token(用于加载 Cesium World Terrain) // 设置 Cesium Ion Access Token(用于加载 Cesium Ion 在线服务)
const cesiumToken = process.env.REACT_APP_CESIUM_TOKEN; const cesiumToken = process.env.REACT_APP_CESIUM_TOKEN;
if (cesiumToken) { if (cesiumToken) {
Cesium.Ion.defaultAccessToken = cesiumToken; Cesium.Ion.defaultAccessToken = cesiumToken;
@@ -466,12 +466,25 @@ export function useCesiumRouteLibraryRenderer(options: UseCesiumRouteLibraryRend
id: wpId, id: wpId,
position: pos, position: pos,
point: { point: {
pixelSize: item.highlighted ? 9 : 5, pixelSize: item.highlighted ? 12 : 6,
color: Cesium.Color.fromCssColorString(baseColorCss).withAlpha(item.highlighted ? 0.95 : 0.75), color: Cesium.Color.fromCssColorString(baseColorCss).withAlpha(item.highlighted ? 0.95 : 0.75),
outlineColor: Cesium.Color.WHITE.withAlpha(0.85), outlineColor: Cesium.Color.WHITE.withAlpha(0.85),
outlineWidth: 1, outlineWidth: 1,
disableDepthTestDistance: Number.POSITIVE_INFINITY, disableDepthTestDistance: Number.POSITIVE_INFINITY,
}, },
label: {
text: wp.pointName || `航点${i + 1}`,
font: '14px bold sans-serif',
fillColor: Cesium.Color.WHITE,
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineWidth: 3,
outlineColor: Cesium.Color.BLACK,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
pixelOffset: new Cesium.Cartesian2(0, -16),
disableDepthTestDistance: Number.POSITIVE_INFINITY,
scaleByDistance: new Cesium.NearFarScalar(20, 1.2, 800, 0.6),
show: item.highlighted !== false,
},
properties: { properties: {
type: 'route-library-waypoint', type: 'route-library-waypoint',
routeId, routeId,