feat: 物联网卡管理
This commit is contained in:
+128
@@ -0,0 +1,128 @@
|
|||||||
|
package com.central.device.controller;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.device.model.IotCard;
|
||||||
|
import com.central.device.service.IIotCardService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物联网卡管理
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
* @date 2026-03-27
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot-card")
|
||||||
|
@Tag(name = "物联网卡管理")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class IotCardController {
|
||||||
|
|
||||||
|
private final IIotCardService iotCardService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表
|
||||||
|
*/
|
||||||
|
@Operation(summary = "查询物联网卡列表")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "page", description = "页码", required = true, in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "limit", description = "每页条数", required = true, in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "cardNumber", description = "卡号", in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "deviceSn", description = "设备SN", in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "enabled", description = "启用状态", in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "carrier", description = "运营商", in = ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping
|
||||||
|
public PageResult<IotCard> list(@RequestParam Map<String, Object> params) {
|
||||||
|
return iotCardService.findList(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询
|
||||||
|
*/
|
||||||
|
@Operation(summary = "查询物联网卡详情")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result<IotCard> findById(@PathVariable Long id) {
|
||||||
|
IotCard model = iotCardService.getById(id);
|
||||||
|
return Result.succeed(model, "查询成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或更新
|
||||||
|
*/
|
||||||
|
@Operation(summary = "新增/更新物联网卡")
|
||||||
|
@PostMapping
|
||||||
|
public Result<String> save(@RequestBody IotCard iotCard) {
|
||||||
|
// 新增时校验卡号唯一
|
||||||
|
if (iotCard.getId() == null && iotCard.getCardNumber() != null) {
|
||||||
|
if (iotCardService.checkCardNumberExists(iotCard.getCardNumber())) {
|
||||||
|
return Result.failed("卡号已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iotCardService.saveOrUpdate(iotCard);
|
||||||
|
return Result.succeed("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@Operation(summary = "删除物联网卡")
|
||||||
|
@Parameter(name = "id", description = "物联网卡ID", in = ParameterIn.PATH, required = true)
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<String> delete(@PathVariable Long id) {
|
||||||
|
iotCardService.removeById(id);
|
||||||
|
return Result.succeed("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定设备
|
||||||
|
*/
|
||||||
|
@Operation(summary = "绑定设备")
|
||||||
|
@PostMapping("/{id}/bind")
|
||||||
|
public Result<String> bindDevice(@PathVariable Long id, @RequestParam String deviceSn) {
|
||||||
|
try {
|
||||||
|
boolean result = iotCardService.bindDevice(id, deviceSn);
|
||||||
|
return result ? Result.succeed("绑定成功") : Result.failed("绑定失败");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return Result.failed(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解绑设备
|
||||||
|
*/
|
||||||
|
@Operation(summary = "解绑设备")
|
||||||
|
@PostMapping("/{id}/unbind")
|
||||||
|
public Result<String> unbindDevice(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
boolean result = iotCardService.unbindDevice(id);
|
||||||
|
return result ? Result.succeed("解绑成功") : Result.failed("解绑失败");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return Result.failed(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用/停用
|
||||||
|
*/
|
||||||
|
@Operation(summary = "启用/停用物联网卡")
|
||||||
|
@PutMapping("/{id}/toggle")
|
||||||
|
public Result<String> toggleEnabled(@PathVariable Long id, @RequestParam Integer enabled) {
|
||||||
|
try {
|
||||||
|
boolean result = iotCardService.toggleEnabled(id, enabled);
|
||||||
|
return result ? Result.succeed("操作成功") : Result.failed("操作失败");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return Result.failed(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -185,6 +185,12 @@ public class BoatRoute implements Serializable {
|
|||||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航线JSON文件URL(S3)
|
||||||
|
*/
|
||||||
|
@TableField("route_file_url")
|
||||||
|
private String routeFileUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标记
|
* 删除标记
|
||||||
*/
|
*/
|
||||||
|
|||||||
+9
@@ -73,6 +73,15 @@ public interface FileCenterService {
|
|||||||
@RequestParam(value = "batchSize", defaultValue = "100") int batchSize,
|
@RequestParam(value = "batchSize", defaultValue = "100") int batchSize,
|
||||||
@RequestParam(value = "area", required = false) String area);
|
@RequestParam(value = "area", required = false) String area);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件到S3存储
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
|
* @return 文件信息(含CDN URL)
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/files-S3", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
FileInfo uploadForS3(@RequestPart("file") MultipartFile file);
|
||||||
|
|
||||||
// ========== 3D模型文件上传相关接口 ==========
|
// ========== 3D模型文件上传相关接口 ==========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+6
@@ -74,6 +74,12 @@ public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCen
|
|||||||
return Result.failed("CDN批量预热文件失败: " + cause.getMessage());
|
return Result.failed("CDN批量预热文件失败: " + cause.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileInfo uploadForS3(MultipartFile file) {
|
||||||
|
log.error("上传文件到S3失败: fileName={}", file != null ? file.getOriginalFilename() : "null", cause);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// ========== 3D模型文件上传相关接口 ==========
|
// ========== 3D模型文件上传相关接口 ==========
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.central.device.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.db.mapper.SuperMapper;
|
||||||
|
import com.central.device.model.IotCard;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物联网卡数据访问层
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
* @date 2026-03-27
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface IotCardMapper extends SuperMapper<IotCard> {
|
||||||
|
/**
|
||||||
|
* 分页查询物联网卡列表
|
||||||
|
*
|
||||||
|
* @param page 分页参数
|
||||||
|
* @param params 查询条件
|
||||||
|
* @return 物联网卡列表
|
||||||
|
*/
|
||||||
|
List<IotCard> findList(Page<IotCard> page, @Param("p") Map<String, Object> params);
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.central.device.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.central.common.model.SuperEntity;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物联网卡实体
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
* @date 2026-03-27
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("iot_card")
|
||||||
|
public class IotCard extends SuperEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡号(ICCID)
|
||||||
|
*/
|
||||||
|
private String cardNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MSISDN号码(手机号)
|
||||||
|
*/
|
||||||
|
private String msisdn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IMSI号码
|
||||||
|
*/
|
||||||
|
private String imsi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营商:1-中国移动,2-中国联通,3-中国电信
|
||||||
|
*/
|
||||||
|
private Integer carrier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐类型/流量套餐描述
|
||||||
|
*/
|
||||||
|
private String packageType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用状态:0-停用,1-启用
|
||||||
|
*/
|
||||||
|
private Integer enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定设备SN
|
||||||
|
*/
|
||||||
|
private String deviceSn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定设备名称(冗余字段,方便展示)
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 激活时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date activationTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 到期时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date expirationTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属租户ID
|
||||||
|
*/
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑删除:0-未删除,1-已删除
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDel;
|
||||||
|
}
|
||||||
+3
@@ -83,6 +83,9 @@ public class BoatRouteDetailVO {
|
|||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "航线JSON文件URL")
|
||||||
|
private String routeFileUrl;
|
||||||
|
|
||||||
@Schema(description = "航点列表")
|
@Schema(description = "航点列表")
|
||||||
private List<BoatWaypointVO> waypoints;
|
private List<BoatWaypointVO> waypoints;
|
||||||
|
|
||||||
|
|||||||
+3
@@ -55,6 +55,9 @@ public class BoatRouteListVO {
|
|||||||
@Schema(description = "规划水域边界ID")
|
@Schema(description = "规划水域边界ID")
|
||||||
private String boundaryId;
|
private String boundaryId;
|
||||||
|
|
||||||
|
@Schema(description = "航线JSON文件URL")
|
||||||
|
private String routeFileUrl;
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
package com.central.device.service;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.ISuperService;
|
||||||
|
import com.central.device.model.IotCard;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物联网卡服务接口
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
* @date 2026-03-27
|
||||||
|
*/
|
||||||
|
public interface IIotCardService extends ISuperService<IotCard> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询物联网卡列表
|
||||||
|
*
|
||||||
|
* @param params 查询条件(page、limit、cardNumber、deviceSn、enabled 等)
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
PageResult<IotCard> findList(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据卡号查询物联网卡
|
||||||
|
*
|
||||||
|
* @param cardNumber 卡号
|
||||||
|
* @return 物联网卡
|
||||||
|
*/
|
||||||
|
IotCard getByCardNumber(String cardNumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查卡号是否已存在
|
||||||
|
*
|
||||||
|
* @param cardNumber 卡号
|
||||||
|
* @return 是否存在
|
||||||
|
*/
|
||||||
|
boolean checkCardNumberExists(String cardNumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定设备
|
||||||
|
*
|
||||||
|
* @param id 物联网卡ID
|
||||||
|
* @param deviceSn 设备SN
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean bindDevice(Long id, String deviceSn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解绑设备
|
||||||
|
*
|
||||||
|
* @param id 物联网卡ID
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean unbindDevice(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用/停用物联网卡
|
||||||
|
*
|
||||||
|
* @param id 物联网卡ID
|
||||||
|
* @param enabled 启用状态:0-停用,1-启用
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean toggleEnabled(Long id, Integer enabled);
|
||||||
|
}
|
||||||
+99
@@ -9,6 +9,7 @@ import com.central.common.context.LoginUserContextHolder;
|
|||||||
import com.central.common.exception.BusinessException;
|
import com.central.common.exception.BusinessException;
|
||||||
import com.central.device.entity.BoatRoute;
|
import com.central.device.entity.BoatRoute;
|
||||||
import com.central.device.entity.BoatWaypoint;
|
import com.central.device.entity.BoatWaypoint;
|
||||||
|
import com.central.device.feign.FileCenterService;
|
||||||
import com.central.device.mapper.BoatRouteMapper;
|
import com.central.device.mapper.BoatRouteMapper;
|
||||||
import com.central.device.mapper.BoatWaypointMapper;
|
import com.central.device.mapper.BoatWaypointMapper;
|
||||||
import com.central.device.model.dto.BoatRouteCreateDTO;
|
import com.central.device.model.dto.BoatRouteCreateDTO;
|
||||||
@@ -18,11 +19,20 @@ import com.central.device.model.dto.PointDTO;
|
|||||||
import com.central.device.model.vo.*;
|
import com.central.device.model.vo.*;
|
||||||
import com.central.device.service.IBoatRouteService;
|
import com.central.device.service.IBoatRouteService;
|
||||||
import com.central.device.service.IWaterBoundaryService;
|
import com.central.device.service.IWaterBoundaryService;
|
||||||
|
import com.central.common.model.FileInfo;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -44,6 +54,7 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
|||||||
|
|
||||||
private final BoatWaypointMapper waypointMapper;
|
private final BoatWaypointMapper waypointMapper;
|
||||||
private final IWaterBoundaryService waterBoundaryService;
|
private final IWaterBoundaryService waterBoundaryService;
|
||||||
|
private final FileCenterService fileCenterService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -207,6 +218,10 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.updateById(route);
|
this.updateById(route);
|
||||||
|
// 已发布航线更新后重新生成并上传JSON文件
|
||||||
|
if (BoatRoute.RouteStatus.PUBLISHED.getCode().equals(route.getStatus())) {
|
||||||
|
generateAndUploadRouteJson(routeId);
|
||||||
|
}
|
||||||
log.info("航线更新成功: routeId={}", routeId);
|
log.info("航线更新成功: routeId={}", routeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,6 +487,8 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
|||||||
throw new BusinessException("只有草稿状态的航线才能发布");
|
throw new BusinessException("只有草稿状态的航线才能发布");
|
||||||
}
|
}
|
||||||
updateStatus(routeId, BoatRoute.RouteStatus.PUBLISHED.getCode());
|
updateStatus(routeId, BoatRoute.RouteStatus.PUBLISHED.getCode());
|
||||||
|
// 发布时生成航线JSON文件并上传到S3
|
||||||
|
generateAndUploadRouteJson(routeId);
|
||||||
log.info("航线发布成功: routeId={}", routeId);
|
log.info("航线发布成功: routeId={}", routeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,4 +578,86 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成航线JSON文件并上传到S3,将返回的URL存入航线表
|
||||||
|
*/
|
||||||
|
private void generateAndUploadRouteJson(String routeId) {
|
||||||
|
try {
|
||||||
|
// 1. 获取航线详情(含航点)
|
||||||
|
BoatRouteDetailVO detail = getRouteDetail(routeId);
|
||||||
|
|
||||||
|
// 2. 序列化为JSON
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
byte[] jsonBytes = objectMapper.writerWithDefaultPrettyPrinter()
|
||||||
|
.writeValueAsBytes(detail);
|
||||||
|
|
||||||
|
// 3. 构造MultipartFile
|
||||||
|
String fileName = "route_" + routeId + ".json";
|
||||||
|
MultipartFile multipartFile = new InMemoryMultipartFile(
|
||||||
|
"file", fileName, "application/json", jsonBytes);
|
||||||
|
// 4. 通过Feign上传到S3
|
||||||
|
FileInfo fileInfo = fileCenterService.uploadForS3(multipartFile);
|
||||||
|
if (fileInfo == null || fileInfo.getUrl() == null) {
|
||||||
|
log.warn("航线JSON上传S3返回为空: routeId={}", routeId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 将URL存入航线表
|
||||||
|
BoatRoute route = getByRouteId(routeId);
|
||||||
|
if (route != null) {
|
||||||
|
route.setRouteFileUrl(fileInfo.getUrl());
|
||||||
|
this.updateById(route);
|
||||||
|
log.info("航线JSON文件上传成功: routeId={}, url={}", routeId, fileInfo.getUrl());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 上传失败不影响主流程,仅记录日志
|
||||||
|
log.error("航线JSON文件生成或上传失败: routeId={}", routeId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内存MultipartFile实现,用于将字节数组包装为MultipartFile通过Feign上传
|
||||||
|
*/
|
||||||
|
private static class InMemoryMultipartFile implements MultipartFile {
|
||||||
|
private final String name;
|
||||||
|
private final String originalFilename;
|
||||||
|
private final String contentType;
|
||||||
|
private final byte[] content;
|
||||||
|
|
||||||
|
InMemoryMultipartFile(String name, String originalFilename, String contentType, byte[] content) {
|
||||||
|
this.name = name;
|
||||||
|
this.originalFilename = originalFilename;
|
||||||
|
this.contentType = contentType;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return name; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOriginalFilename() { return originalFilename; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() { return contentType; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() { return content.length == 0; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() { return content.length; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getBytes() { return content; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getInputStream() { return new ByteArrayInputStream(content); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||||
|
java.nio.file.Files.write(dest.toPath(), content);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+121
@@ -0,0 +1,121 @@
|
|||||||
|
package com.central.device.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.common.feign.UserService;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
|
import com.central.device.mapper.IotCardMapper;
|
||||||
|
import com.central.device.model.AgeDevice;
|
||||||
|
import com.central.device.model.IotCard;
|
||||||
|
import com.central.device.service.IAgeDeviceService;
|
||||||
|
import com.central.device.service.IIotCardService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物联网卡服务实现
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
* @date 2026-03-27
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class IotCardServiceImpl extends SuperServiceImpl<IotCardMapper, IotCard> implements IIotCardService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userCenterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAgeDeviceService ageDeviceService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<IotCard> findList(Map<String, Object> params) {
|
||||||
|
Page<IotCard> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
|
String anchor = MapUtils.getString(params, "tenantId");
|
||||||
|
try {
|
||||||
|
if (anchor == null || anchor.isEmpty()) {
|
||||||
|
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||||
|
if (anchor == null || anchor.isEmpty()) {
|
||||||
|
anchor = com.central.common.context.LoginUserContextHolder.getCurrentTenantId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
log.error("获取当前登录用户租户失败");
|
||||||
|
}
|
||||||
|
List<String> tenantIds = userCenterService.getSonTenantIds(anchor);
|
||||||
|
params.put("tenantIds", tenantIds);
|
||||||
|
List<IotCard> list = baseMapper.findList(page, params);
|
||||||
|
return PageResult.<IotCard>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IotCard getByCardNumber(String cardNumber) {
|
||||||
|
return this.getOne(new QueryWrapper<IotCard>().eq("card_number", cardNumber).eq("is_del", 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkCardNumberExists(String cardNumber) {
|
||||||
|
return this.baseMapper.exists(new QueryWrapper<IotCard>().eq("card_number", cardNumber).eq("is_del", 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean bindDevice(Long id, String deviceSn) {
|
||||||
|
IotCard card = this.getById(id);
|
||||||
|
if (card == null) {
|
||||||
|
throw new IllegalArgumentException("物联网卡不存在");
|
||||||
|
}
|
||||||
|
// 查询设备信息,回填设备名称
|
||||||
|
AgeDevice device = ageDeviceService.getByDeviceSn(deviceSn);
|
||||||
|
card.setDeviceSn(deviceSn);
|
||||||
|
card.setDeviceName(device != null ? device.getDeviceName() : null);
|
||||||
|
boolean result = this.updateById(card);
|
||||||
|
if (result) {
|
||||||
|
log.info("物联网卡绑定设备成功: cardNumber={}, deviceSn={}", card.getCardNumber(), deviceSn);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean unbindDevice(Long id) {
|
||||||
|
IotCard card = this.getById(id);
|
||||||
|
if (card == null) {
|
||||||
|
throw new IllegalArgumentException("物联网卡不存在");
|
||||||
|
}
|
||||||
|
String oldDeviceSn = card.getDeviceSn();
|
||||||
|
// 使用 UpdateWrapper 显式将字段置为 null,避免 MyBatis-Plus 默认策略跳过 null 值
|
||||||
|
boolean result = this.update(
|
||||||
|
new com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper<IotCard>()
|
||||||
|
.set("device_sn", null)
|
||||||
|
.set("device_name", null)
|
||||||
|
.eq("id", id)
|
||||||
|
);
|
||||||
|
if (result) {
|
||||||
|
log.info("物联网卡解绑设备成功: cardNumber={}, oldDeviceSn={}", card.getCardNumber(), oldDeviceSn);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean toggleEnabled(Long id, Integer enabled) {
|
||||||
|
IotCard card = this.getById(id);
|
||||||
|
if (card == null) {
|
||||||
|
throw new IllegalArgumentException("物联网卡不存在");
|
||||||
|
}
|
||||||
|
card.setEnabled(enabled);
|
||||||
|
boolean result = this.updateById(card);
|
||||||
|
if (result) {
|
||||||
|
log.info("物联网卡状态变更: cardNumber={}, enabled={}", card.getCardNumber(), enabled);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.central.device.mapper.IotCardMapper">
|
||||||
|
<select id="findList" resultType="com.central.device.model.IotCard">
|
||||||
|
select * from iot_card t where t.is_del = 0
|
||||||
|
<if test="p.cardNumber != null and p.cardNumber != ''">
|
||||||
|
and t.card_number like concat('%', #{p.cardNumber}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="p.msisdn != null and p.msisdn != ''">
|
||||||
|
and t.msisdn like concat('%', #{p.msisdn}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="p.deviceSn != null and p.deviceSn != ''">
|
||||||
|
and t.device_sn = #{p.deviceSn}
|
||||||
|
</if>
|
||||||
|
<if test="p.enabled != null and p.enabled != ''">
|
||||||
|
and t.enabled = #{p.enabled}
|
||||||
|
</if>
|
||||||
|
<if test="p.carrier != null and p.carrier != ''">
|
||||||
|
and t.carrier = #{p.carrier}
|
||||||
|
</if>
|
||||||
|
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||||
|
AND t.tenant_id IN
|
||||||
|
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||||
|
#{tid}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
order by t.id desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
-- 物联网卡管理表
|
||||||
|
-- 使用前请确认目标数据库
|
||||||
|
CREATE TABLE IF NOT EXISTS `iot_card` (
|
||||||
|
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
|
`card_number` VARCHAR(32) NOT NULL COMMENT '卡号(ICCID)',
|
||||||
|
`msisdn` VARCHAR(20) DEFAULT NULL COMMENT 'MSISDN号码(手机号)',
|
||||||
|
`imsi` VARCHAR(20) DEFAULT NULL COMMENT 'IMSI号码',
|
||||||
|
`carrier` TINYINT DEFAULT NULL COMMENT '运营商:1-中国移动,2-中国联通,3-中国电信',
|
||||||
|
`package_type` VARCHAR(100) DEFAULT NULL COMMENT '套餐类型/流量套餐描述',
|
||||||
|
`enabled` TINYINT NOT NULL DEFAULT 1 COMMENT '启用状态:0-停用,1-启用',
|
||||||
|
`device_sn` VARCHAR(64) DEFAULT NULL COMMENT '绑定设备SN',
|
||||||
|
`device_name` VARCHAR(128) DEFAULT NULL COMMENT '绑定设备名称',
|
||||||
|
`activation_time` DATETIME DEFAULT NULL COMMENT '激活时间',
|
||||||
|
`expiration_time` DATETIME DEFAULT NULL COMMENT '到期时间',
|
||||||
|
`tenant_id` VARCHAR(32) DEFAULT NULL COMMENT '所属租户ID',
|
||||||
|
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||||
|
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`is_del` TINYINT NOT NULL DEFAULT 0 COMMENT '逻辑删除:0-未删除,1-已删除',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_card_number` (`card_number`),
|
||||||
|
KEY `idx_device_sn` (`device_sn`),
|
||||||
|
KEY `idx_tenant_id` (`tenant_id`),
|
||||||
|
KEY `idx_enabled` (`enabled`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='物联网卡管理表';
|
||||||
@@ -16,7 +16,8 @@ ALTER TABLE `3d_model_file`
|
|||||||
ADD COLUMN `device_name` VARCHAR(100) DEFAULT NULL COMMENT '关联设备名称'
|
ADD COLUMN `device_name` VARCHAR(100) DEFAULT NULL COMMENT '关联设备名称'
|
||||||
AFTER `device_sn`;
|
AFTER `device_sn`;
|
||||||
|
|
||||||
ALTER TABLE `3d_model_file`
|
ALTER TABLE `3d_model_file` ADD INDEX `idx_device_sn` (`device_sn`);
|
||||||
ADD INDEX `idx_device_sn` (`device_sn`);
|
|
||||||
|
ALTER TABLE boat_route ADD COLUMN route_file_url VARCHAR(512) DEFAULT NULL COMMENT '航线JSON文件URL(S3)' AFTER remark;
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -61,4 +61,10 @@ public class OrderFavorite extends SuperEntity {
|
|||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Date orderCreateTime;
|
private Date orderCreateTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Long orderUserId;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String phone;
|
||||||
}
|
}
|
||||||
|
|||||||
+31
@@ -1,24 +1,33 @@
|
|||||||
package com.central.order.service.impl;
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.central.common.context.LoginUserContextHolder;
|
import com.central.common.context.LoginUserContextHolder;
|
||||||
|
import com.central.common.feign.UserService;
|
||||||
import com.central.common.model.LoginAppUser;
|
import com.central.common.model.LoginAppUser;
|
||||||
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.common.model.SysUser;
|
||||||
import com.central.common.service.impl.SuperServiceImpl;
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
import com.central.order.mapper.OrderFavoriteMapper;
|
import com.central.order.mapper.OrderFavoriteMapper;
|
||||||
import com.central.order.model.Order;
|
import com.central.order.model.Order;
|
||||||
import com.central.order.model.OrderFavorite;
|
import com.central.order.model.OrderFavorite;
|
||||||
import com.central.order.service.IOrderFavoriteService;
|
import com.central.order.service.IOrderFavoriteService;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
|
import com.central.order.util.StringUtils;
|
||||||
|
import com.central.wechat.entity.WechatConfig;
|
||||||
|
import com.central.wechat.feign.WechatConfigService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单收藏
|
* 订单收藏
|
||||||
@@ -33,12 +42,34 @@ public class OrderFavoriteServiceImpl extends SuperServiceImpl<OrderFavoriteMapp
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IOrderService orderService;
|
private IOrderService orderService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserService userCenterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WechatConfigService wechatConfigService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OrderFavorite> findList(Map<String, Object> params) {
|
public PageResult<OrderFavorite> findList(Map<String, Object> params) {
|
||||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||||
Page<OrderFavorite> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
Page<OrderFavorite> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
params.put("userId", user.getId());
|
params.put("userId", user.getId());
|
||||||
List<OrderFavorite> list = baseMapper.findList(page, params);
|
List<OrderFavorite> list = baseMapper.findList(page, params);
|
||||||
|
for(OrderFavorite orderFavorite:list){
|
||||||
|
if(Objects.nonNull(orderFavorite.getOrderUserId())){
|
||||||
|
//获取手机号
|
||||||
|
SysUser orderUser = userCenterService.findUserById(orderFavorite.getOrderUserId());
|
||||||
|
if(Objects.nonNull(orderUser)){
|
||||||
|
orderFavorite.setPhone(orderUser.getMobile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//获取资金去向
|
||||||
|
if(StringUtil.isNotBlank(orderFavorite.getTenantId())){
|
||||||
|
WechatConfig wechatConfig = wechatConfigService.getConfig("PAY",orderFavorite.getTenantId());
|
||||||
|
if(wechatConfig!=null){
|
||||||
|
orderFavorite.setCompany(wechatConfig.getSubMchName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return PageResult.<OrderFavorite>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
return PageResult.<OrderFavorite>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
<mapper namespace="com.central.order.mapper.OrderFavoriteMapper">
|
<mapper namespace="com.central.order.mapper.OrderFavoriteMapper">
|
||||||
|
|
||||||
<select id="findList" resultType="com.central.order.model.OrderFavorite">
|
<select id="findList" resultType="com.central.order.model.OrderFavorite">
|
||||||
select t.id, t.user_id, t.order_id, t.order_no, t.create_time, t.tenant_id, t.company,
|
select t.id, t.user_id, t.order_id, t.order_no, t.create_time, qr.tenant_id as tenant_id, t.company,
|
||||||
o.device_sn, o.tourism_id, o.order_amount, o.order_status, o.pay_type, o.pay_time,
|
o.device_sn, o.tourism_id, o.order_amount, o.order_status, o.pay_type, o.pay_time,
|
||||||
o.create_time as order_create_time,
|
o.create_time as order_create_time, o.user_id as order_user_id,
|
||||||
tr.tourism_name as tourism_name
|
tr.tourism_name as tourism_name
|
||||||
from order_favorite t
|
from order_favorite t
|
||||||
left join orders o on t.order_id = o.id
|
left join orders o on t.order_id = o.id
|
||||||
left join tourisms tr on o.tourism_id = tr.id
|
left join tourisms tr on o.tourism_id = tr.id
|
||||||
|
left join qrcodes qr on o.code_id= qr.code_id
|
||||||
<where>
|
<where>
|
||||||
<if test="p.userId != null">
|
<if test="p.userId != null">
|
||||||
and t.user_id = #{p.userId}
|
and t.user_id = #{p.userId}
|
||||||
|
|||||||
-2
@@ -22,8 +22,6 @@ public class BannerInitializer implements ApplicationContextInitializer<Configur
|
|||||||
if (!(applicationContext instanceof AnnotationConfigApplicationContext)) {
|
if (!(applicationContext instanceof AnnotationConfigApplicationContext)) {
|
||||||
LogoBanner logoBanner = new LogoBanner(BannerInitializer.class, "/zltmp/logo.txt", "Welcome to zlt", 5, 6, new Color[5], true);
|
LogoBanner logoBanner = new LogoBanner(BannerInitializer.class, "/zltmp/logo.txt", "Welcome to zlt", 5, 6, new Color[5], true);
|
||||||
CustomBanner.show(logoBanner, new Description(BannerConstant.VERSION + ":", CommonConstant.PROJECT_VERSION, 0, 1)
|
CustomBanner.show(logoBanner, new Description(BannerConstant.VERSION + ":", CommonConstant.PROJECT_VERSION, 0, 1)
|
||||||
, new Description("Github:", "https://github.com/zlt2000", 0, 1)
|
|
||||||
, new Description("Blog:", "http://zlt2000.gitee.io", 0, 1)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ export default [
|
|||||||
{ path: '/device/device.html', component: '@/pages/device/Device' },
|
{ path: '/device/device.html', component: '@/pages/device/Device' },
|
||||||
// 3D模型管理
|
// 3D模型管理
|
||||||
{ path: '/device/3dModel.html', name: '3D模型管理', component: '@/pages/device/ThreeDModel' },
|
{ path: '/device/3dModel.html', name: '3D模型管理', component: '@/pages/device/ThreeDModel' },
|
||||||
|
// 物联网卡管理
|
||||||
|
{ path: '/device/iotCard.html', component: '@/pages/device/IotCard' },
|
||||||
// 景区地图仪表盘
|
// 景区地图仪表盘
|
||||||
{ path: '/device/mapDashboard.html', name: '地图仪表盘', component: '@/pages/device/mapDashboard', exact: true },
|
{ path: '/device/mapDashboard.html', name: '地图仪表盘', component: '@/pages/device/mapDashboard', exact: true },
|
||||||
{ path: '/device/mapDashboard/tourismDeviceDetail/:tourismId', component: '@/pages/device/mapDashboard/TourismDeviceDetail' },
|
{ path: '/device/mapDashboard/tourismDeviceDetail/:tourismId', component: '@/pages/device/mapDashboard/TourismDeviceDetail' },
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,114 @@
|
|||||||
|
import React, { useEffect, useRef } from 'react';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormText,
|
||||||
|
ProFormSelect,
|
||||||
|
ProFormDateTimePicker,
|
||||||
|
ProFormTextArea,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import TenantSelector from '@/components/ui/TenantSelector';
|
||||||
|
import { CARRIER_OPTIONS, ENABLED_OPTIONS } from '@/services/iotCard';
|
||||||
|
|
||||||
|
export type IotCardFormValues = {
|
||||||
|
id?: number;
|
||||||
|
cardNumber?: string;
|
||||||
|
msisdn?: string;
|
||||||
|
imsi?: string;
|
||||||
|
carrier?: number;
|
||||||
|
packageType?: string;
|
||||||
|
enabled?: number;
|
||||||
|
deviceSn?: string;
|
||||||
|
activationTime?: string;
|
||||||
|
expirationTime?: string;
|
||||||
|
tenantId?: string;
|
||||||
|
remark?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface IotCardFormProps {
|
||||||
|
title: string;
|
||||||
|
visible: boolean;
|
||||||
|
onVisibleChange: (v: boolean) => void;
|
||||||
|
onFinish: (values: IotCardFormValues) => Promise<boolean>;
|
||||||
|
initialValues?: Partial<IotCardFormValues>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const IotCardForm: React.FC<IotCardFormProps> = ({
|
||||||
|
title,
|
||||||
|
visible,
|
||||||
|
onVisibleChange,
|
||||||
|
onFinish,
|
||||||
|
initialValues,
|
||||||
|
}) => {
|
||||||
|
const formRef = useRef<any>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (visible && initialValues) {
|
||||||
|
setTimeout(() => {
|
||||||
|
formRef.current?.setFieldsValue(initialValues);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}, [visible, initialValues]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalForm<IotCardFormValues>
|
||||||
|
title={title}
|
||||||
|
visible={visible}
|
||||||
|
formRef={formRef}
|
||||||
|
onVisibleChange={onVisibleChange}
|
||||||
|
onFinish={onFinish}
|
||||||
|
modalProps={{ destroyOnClose: true }}
|
||||||
|
initialValues={initialValues}
|
||||||
|
>
|
||||||
|
{/* 所属租户 */}
|
||||||
|
<TenantSelector
|
||||||
|
nameTenant="tenantId"
|
||||||
|
labelTenant="所属租户"
|
||||||
|
hideIncludeChildren
|
||||||
|
rulesTenant={[{ required: true, message: '请选择租户' }]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
name="cardNumber"
|
||||||
|
label="卡号(ICCID)"
|
||||||
|
rules={[{ required: true, message: '请输入卡号' }]}
|
||||||
|
width="md"
|
||||||
|
placeholder="请输入物联网卡ICCID号"
|
||||||
|
disabled={!!initialValues?.id}
|
||||||
|
/>
|
||||||
|
<ProFormText name="msisdn" label="MSISDN号码" width="md" placeholder="手机号" />
|
||||||
|
<ProFormText name="imsi" label="IMSI号码" width="md" placeholder="IMSI" />
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
name="carrier"
|
||||||
|
label="运营商"
|
||||||
|
options={CARRIER_OPTIONS}
|
||||||
|
width="md"
|
||||||
|
placeholder="请选择运营商"
|
||||||
|
/>
|
||||||
|
<ProFormText name="packageType" label="套餐类型" width="md" placeholder="如:月包30M" />
|
||||||
|
<ProFormSelect
|
||||||
|
name="enabled"
|
||||||
|
label="启用状态"
|
||||||
|
options={ENABLED_OPTIONS}
|
||||||
|
width="md"
|
||||||
|
initialValue={1}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormDateTimePicker name="activationTime" label="激活时间" width="md" />
|
||||||
|
<ProFormDateTimePicker name="expirationTime" label="到期时间" width="md" />
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormTextArea name="remark" label="备注" width="lg" />
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default IotCardForm;
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
import React, { forwardRef, useImperativeHandle, useRef, useEffect } from 'react';
|
||||||
|
import { ProTable } from '@ant-design/pro-components';
|
||||||
|
import type { ProColumns, ActionType } from '@ant-design/pro-components';
|
||||||
|
import { Space, Tag, Tooltip, Popconfirm } from 'antd';
|
||||||
|
import { EditOutlined, DeleteOutlined, LinkOutlined, DisconnectOutlined } from '@ant-design/icons';
|
||||||
|
import { iotCardApi, CARRIER_MAP } from '@/services/iotCard';
|
||||||
|
|
||||||
|
export interface IotCardTableRef {
|
||||||
|
reload: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IotCardTableProps {
|
||||||
|
params?: Record<string, any>;
|
||||||
|
onEdit?: (record: any) => void;
|
||||||
|
onDelete?: (record: any) => void;
|
||||||
|
onBind?: (record: any) => void;
|
||||||
|
onUnbind?: (record: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const IotCardTable = forwardRef<IotCardTableRef, IotCardTableProps>(
|
||||||
|
({ params, onEdit, onDelete, onBind, onUnbind }, ref) => {
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
|
useImperativeHandle(ref, () => ({ reload: () => actionRef.current?.reload() }));
|
||||||
|
|
||||||
|
// 当查询参数变化时,自动重置到第一页
|
||||||
|
useEffect(() => {
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.setPageInfo?.({ current: 1 });
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}, [JSON.stringify(params)]);
|
||||||
|
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{ dataIndex: 'index', valueType: 'indexBorder', width: 48, fixed: 'left' },
|
||||||
|
{ title: '卡号(ICCID)', dataIndex: 'cardNumber', copyable: true, fixed: 'left', width: 200 },
|
||||||
|
{ title: 'MSISDN', dataIndex: 'msisdn', width: 140 },
|
||||||
|
{ title: 'IMSI', dataIndex: 'imsi', width: 160 },
|
||||||
|
{
|
||||||
|
title: '运营商',
|
||||||
|
dataIndex: 'carrier',
|
||||||
|
width: 100,
|
||||||
|
render: (_, record) => {
|
||||||
|
const name = CARRIER_MAP[record.carrier];
|
||||||
|
return name || '-';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ title: '套餐类型', dataIndex: 'packageType', width: 120, ellipsis: true },
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'enabled',
|
||||||
|
width: 80,
|
||||||
|
render: (_, record) => (
|
||||||
|
<Tag color={record.enabled === 1 ? 'green' : 'default'}>
|
||||||
|
{record.enabled === 1 ? '启用' : '停用'}
|
||||||
|
</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '绑定设备',
|
||||||
|
dataIndex: 'deviceSn',
|
||||||
|
width: 180,
|
||||||
|
render: (_, record) =>
|
||||||
|
record.deviceSn ? (
|
||||||
|
<Tooltip title={record.deviceName || record.deviceSn}>
|
||||||
|
<Tag color="blue">{record.deviceSn}</Tag>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
<Tag>未绑定</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{ title: '所属租户', dataIndex: 'tenantId', width: 120 },
|
||||||
|
{ title: '激活时间', dataIndex: 'activationTime', valueType: 'dateTime', width: 170 },
|
||||||
|
{ title: '到期时间', dataIndex: 'expirationTime', valueType: 'dateTime', width: 170 },
|
||||||
|
{ title: '备注', dataIndex: 'remark', ellipsis: true, width: 150 },
|
||||||
|
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 170 },
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
valueType: 'option',
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Space>
|
||||||
|
{record.deviceSn ? (
|
||||||
|
<Tooltip title="解绑设备">
|
||||||
|
<a style={{ color: '#faad14' }} onClick={() => onUnbind?.(record)}>
|
||||||
|
<DisconnectOutlined />
|
||||||
|
</a>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
<Tooltip title="绑定设备">
|
||||||
|
<a style={{ color: '#1890ff' }} onClick={() => onBind?.(record)}>
|
||||||
|
<LinkOutlined />
|
||||||
|
</a>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
<Tooltip title="编辑">
|
||||||
|
<a onClick={() => onEdit?.(record)}>
|
||||||
|
<EditOutlined />
|
||||||
|
</a>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="删除">
|
||||||
|
<a style={{ color: '#ff4d4f' }} onClick={() => onDelete?.(record)}>
|
||||||
|
<DeleteOutlined />
|
||||||
|
</a>
|
||||||
|
</Tooltip>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ProTable<any>
|
||||||
|
rowKey="id"
|
||||||
|
headerTitle="物联网卡列表"
|
||||||
|
actionRef={actionRef}
|
||||||
|
request={(p) => iotCardApi.list({ page: p.current, limit: p.pageSize, ...params })}
|
||||||
|
columns={columns}
|
||||||
|
search={false}
|
||||||
|
scroll={{ x: 2000 }}
|
||||||
|
pagination={{ showSizeChanger: true, showQuickJumper: true }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export default IotCardTable;
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
import React, { useRef, useState, useCallback } from 'react';
|
||||||
|
import { PageContainer, ProFormText, ProFormSelect, ModalForm } from '@ant-design/pro-components';
|
||||||
|
import { Modal, message } from 'antd';
|
||||||
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
|
import { iotCardApi, CARRIER_OPTIONS, ENABLED_OPTIONS } from '@/services/iotCard';
|
||||||
|
import { deviceApi } from '@/services/device';
|
||||||
|
import IotCardTable, { IotCardTableRef } from './components/IotCardTable';
|
||||||
|
import IotCardForm, { IotCardFormValues } from './components/IotCardForm';
|
||||||
|
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
|
||||||
|
|
||||||
|
const IotCardPage: React.FC = () => {
|
||||||
|
const tableRef = useRef<IotCardTableRef>(null);
|
||||||
|
const [query, setQuery] = useState<Record<string, any>>({});
|
||||||
|
const [createOpen, setCreateOpen] = useState(false);
|
||||||
|
const [editOpen, setEditOpen] = useState(false);
|
||||||
|
const [current, setCurrent] = useState<any | null>(null);
|
||||||
|
const [bindOpen, setBindOpen] = useState(false);
|
||||||
|
const [bindRecord, setBindRecord] = useState<any | null>(null);
|
||||||
|
const [deviceOptions, setDeviceOptions] = useState<{ label: string; value: string }[]>([]);
|
||||||
|
const [deviceSearching, setDeviceSearching] = useState(false);
|
||||||
|
|
||||||
|
/** 搜索设备列表,用于绑定下拉框 */
|
||||||
|
const fetchDeviceOptions = useCallback(async (keyword?: string) => {
|
||||||
|
setDeviceSearching(true);
|
||||||
|
try {
|
||||||
|
const res = await deviceApi.deviceList({ page: 1, limit: 50, deviceSn: keyword || undefined, deviceName: keyword || undefined });
|
||||||
|
const options = (res.data || []).map((d: any) => ({
|
||||||
|
label: `${d.deviceSn}${d.deviceName ? ' - ' + d.deviceName : ''}`,
|
||||||
|
value: d.deviceSn,
|
||||||
|
}));
|
||||||
|
setDeviceOptions(options);
|
||||||
|
} catch {
|
||||||
|
setDeviceOptions([]);
|
||||||
|
} finally {
|
||||||
|
setDeviceSearching(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
/** 新增 */
|
||||||
|
const add = async (values: IotCardFormValues) => {
|
||||||
|
const hide = message.loading('保存中...');
|
||||||
|
try {
|
||||||
|
await iotCardApi.saveOrUpdate(values as any);
|
||||||
|
message.success('新增成功');
|
||||||
|
tableRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
message.error('新增失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 编辑 */
|
||||||
|
const edit = async (values: IotCardFormValues) => {
|
||||||
|
const hide = message.loading('保存中...');
|
||||||
|
try {
|
||||||
|
await iotCardApi.saveOrUpdate({ ...(current || {}), ...values } as any);
|
||||||
|
message.success('修改成功');
|
||||||
|
tableRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
message.error('修改失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
const del = async (record: any) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: `确认删除物联网卡 [${record.cardNumber}]?`,
|
||||||
|
onOk: async () => {
|
||||||
|
const hide = message.loading('正在删除...');
|
||||||
|
try {
|
||||||
|
await iotCardApi.remove(record.id);
|
||||||
|
message.success('删除成功');
|
||||||
|
tableRef.current?.reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error('删除失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 绑定设备 */
|
||||||
|
const handleBind = async (values: { deviceSn: string }) => {
|
||||||
|
if (!bindRecord) return false;
|
||||||
|
const hide = message.loading('绑定中...');
|
||||||
|
try {
|
||||||
|
await iotCardApi.bindDevice(bindRecord.id, values.deviceSn);
|
||||||
|
message.success('绑定成功');
|
||||||
|
tableRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
message.error('绑定失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 解绑设备 */
|
||||||
|
const handleUnbind = (record: any) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: `确认解绑设备 [${record.deviceSn}]?`,
|
||||||
|
onOk: async () => {
|
||||||
|
const hide = message.loading('解绑中...');
|
||||||
|
try {
|
||||||
|
await iotCardApi.unbindDevice(record.id);
|
||||||
|
message.success('解绑成功');
|
||||||
|
tableRef.current?.reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error('解绑失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer header={{ title: '物联网卡管理' }}>
|
||||||
|
{/* 搜索栏 */}
|
||||||
|
<SearchBarPlus
|
||||||
|
defaultCollapsed
|
||||||
|
split
|
||||||
|
span={6}
|
||||||
|
onTenantChanged={() => tableRef.current?.reload()}
|
||||||
|
showTenant={true}
|
||||||
|
onFinish={async (values) => setQuery(values)}
|
||||||
|
>
|
||||||
|
<ProFormText name="cardNumber" label="卡号" />
|
||||||
|
<ProFormText name="msisdn" label="MSISDN" />
|
||||||
|
<ProFormText name="deviceSn" label="设备SN" />
|
||||||
|
<ProFormSelect name="carrier" label="运营商" options={CARRIER_OPTIONS} />
|
||||||
|
<ProFormSelect name="enabled" label="启用状态" options={ENABLED_OPTIONS} />
|
||||||
|
</SearchBarPlus>
|
||||||
|
|
||||||
|
{/* 操作栏 */}
|
||||||
|
<ActionBar
|
||||||
|
left={
|
||||||
|
<GradientButton
|
||||||
|
size="middle"
|
||||||
|
type="primary"
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
onClick={() => setCreateOpen(true)}
|
||||||
|
>
|
||||||
|
新增
|
||||||
|
</GradientButton>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 表格 */}
|
||||||
|
<GlassCard>
|
||||||
|
<IotCardTable
|
||||||
|
ref={tableRef}
|
||||||
|
params={query}
|
||||||
|
onEdit={(r) => {
|
||||||
|
setCurrent(r);
|
||||||
|
setEditOpen(true);
|
||||||
|
}}
|
||||||
|
onDelete={(r) => del(r)}
|
||||||
|
onBind={(r) => {
|
||||||
|
setBindRecord(r);
|
||||||
|
setBindOpen(true);
|
||||||
|
}}
|
||||||
|
onUnbind={(r) => handleUnbind(r)}
|
||||||
|
/>
|
||||||
|
</GlassCard>
|
||||||
|
|
||||||
|
{/* 新增表单 */}
|
||||||
|
<IotCardForm title="新增物联网卡" visible={createOpen} onVisibleChange={setCreateOpen} onFinish={add} />
|
||||||
|
|
||||||
|
{/* 编辑表单 */}
|
||||||
|
<IotCardForm
|
||||||
|
title="编辑物联网卡"
|
||||||
|
visible={editOpen}
|
||||||
|
onVisibleChange={(v) => {
|
||||||
|
setEditOpen(v);
|
||||||
|
if (!v) setCurrent(null);
|
||||||
|
}}
|
||||||
|
onFinish={edit}
|
||||||
|
initialValues={current || {}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 绑定设备弹窗 */}
|
||||||
|
<ModalForm<{ deviceSn: string }>
|
||||||
|
title={`绑定设备 - 卡号: ${bindRecord?.cardNumber || ''}`}
|
||||||
|
visible={bindOpen}
|
||||||
|
onVisibleChange={(v) => {
|
||||||
|
setBindOpen(v);
|
||||||
|
if (!v) {
|
||||||
|
setBindRecord(null);
|
||||||
|
setDeviceOptions([]);
|
||||||
|
}
|
||||||
|
if (v) {
|
||||||
|
// 弹窗打开时加载设备列表
|
||||||
|
fetchDeviceOptions();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onFinish={handleBind}
|
||||||
|
modalProps={{ destroyOnClose: true }}
|
||||||
|
>
|
||||||
|
<ProFormSelect
|
||||||
|
name="deviceSn"
|
||||||
|
label="选择设备"
|
||||||
|
rules={[{ required: true, message: '请选择要绑定的设备' }]}
|
||||||
|
width="lg"
|
||||||
|
placeholder="输入设备SN或名称搜索"
|
||||||
|
showSearch
|
||||||
|
options={deviceOptions}
|
||||||
|
fieldProps={{
|
||||||
|
loading: deviceSearching,
|
||||||
|
filterOption: false,
|
||||||
|
onSearch: (val: string) => fetchDeviceOptions(val),
|
||||||
|
notFoundContent: deviceSearching ? '加载中...' : '暂无设备',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ModalForm>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default IotCardPage;
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import { request } from 'umi';
|
||||||
|
|
||||||
|
/** 物联网卡数据项 */
|
||||||
|
export interface IotCardItem {
|
||||||
|
id?: number;
|
||||||
|
cardNumber?: string;
|
||||||
|
msisdn?: string;
|
||||||
|
imsi?: string;
|
||||||
|
carrier?: number;
|
||||||
|
packageType?: string;
|
||||||
|
enabled?: number;
|
||||||
|
deviceSn?: string;
|
||||||
|
deviceName?: string;
|
||||||
|
activationTime?: string;
|
||||||
|
expirationTime?: string;
|
||||||
|
tenantId?: string;
|
||||||
|
remark?: string;
|
||||||
|
createTime?: string;
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 运营商映射 */
|
||||||
|
export const CARRIER_MAP: Record<number, string> = {
|
||||||
|
1: '中国移动',
|
||||||
|
2: '中国联通',
|
||||||
|
3: '中国电信',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 运营商选项 */
|
||||||
|
export const CARRIER_OPTIONS = [
|
||||||
|
{ label: '中国移动', value: 1 },
|
||||||
|
{ label: '中国联通', value: 2 },
|
||||||
|
{ label: '中国电信', value: 3 },
|
||||||
|
];
|
||||||
|
|
||||||
|
/** 启用状态选项 */
|
||||||
|
export const ENABLED_OPTIONS = [
|
||||||
|
{ label: '启用', value: 1 },
|
||||||
|
{ label: '停用', value: 0 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const iotCardApi = {
|
||||||
|
/** 分页列表 */
|
||||||
|
list: async (params: { page?: number; limit?: number; [k: string]: any }) => {
|
||||||
|
const res = await request('/api-device/iot-card', { method: 'GET', params });
|
||||||
|
return { data: (res as any).data, total: (res as any).count } as { data: IotCardItem[]; total: number };
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 查询详情 */
|
||||||
|
getById: async (id: number) => {
|
||||||
|
const res = await request(`/api-device/iot-card/${id}`, { method: 'GET' });
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 新增/更新 */
|
||||||
|
saveOrUpdate: async (data: Partial<IotCardItem>) => {
|
||||||
|
const res = await request('/api-device/iot-card', { method: 'POST', data });
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
remove: async (id: number) => {
|
||||||
|
const res = await request(`/api-device/iot-card/${id}`, { method: 'DELETE' });
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 绑定设备 */
|
||||||
|
bindDevice: async (id: number, deviceSn: string) => {
|
||||||
|
const res = await request(`/api-device/iot-card/${id}/bind`, { method: 'POST', params: { deviceSn } });
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 解绑设备 */
|
||||||
|
unbindDevice: async (id: number) => {
|
||||||
|
const res = await request(`/api-device/iot-card/${id}/unbind`, { method: 'POST' });
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 启用/停用 */
|
||||||
|
toggleEnabled: async (id: number, enabled: number) => {
|
||||||
|
const res = await request(`/api-device/iot-card/${id}/toggle`, { method: 'PUT', params: { enabled } });
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
};
|
||||||
Binary file not shown.
@@ -46,7 +46,7 @@
|
|||||||
"@types/uuid": "^9.0.0",
|
"@types/uuid": "^9.0.0",
|
||||||
"@umijs/preset-react": "^2.1.0",
|
"@umijs/preset-react": "^2.1.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"typescript": "^4.9.0"
|
"typescript": "^5.9.3"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"path-to-regexp": "^3.3.0",
|
"path-to-regexp": "^3.3.0",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 329 KiB |
@@ -53,26 +53,49 @@
|
|||||||
|
|
||||||
.routeActions {
|
.routeActions {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 20px;
|
bottom: 24px;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
background: rgba(10, 18, 32, 0.92);
|
background: linear-gradient(135deg, rgba(8, 22, 36, 0.94) 0%, rgba(15, 35, 58, 0.9) 100%);
|
||||||
padding: 10px 20px;
|
padding: 12px 18px;
|
||||||
border-radius: 8px;
|
border-radius: 16px;
|
||||||
z-index: 800;
|
z-index: 830;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
|
box-shadow:
|
||||||
border: 1px solid rgba(0, 212, 255, 0.3);
|
0 16px 34px rgba(0, 0, 0, 0.35),
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.08),
|
||||||
|
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 {
|
.routeActionsTitle {
|
||||||
color: #00d4ff;
|
color: #dff3ff;
|
||||||
font-size: 13px;
|
font-size: 14px;
|
||||||
font-weight: 500;
|
font-weight: 700;
|
||||||
max-width: 150px;
|
max-width: 180px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 960px) {
|
||||||
|
.routeActions {
|
||||||
|
left: 12px;
|
||||||
|
right: 12px;
|
||||||
|
bottom: 12px;
|
||||||
|
transform: none;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeActionsTitle {
|
||||||
|
max-width: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ interface CenterViewProps {
|
|||||||
selectedRouteId: string | null;
|
selectedRouteId: string | null;
|
||||||
boatData: BoatTelemetryData | null;
|
boatData: BoatTelemetryData | null;
|
||||||
onModelCenter?: (lon: number, lat: number) => void;
|
onModelCenter?: (lon: number, lat: number) => void;
|
||||||
|
isSailing?: boolean;
|
||||||
|
previewStopSignal?: number;
|
||||||
|
onStartSailing?: (routeId: string) => void;
|
||||||
|
onPreviewChange?: (previewing: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRouteId, boatData, onModelCenter }) => {
|
const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRouteId, boatData, onModelCenter, isSailing, 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);
|
||||||
@@ -32,6 +36,24 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
|
|||||||
const { loadTileset, unloadAllTilesets } = useTilesetLoader();
|
const { loadTileset, unloadAllTilesets } = useTilesetLoader();
|
||||||
const { isPreviewing, startPreview, stopPreview } = useRoutePreview({ viewerRef });
|
const { isPreviewing, startPreview, stopPreview } = useRoutePreview({ viewerRef });
|
||||||
|
|
||||||
|
// 预览状态变化时通知父组件
|
||||||
|
useEffect(() => {
|
||||||
|
onPreviewChange?.(isPreviewing);
|
||||||
|
}, [isPreviewing, onPreviewChange]);
|
||||||
|
|
||||||
|
const lastPreviewStopSignalRef = useRef(previewStopSignal);
|
||||||
|
|
||||||
|
// 外部停止通道:例如 HUD 点击“结束预览”时由父组件递增信号
|
||||||
|
useEffect(() => {
|
||||||
|
if (previewStopSignal == null) return;
|
||||||
|
if (lastPreviewStopSignalRef.current === previewStopSignal) return;
|
||||||
|
|
||||||
|
lastPreviewStopSignalRef.current = previewStopSignal;
|
||||||
|
if (isPreviewing) {
|
||||||
|
stopPreview();
|
||||||
|
}
|
||||||
|
}, [previewStopSignal, isPreviewing, stopPreview]);
|
||||||
|
|
||||||
// 航线渲染数据(含航点)
|
// 航线渲染数据(含航点)
|
||||||
const [routeRenderItems, setRouteRenderItems] = useState<any[]>([]);
|
const [routeRenderItems, setRouteRenderItems] = useState<any[]>([]);
|
||||||
// 缓存已加载的航线详情
|
// 缓存已加载的航线详情
|
||||||
@@ -384,10 +406,12 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
|
|||||||
await startPreview(waypoints, 2);
|
await startPreview(waypoints, 2);
|
||||||
}, [selectedRouteId, startPreview]);
|
}, [selectedRouteId, startPreview]);
|
||||||
|
|
||||||
// 执行航线(暂未实现)
|
// 执行航线
|
||||||
const handleExecuteRoute = useCallback(() => {
|
const handleExecuteRoute = useCallback(() => {
|
||||||
message.info('航行功能开发中...');
|
if (selectedRouteId && onStartSailing) {
|
||||||
}, []);
|
onStartSailing(selectedRouteId);
|
||||||
|
}
|
||||||
|
}, [selectedRouteId, onStartSailing]);
|
||||||
|
|
||||||
// 获取选中航线名称
|
// 获取选中航线名称
|
||||||
const selectedRouteName = useMemo(() => {
|
const selectedRouteName = useMemo(() => {
|
||||||
@@ -407,8 +431,8 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 选中线路时显示操作按钮 */}
|
{/* 选中线路时显示操作按钮(非航行模式) */}
|
||||||
{selectedRouteId && !isPreviewing && (
|
{selectedRouteId && !isPreviewing && !isSailing && (
|
||||||
<div className={styles.routeActions}>
|
<div className={styles.routeActions}>
|
||||||
<div className={styles.routeActionsTitle}>{selectedRouteName}</div>
|
<div className={styles.routeActionsTitle}>{selectedRouteName}</div>
|
||||||
<Space>
|
<Space>
|
||||||
@@ -432,20 +456,7 @@ const CenterView: React.FC<CenterViewProps> = ({ deviceSn, routes, selectedRoute
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 预览中显示停止按钮 */}
|
{/* 预览停止操作已收敛至 NavigationHUD,此处不再重复渲染 */}
|
||||||
{isPreviewing && (
|
|
||||||
<div className={styles.routeActions}>
|
|
||||||
<Button
|
|
||||||
danger
|
|
||||||
type="primary"
|
|
||||||
icon={<StopOutlined />}
|
|
||||||
onClick={stopPreview}
|
|
||||||
size="small"
|
|
||||||
>
|
|
||||||
停止预览 (ESC)
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
.emergencyBtn {
|
||||||
|
position: absolute;
|
||||||
|
top: 22px;
|
||||||
|
right: 22px;
|
||||||
|
z-index: 930;
|
||||||
|
width: 142px;
|
||||||
|
height: 54px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: linear-gradient(135deg, rgba(255, 111, 85, 0.96) 0%, rgba(206, 51, 53, 0.94) 100%);
|
||||||
|
border: 1px solid rgba(255, 181, 152, 0.36);
|
||||||
|
color: #fff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
box-shadow:
|
||||||
|
0 16px 34px rgba(94, 16, 18, 0.34),
|
||||||
|
0 0 0 1px rgba(255, 110, 92, 0.22),
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.18);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
animation: dangerPulse 2s infinite;
|
||||||
|
font-family: 'Rajdhani', 'Orbitron', 'DIN', 'Avenir Next', 'PingFang SC', sans-serif;
|
||||||
|
backdrop-filter: blur(16px);
|
||||||
|
-webkit-backdrop-filter: blur(16px);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: linear-gradient(135deg, rgba(255, 133, 110, 0.98) 0%, rgba(230, 61, 63, 0.96) 100%);
|
||||||
|
box-shadow:
|
||||||
|
0 18px 38px rgba(112, 19, 23, 0.42),
|
||||||
|
0 0 22px rgba(255, 107, 88, 0.32),
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.24);
|
||||||
|
animation: dangerPulseHover 1s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: scale(0.97);
|
||||||
|
box-shadow:
|
||||||
|
0 8px 16px rgba(82, 17, 18, 0.35),
|
||||||
|
inset 0 4px 10px rgba(0, 0, 0, 0.16);
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
font-size: 18px;
|
||||||
|
margin-top: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes dangerPulse {
|
||||||
|
0% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.6); }
|
||||||
|
70% { box-shadow: 0 0 0 12px rgba(255, 77, 79, 0); }
|
||||||
|
100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes dangerPulseHover {
|
||||||
|
0% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.8); }
|
||||||
|
70% { box-shadow: 0 0 0 16px rgba(255, 77, 79, 0); }
|
||||||
|
100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 960px) {
|
||||||
|
.emergencyBtn {
|
||||||
|
top: 14px;
|
||||||
|
right: 14px;
|
||||||
|
width: 132px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Modal } from 'antd';
|
||||||
|
import { WarningOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
export interface EmergencyButtonProps {
|
||||||
|
onEmergencyStop: () => void;
|
||||||
|
deviceSn: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EmergencyButton: React.FC<EmergencyButtonProps> = ({ onEmergencyStop, deviceSn }) => {
|
||||||
|
const handleClick = () => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认紧急停靠',
|
||||||
|
icon: <ExclamationCircleOutlined style={{ color: '#ff4d4f' }} />,
|
||||||
|
content: `您确定要立即停止设备 ${deviceSn} 的所有动作吗?这可能会造成不可逆的后果。`,
|
||||||
|
okText: '确认停靠',
|
||||||
|
okType: 'danger',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
onEmergencyStop();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button className={styles.emergencyBtn} onClick={handleClick}>
|
||||||
|
<WarningOutlined className={styles.icon} />
|
||||||
|
<span className={styles.text}>紧急停靠</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EmergencyButton;
|
||||||
@@ -1,3 +1,17 @@
|
|||||||
|
/* ========== 玻璃拟态变量 ========== */
|
||||||
|
@glass-border: rgba(65, 170, 255, 0.28);
|
||||||
|
@glass-border-light: rgba(92, 211, 255, 0.18);
|
||||||
|
@accent-cyan: #00d4ff;
|
||||||
|
@accent-blue: #0096ff;
|
||||||
|
@text-primary: #eaf6ff;
|
||||||
|
@text-secondary: rgba(255, 255, 255, 0.55);
|
||||||
|
@text-dim: rgba(255, 255, 255, 0.35);
|
||||||
|
@card-bg: linear-gradient(145deg, rgba(10, 24, 48, 0.7), rgba(8, 18, 38, 0.5));
|
||||||
|
@card-bg-active: linear-gradient(145deg, rgba(0, 80, 160, 0.2), rgba(0, 120, 200, 0.1));
|
||||||
|
@card-shadow: 0 2px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||||
|
@card-shadow-active: 0 2px 20px rgba(0, 112, 212, 0.2), inset 0 1px 0 rgba(0, 180, 255, 0.12);
|
||||||
|
@transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -6,54 +20,74 @@
|
|||||||
|
|
||||||
/* ========== 头部 ========== */
|
/* ========== 头部 ========== */
|
||||||
.header {
|
.header {
|
||||||
padding: 18px 16px;
|
padding: 20px 16px 16px;
|
||||||
border-bottom: 1px solid rgba(0, 212, 255, 0.12);
|
border-bottom: 1px solid @glass-border-light;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
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 {
|
.headerIcon {
|
||||||
width: 36px;
|
width: 38px;
|
||||||
height: 36px;
|
height: 38px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background: linear-gradient(135deg, rgba(0, 112, 212, 0.3), rgba(0, 180, 255, 0.15));
|
background: linear-gradient(135deg, rgba(0, 100, 200, 0.35), rgba(0, 180, 255, 0.15));
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
border: 1px solid rgba(0, 150, 255, 0.25);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: #00d4ff;
|
color: @accent-cyan;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
flex-shrink: 0;
|
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 {
|
.headerTitle {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #fff;
|
color: @text-primary;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.headerSub {
|
.headerSub {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: rgba(255, 255, 255, 0.35);
|
color: @text-dim;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.count {
|
.count {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
background: rgba(0, 112, 212, 0.2);
|
background: linear-gradient(135deg, rgba(0, 100, 200, 0.25), rgba(0, 150, 255, 0.15));
|
||||||
color: #00b4ff;
|
border: 1px solid rgba(0, 150, 255, 0.2);
|
||||||
|
color: @accent-cyan;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
padding: 2px 10px;
|
font-family: 'Rajdhani', 'DIN', monospace;
|
||||||
|
padding: 2px 12px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 列表 ========== */
|
/* ========== 列表 ========== */
|
||||||
.list {
|
.list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 10px;
|
padding: 12px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.center {
|
.center {
|
||||||
@@ -65,27 +99,58 @@
|
|||||||
|
|
||||||
/* ========== 线路卡片 ========== */
|
/* ========== 线路卡片 ========== */
|
||||||
.routeCard {
|
.routeCard {
|
||||||
padding: 14px;
|
padding: 14px 16px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.25s;
|
transition: @transition-fast;
|
||||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
background: rgba(255, 255, 255, 0.03);
|
background: @card-bg;
|
||||||
|
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: rgba(0, 150, 220, 0.08);
|
background: linear-gradient(145deg, rgba(0, 80, 160, 0.12), rgba(0, 120, 200, 0.06));
|
||||||
border-color: rgba(0, 180, 255, 0.2);
|
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: rgba(0, 112, 212, 0.12);
|
background: @card-bg-active;
|
||||||
border-color: rgba(0, 150, 255, 0.4);
|
border-color: rgba(0, 150, 255, 0.4);
|
||||||
box-shadow: 0 0 16px rgba(0, 112, 212, 0.12);
|
box-shadow: @card-shadow-active;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
background: linear-gradient(180deg, @accent-cyan, @accent-blue);
|
||||||
|
width: 3px;
|
||||||
|
top: 12%;
|
||||||
|
bottom: 12%;
|
||||||
|
}
|
||||||
|
|
||||||
.routeName {
|
.routeName {
|
||||||
color: #00d4ff;
|
color: @accent-cyan;
|
||||||
|
text-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +159,8 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: rgba(255, 255, 255, 0.92);
|
color: rgba(255, 255, 255, 0.92);
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
transition: color 0.2s;
|
transition: @transition-fast;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 标签行 ========== */
|
/* ========== 标签行 ========== */
|
||||||
@@ -110,15 +176,18 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: rgba(255, 255, 255, 0.5);
|
color: @text-secondary;
|
||||||
background: rgba(255, 255, 255, 0.06);
|
background: rgba(0, 100, 180, 0.1);
|
||||||
|
border: 1px solid rgba(0, 150, 255, 0.1);
|
||||||
padding: 2px 8px;
|
padding: 2px 8px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
font-family: 'Rajdhani', 'DIN', sans-serif;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tagIcon {
|
.tagIcon {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
color: rgba(0, 180, 255, 0.6);
|
color: rgba(0, 180, 255, 0.65);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 航点路径 ========== */
|
/* ========== 航点路径 ========== */
|
||||||
@@ -126,42 +195,53 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 5px;
|
||||||
padding: 10px 0 4px;
|
padding: 10px 0 4px;
|
||||||
border-top: 1px dashed rgba(255, 255, 255, 0.08);
|
border-top: 1px solid rgba(65, 170, 255, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.waypointDot {
|
.waypointDot {
|
||||||
width: 6px;
|
width: 6px;
|
||||||
height: 6px;
|
height: 6px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: rgba(0, 180, 255, 0.6);
|
background: @accent-cyan;
|
||||||
|
box-shadow: 0 0 4px rgba(0, 212, 255, 0.4);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.waypointName {
|
.waypointName {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: rgba(255, 255, 255, 0.7);
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
letter-spacing: 0.2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.waypointArrow {
|
.waypointArrow {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: rgba(0, 180, 255, 0.5);
|
color: rgba(0, 180, 255, 0.45);
|
||||||
margin: 0 1px;
|
margin: 0 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 开始航行按钮 ========== */
|
/* ========== 开始航行按钮 ========== */
|
||||||
.startBtn {
|
.startBtn {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
height: 36px;
|
height: 38px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1.5px;
|
||||||
background: linear-gradient(135deg, #0070d4, #0096ff);
|
background: linear-gradient(135deg, #0070d4, #0096ff);
|
||||||
border: none;
|
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;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: linear-gradient(135deg, #0080e8, #00a8ff);
|
background: linear-gradient(135deg, #0080e8, #00a8ff);
|
||||||
|
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 {
|
||||||
|
transform: translateY(0);
|
||||||
|
box-shadow: 0 1px 6px rgba(0, 112, 212, 0.3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,467 @@
|
|||||||
|
.hudContainer {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 26px;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: calc(100% - 48px);
|
||||||
|
max-width: 1360px;
|
||||||
|
z-index: 920;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 168px 1fr 216px 168px;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: stretch;
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 14px 16px;
|
||||||
|
background:
|
||||||
|
linear-gradient(120deg, rgba(7, 20, 34, 0.95) 0%, rgba(11, 36, 60, 0.9) 58%, rgba(18, 29, 50, 0.94) 100%);
|
||||||
|
border: 1px solid rgba(65, 170, 255, 0.28);
|
||||||
|
box-shadow:
|
||||||
|
0 16px 40px rgba(2, 11, 24, 0.5),
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.08),
|
||||||
|
inset 0 0 0 1px rgba(33, 145, 240, 0.14);
|
||||||
|
color: #eaf6ff;
|
||||||
|
font-family: 'Rajdhani', 'DIN', 'Avenir Next', 'PingFang SC', sans-serif;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hudContainer::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 16px;
|
||||||
|
right: 16px;
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(90deg, transparent 0%, rgba(133, 206, 255, 0.7) 45%, transparent 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hudContainer::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: -120px;
|
||||||
|
right: -120px;
|
||||||
|
width: 280px;
|
||||||
|
height: 280px;
|
||||||
|
background: radial-gradient(circle, rgba(70, 156, 255, 0.22) 0%, rgba(70, 156, 255, 0) 72%);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.previewMode {
|
||||||
|
border-color: rgba(72, 190, 255, 0.42);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sailingMode {
|
||||||
|
border-color: rgba(255, 158, 94, 0.38);
|
||||||
|
}
|
||||||
|
|
||||||
|
.primaryCluster,
|
||||||
|
.centerCluster,
|
||||||
|
.statusCluster,
|
||||||
|
.actionCluster {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primaryCluster {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedDial {
|
||||||
|
width: 116px;
|
||||||
|
height: 116px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedSvg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedTrack,
|
||||||
|
.speedRing {
|
||||||
|
fill: none;
|
||||||
|
stroke-width: 8;
|
||||||
|
transform-origin: 60px 60px;
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedTrack {
|
||||||
|
stroke: rgba(208, 231, 255, 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedRing {
|
||||||
|
stroke: #4fcbff;
|
||||||
|
stroke-linecap: round;
|
||||||
|
transition: stroke-dashoffset 0.35s ease;
|
||||||
|
filter: drop-shadow(0 0 8px rgba(79, 203, 255, 0.7));
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedCenter {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedValue {
|
||||||
|
font-size: 34px;
|
||||||
|
line-height: 1;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #f5fbff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.speedUnit {
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
color: rgba(166, 223, 255, 0.86);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modeChip {
|
||||||
|
padding: 2px 12px;
|
||||||
|
border-radius: 100px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #d8eeff;
|
||||||
|
border: 1px solid rgba(156, 213, 255, 0.35);
|
||||||
|
background: rgba(20, 48, 75, 0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.centerCluster {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeHeader {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeTitle {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #f1f9ff;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeProgress {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #7fd9ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeProgressTrack {
|
||||||
|
width: 100%;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: rgba(201, 226, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeProgressFill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: inherit;
|
||||||
|
background: linear-gradient(90deg, #2e9dff 0%, #3ff0ff 55%, #7effcc 100%);
|
||||||
|
transition: width 0.3s ease;
|
||||||
|
box-shadow: 0 0 8px rgba(76, 202, 255, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointCard {
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
background: linear-gradient(140deg, rgba(22, 47, 78, 0.78) 0%, rgba(11, 26, 43, 0.84) 100%);
|
||||||
|
border: 1px solid rgba(110, 186, 255, 0.22);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointMain {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navArrow {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #59cbff;
|
||||||
|
filter: drop-shadow(0 0 6px rgba(89, 203, 255, 0.7));
|
||||||
|
}
|
||||||
|
|
||||||
|
.infoLabel {
|
||||||
|
font-size: 11px;
|
||||||
|
letter-spacing: 0.6px;
|
||||||
|
color: rgba(195, 226, 255, 0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointName {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #f7fcff;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
max-width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointStats {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infoValue {
|
||||||
|
margin-top: 2px;
|
||||||
|
font-size: 17px;
|
||||||
|
color: #8de5ff;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emptyWaypoint {
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
color: rgba(204, 229, 255, 0.72);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryRow {
|
||||||
|
display: flex;
|
||||||
|
gap: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryItem {
|
||||||
|
min-width: 92px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryValue {
|
||||||
|
margin-top: 2px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #e6f5ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusCluster {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compassCard,
|
||||||
|
.powerCard {
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
background: rgba(12, 29, 48, 0.78);
|
||||||
|
border: 1px solid rgba(106, 176, 238, 0.22);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardTitle {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #b7deff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compassDial {
|
||||||
|
margin: 6px auto;
|
||||||
|
width: 72px;
|
||||||
|
height: 72px;
|
||||||
|
border-radius: 50%;
|
||||||
|
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%);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compassRotor {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
transition: transform 0.28s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compassTick {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 5px;
|
||||||
|
width: 2px;
|
||||||
|
height: 7px;
|
||||||
|
margin-left: -1px;
|
||||||
|
background: rgba(174, 219, 255, 0.75);
|
||||||
|
transform-origin: 50% 31px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compassNeedle {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 8px;
|
||||||
|
margin-left: -3px;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-left: 3px solid transparent;
|
||||||
|
border-right: 3px solid transparent;
|
||||||
|
border-bottom: 14px solid #ff8f66;
|
||||||
|
filter: drop-shadow(0 0 5px rgba(255, 143, 102, 0.8));
|
||||||
|
}
|
||||||
|
|
||||||
|
.compassValue {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #ecf8ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.powerCard {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.powerRow {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.powerValue {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #f7fbff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.powerTrack {
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: rgba(196, 223, 250, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.powerFill,
|
||||||
|
.signalFill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: inherit;
|
||||||
|
transition: width 0.25s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.powerFill {
|
||||||
|
background: linear-gradient(90deg, #fa7d57 0%, #ffcf77 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.signalFill {
|
||||||
|
background: linear-gradient(90deg, #2ea4ff 0%, #63f4ff 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionCluster {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionBtn {
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
background: rgba(255, 255, 255, 0.07);
|
||||||
|
color: #f2faff;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionBtn:active {
|
||||||
|
transform: scale(0.97);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionPrimary {
|
||||||
|
border-color: rgba(95, 210, 255, 0.5);
|
||||||
|
background: linear-gradient(120deg, rgba(43, 147, 232, 0.34) 0%, rgba(51, 190, 235, 0.5) 100%);
|
||||||
|
box-shadow: inset 0 0 0 1px rgba(144, 220, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionPrimary:hover {
|
||||||
|
filter: brightness(1.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionDanger {
|
||||||
|
border-color: rgba(255, 151, 108, 0.62);
|
||||||
|
background: linear-gradient(120deg, rgba(219, 95, 46, 0.55) 0%, rgba(255, 140, 90, 0.52) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionDanger:hover {
|
||||||
|
filter: brightness(1.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1240px) {
|
||||||
|
.hudContainer {
|
||||||
|
grid-template-columns: 154px 1fr 200px 154px;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeTitle {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointName {
|
||||||
|
max-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointStats {
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 960px) {
|
||||||
|
.hudContainer {
|
||||||
|
left: 12px;
|
||||||
|
right: 12px;
|
||||||
|
bottom: 10px;
|
||||||
|
transform: none;
|
||||||
|
width: auto;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
max-height: 46vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primaryCluster,
|
||||||
|
.statusCluster,
|
||||||
|
.actionCluster {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centerCluster {
|
||||||
|
order: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summaryRow {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionCluster {
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionBtn {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
import React, { useMemo } from 'react';
|
||||||
|
import {
|
||||||
|
PauseCircleOutlined,
|
||||||
|
PlayCircleOutlined,
|
||||||
|
StopOutlined,
|
||||||
|
SendOutlined,
|
||||||
|
ThunderboltOutlined,
|
||||||
|
WifiOutlined,
|
||||||
|
CompassOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
type NavigationMode = 'preview' | 'sailing';
|
||||||
|
|
||||||
|
export interface NavigationHUDProps {
|
||||||
|
mode: NavigationMode;
|
||||||
|
routeName: string;
|
||||||
|
speed: number;
|
||||||
|
heading: number;
|
||||||
|
battery: number;
|
||||||
|
signalStrength?: number;
|
||||||
|
nextWaypoint?: {
|
||||||
|
name: string;
|
||||||
|
distance: number;
|
||||||
|
estimatedTime: number;
|
||||||
|
};
|
||||||
|
remainingDistance: number;
|
||||||
|
estimatedRemainingTime: number;
|
||||||
|
progress: number;
|
||||||
|
isPaused: boolean;
|
||||||
|
onPause: () => void;
|
||||||
|
onResume: () => void;
|
||||||
|
onStop: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 格式化距离 */
|
||||||
|
const formatDist = (m: number) => (m >= 1000 ? `${(m / 1000).toFixed(1)}km` : `${Math.round(m)}m`);
|
||||||
|
|
||||||
|
/** 格式化时间 */
|
||||||
|
const formatTime = (s: number) => {
|
||||||
|
const mins = Math.floor(s / 60);
|
||||||
|
const secs = Math.floor(s % 60);
|
||||||
|
if (mins >= 60) {
|
||||||
|
const h = Math.floor(mins / 60);
|
||||||
|
const m = mins % 60;
|
||||||
|
return `${h}时${m}分`;
|
||||||
|
}
|
||||||
|
return mins > 0 ? `${mins}分${secs}秒` : `${secs}秒`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const directionText = (heading: number) => {
|
||||||
|
const normalized = ((heading % 360) + 360) % 360;
|
||||||
|
if (normalized < 22.5 || normalized >= 337.5) return '北';
|
||||||
|
if (normalized < 67.5) return '东北';
|
||||||
|
if (normalized < 112.5) return '东';
|
||||||
|
if (normalized < 157.5) return '东南';
|
||||||
|
if (normalized < 202.5) return '南';
|
||||||
|
if (normalized < 247.5) return '西南';
|
||||||
|
if (normalized < 292.5) return '西';
|
||||||
|
return '西北';
|
||||||
|
};
|
||||||
|
|
||||||
|
const NavigationHUD: React.FC<NavigationHUDProps> = ({
|
||||||
|
mode,
|
||||||
|
routeName,
|
||||||
|
speed,
|
||||||
|
heading,
|
||||||
|
battery,
|
||||||
|
signalStrength,
|
||||||
|
nextWaypoint,
|
||||||
|
remainingDistance,
|
||||||
|
estimatedRemainingTime,
|
||||||
|
progress,
|
||||||
|
isPaused,
|
||||||
|
onPause,
|
||||||
|
onResume,
|
||||||
|
onStop,
|
||||||
|
}) => {
|
||||||
|
const maxSpeed = 12;
|
||||||
|
const clampedSpeed = Math.max(0, Math.min(speed, maxSpeed));
|
||||||
|
const speedPercent = clampedSpeed / maxSpeed;
|
||||||
|
const ringLength = 2 * Math.PI * 44;
|
||||||
|
const ringOffset = ringLength * (1 - speedPercent);
|
||||||
|
const normalizedProgress = Math.max(0, Math.min(100, progress));
|
||||||
|
const normalizedBattery = Math.max(0, Math.min(100, battery));
|
||||||
|
const normalizedSignal = Math.max(0, Math.min(100, signalStrength ?? 0));
|
||||||
|
|
||||||
|
const compassTicks = useMemo(() => {
|
||||||
|
const marks = [];
|
||||||
|
for (let i = 0; i < 12; i += 1) {
|
||||||
|
marks.push(<span key={i} className={styles.compassTick} style={{ transform: `rotate(${i * 30}deg)` }} />);
|
||||||
|
}
|
||||||
|
return marks;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const previewing = mode === 'preview';
|
||||||
|
const actionText = previewing ? '结束预览' : isPaused ? '继续航行' : '暂停航行';
|
||||||
|
const actionIcon = previewing ? <StopOutlined /> : isPaused ? <PlayCircleOutlined /> : <PauseCircleOutlined />;
|
||||||
|
const actionHandler = previewing ? onStop : isPaused ? onResume : onPause;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`${styles.hudContainer} ${previewing ? styles.previewMode : styles.sailingMode}`}>
|
||||||
|
<div className={styles.primaryCluster}>
|
||||||
|
<div className={styles.speedDial}>
|
||||||
|
<svg viewBox="0 0 120 120" className={styles.speedSvg}>
|
||||||
|
<circle cx="60" cy="60" r="44" className={styles.speedTrack} />
|
||||||
|
<circle
|
||||||
|
cx="60"
|
||||||
|
cy="60"
|
||||||
|
r="44"
|
||||||
|
className={styles.speedRing}
|
||||||
|
style={{ strokeDasharray: ringLength, strokeDashoffset: ringOffset }}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<div className={styles.speedCenter}>
|
||||||
|
<div className={styles.speedValue}>{speed.toFixed(1)}</div>
|
||||||
|
<div className={styles.speedUnit}>m/s</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.modeChip}>{previewing ? '预览模式' : '航行模式'}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.centerCluster}>
|
||||||
|
<div className={styles.routeHeader}>
|
||||||
|
<span className={styles.routeTitle}>{routeName || '未选择线路'}</span>
|
||||||
|
<span className={styles.routeProgress}>{normalizedProgress}%</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.routeProgressTrack}>
|
||||||
|
<div className={styles.routeProgressFill} style={{ width: `${normalizedProgress}%` }} />
|
||||||
|
</div>
|
||||||
|
<div className={styles.waypointCard}>
|
||||||
|
{nextWaypoint ? (
|
||||||
|
<>
|
||||||
|
<div className={styles.waypointMain}>
|
||||||
|
<SendOutlined className={styles.navArrow} />
|
||||||
|
<div>
|
||||||
|
<div className={styles.infoLabel}>下一航点</div>
|
||||||
|
<div className={styles.waypointName}>{nextWaypoint.name}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.waypointStats}>
|
||||||
|
<div>
|
||||||
|
<div className={styles.infoLabel}>到点距离</div>
|
||||||
|
<div className={styles.infoValue}>{formatDist(nextWaypoint.distance)}</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className={styles.infoLabel}>到点时间</div>
|
||||||
|
<div className={styles.infoValue}>{formatTime(nextWaypoint.estimatedTime)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className={styles.emptyWaypoint}>
|
||||||
|
暂无航点数据
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className={styles.summaryRow}>
|
||||||
|
<div className={styles.summaryItem}>
|
||||||
|
<div className={styles.infoLabel}>剩余里程</div>
|
||||||
|
<div className={styles.summaryValue}>{formatDist(remainingDistance)}</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.summaryItem}>
|
||||||
|
<div className={styles.infoLabel}>预计剩余</div>
|
||||||
|
<div className={styles.summaryValue}>{formatTime(estimatedRemainingTime)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.statusCluster}>
|
||||||
|
<div className={styles.compassCard}>
|
||||||
|
<div className={styles.cardTitle}><CompassOutlined /> 航向</div>
|
||||||
|
<div className={styles.compassDial}>
|
||||||
|
<div className={styles.compassRotor} style={{ transform: `rotate(${heading}deg)` }}>
|
||||||
|
{compassTicks}
|
||||||
|
</div>
|
||||||
|
<div className={styles.compassNeedle} />
|
||||||
|
</div>
|
||||||
|
<div className={styles.compassValue}>{Math.round(heading)}° · {directionText(heading)}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.powerCard}>
|
||||||
|
<div className={styles.powerRow}>
|
||||||
|
<span className={styles.infoLabel}><ThunderboltOutlined /> 电量</span>
|
||||||
|
<span className={styles.powerValue}>{Math.round(normalizedBattery)}%</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.powerTrack}>
|
||||||
|
<div className={styles.powerFill} style={{ width: `${normalizedBattery}%` }} />
|
||||||
|
</div>
|
||||||
|
<div className={styles.powerRow}>
|
||||||
|
<span className={styles.infoLabel}><WifiOutlined /> 信号</span>
|
||||||
|
<span className={styles.powerValue}>{signalStrength == null ? '--' : `${Math.round(normalizedSignal)}%`}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.powerTrack}>
|
||||||
|
<div className={styles.signalFill} style={{ width: `${signalStrength == null ? 0 : normalizedSignal}%` }} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.actionCluster}>
|
||||||
|
<button className={`${styles.actionBtn} ${styles.actionPrimary}`} onClick={actionHandler}>
|
||||||
|
{actionIcon}
|
||||||
|
<span>{actionText}</span>
|
||||||
|
</button>
|
||||||
|
{!previewing && (
|
||||||
|
<button className={`${styles.actionBtn} ${styles.actionDanger}`} onClick={onStop}>
|
||||||
|
<StopOutlined />
|
||||||
|
<span>结束航行</span>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default NavigationHUD;
|
||||||
@@ -0,0 +1,369 @@
|
|||||||
|
.overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
left: 20px;
|
||||||
|
z-index: 910;
|
||||||
|
width: 340px;
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 14px;
|
||||||
|
background:
|
||||||
|
linear-gradient(145deg, rgba(8, 21, 36, 0.94) 0%, rgba(13, 35, 58, 0.9) 58%, rgba(18, 28, 46, 0.95) 100%);
|
||||||
|
border: 1px solid rgba(92, 180, 255, 0.28);
|
||||||
|
box-shadow:
|
||||||
|
0 18px 42px rgba(3, 10, 24, 0.42),
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.08),
|
||||||
|
inset 0 0 0 1px rgba(41, 129, 210, 0.12);
|
||||||
|
color: #eef7ff;
|
||||||
|
overflow: hidden;
|
||||||
|
font-family: 'Rajdhani', 'DIN', 'Avenir Next', 'PingFang SC', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlay::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 14px;
|
||||||
|
right: 14px;
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(90deg, transparent 0%, rgba(134, 211, 255, 0.75) 50%, transparent 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.previewMode {
|
||||||
|
border-color: rgba(74, 196, 255, 0.42);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sailingMode {
|
||||||
|
border-color: rgba(255, 152, 108, 0.34);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header,
|
||||||
|
.progressCard,
|
||||||
|
.waypointList,
|
||||||
|
.footer {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.routeBlock {
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.caption {
|
||||||
|
font-size: 11px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: rgba(186, 223, 255, 0.62);
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.1;
|
||||||
|
color: #f3f9ff;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerMeta {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(202, 230, 255, 0.78);
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerMeta span {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusTag {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(28, 69, 104, 0.62);
|
||||||
|
border: 1px solid rgba(112, 191, 255, 0.24);
|
||||||
|
color: #dff4ff;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pulseDot {
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #49c7ff;
|
||||||
|
box-shadow: 0 0 0 0 rgba(73, 199, 255, 0.6);
|
||||||
|
animation: pulse 1.5s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0% {
|
||||||
|
transform: scale(0.85);
|
||||||
|
box-shadow: 0 0 0 0 rgba(73, 199, 255, 0.55);
|
||||||
|
}
|
||||||
|
70% {
|
||||||
|
transform: scale(1.05);
|
||||||
|
box-shadow: 0 0 0 8px rgba(73, 199, 255, 0);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: scale(0.85);
|
||||||
|
box-shadow: 0 0 0 0 rgba(73, 199, 255, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressCard {
|
||||||
|
margin-top: 14px;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: linear-gradient(145deg, rgba(19, 48, 77, 0.72) 0%, rgba(10, 24, 40, 0.86) 100%);
|
||||||
|
border: 1px solid rgba(104, 184, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressHead {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #dcefff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressBar {
|
||||||
|
margin-top: 10px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: rgba(198, 225, 250, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressFill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: inherit;
|
||||||
|
background: linear-gradient(90deg, #2c9bff 0%, #43eeff 55%, #87ffd4 100%);
|
||||||
|
box-shadow: 0 0 10px rgba(67, 238, 255, 0.46);
|
||||||
|
transition: width 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricRow {
|
||||||
|
margin-top: 12px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricItem {
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
border: 1px solid rgba(123, 186, 236, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricLabel {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: rgba(193, 224, 247, 0.68);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricValue {
|
||||||
|
display: block;
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #f4fbff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointList {
|
||||||
|
margin-top: 14px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
max-height: 290px;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointList::-webkit-scrollbar {
|
||||||
|
width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointList::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(180, 217, 255, 0.28);
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypointItem {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 10px;
|
||||||
|
min-height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trackColumn {
|
||||||
|
width: 24px;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconWrapper {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgba(8, 21, 36, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.passedIcon {
|
||||||
|
color: #78ffcf;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.currentIcon {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 2px solid #4ec8ff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-shadow: 0 0 10px rgba(78, 200, 255, 0.58);
|
||||||
|
}
|
||||||
|
|
||||||
|
.currentInner {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #4ec8ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upcomingIcon {
|
||||||
|
width: 11px;
|
||||||
|
height: 11px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 2px solid rgba(219, 235, 246, 0.36);
|
||||||
|
}
|
||||||
|
|
||||||
|
.connectingLine {
|
||||||
|
position: absolute;
|
||||||
|
top: 22px;
|
||||||
|
bottom: 0;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 2px;
|
||||||
|
background: rgba(224, 239, 255, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
|
.linePassed {
|
||||||
|
background: linear-gradient(180deg, #78ffcf 0%, rgba(120, 255, 207, 0.2) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lineCurrent {
|
||||||
|
background: linear-gradient(180deg, #55d0ff 0%, rgba(85, 208, 255, 0.2) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contentColumn {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 2px 0 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #edf7ff;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stateText {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
color: rgba(194, 223, 244, 0.72);
|
||||||
|
}
|
||||||
|
|
||||||
|
.itemPassed .name,
|
||||||
|
.itemPassed .stateText {
|
||||||
|
color: rgba(194, 214, 229, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.itemCurrent .contentColumn {
|
||||||
|
padding-left: 10px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: linear-gradient(90deg, rgba(62, 172, 244, 0.18) 0%, rgba(62, 172, 244, 0) 100%);
|
||||||
|
border-bottom-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.itemCurrent .stateText {
|
||||||
|
color: #7fdfff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.itemUpcoming .name {
|
||||||
|
color: rgba(224, 239, 255, 0.72);
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
margin-top: 10px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(206, 228, 246, 0.72);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 960px) {
|
||||||
|
.overlay {
|
||||||
|
width: calc(100% - 24px);
|
||||||
|
left: 12px;
|
||||||
|
top: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusTag {
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metricRow {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
import React, { useMemo } from 'react';
|
||||||
|
import {
|
||||||
|
CheckCircleFilled,
|
||||||
|
ClockCircleOutlined,
|
||||||
|
EnvironmentOutlined,
|
||||||
|
FlagOutlined,
|
||||||
|
RadarChartOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
type NavigationMode = 'preview' | 'sailing';
|
||||||
|
|
||||||
|
export interface NavigationOverlayProps {
|
||||||
|
mode: NavigationMode;
|
||||||
|
routeName: string;
|
||||||
|
waypoints: Array<{
|
||||||
|
name: string;
|
||||||
|
waypointIndex: number;
|
||||||
|
}>;
|
||||||
|
currentWaypointIndex: number;
|
||||||
|
totalDistance: number;
|
||||||
|
remainingDistance: number;
|
||||||
|
estimatedRemainingTime: number;
|
||||||
|
progress: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NavigationOverlay: React.FC<NavigationOverlayProps> = ({
|
||||||
|
mode,
|
||||||
|
routeName,
|
||||||
|
waypoints,
|
||||||
|
currentWaypointIndex,
|
||||||
|
totalDistance,
|
||||||
|
remainingDistance,
|
||||||
|
estimatedRemainingTime,
|
||||||
|
progress,
|
||||||
|
}) => {
|
||||||
|
const formatDistance = (m: number) => {
|
||||||
|
if (m >= 1000) {
|
||||||
|
return `${(m / 1000).toFixed(1)}km`;
|
||||||
|
}
|
||||||
|
return `${Math.round(m)}m`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatTime = (s: number) => {
|
||||||
|
const safeSeconds = Math.max(0, Math.floor(s));
|
||||||
|
const mins = Math.floor(safeSeconds / 60);
|
||||||
|
const secs = Math.floor(safeSeconds % 60);
|
||||||
|
if (mins >= 60) {
|
||||||
|
const hours = Math.floor(mins / 60);
|
||||||
|
const restMins = mins % 60;
|
||||||
|
return `${hours}时${restMins}分`;
|
||||||
|
}
|
||||||
|
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const safeProgress = Math.max(0, Math.min(100, progress));
|
||||||
|
const modeText = mode === 'preview' ? '预览态' : '航行中';
|
||||||
|
const completedCount = waypoints.filter((wp) => wp.waypointIndex < currentWaypointIndex).length;
|
||||||
|
|
||||||
|
// Get visible waypoints
|
||||||
|
const visibleWaypoints = useMemo(() => {
|
||||||
|
// Current waypoint logic: showing ±2 around current.
|
||||||
|
let start = Math.max(0, currentWaypointIndex - 2);
|
||||||
|
let end = Math.min(waypoints.length - 1, start + 4);
|
||||||
|
|
||||||
|
// Adjust start if we are near the end
|
||||||
|
if (end - start < 4) {
|
||||||
|
start = Math.max(0, end - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return waypoints.slice(start, end + 1);
|
||||||
|
}, [waypoints, currentWaypointIndex]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`${styles.overlay} ${mode === 'preview' ? styles.previewMode : styles.sailingMode}`}>
|
||||||
|
<div className={styles.header}>
|
||||||
|
<div className={styles.routeBlock}>
|
||||||
|
<div className={styles.caption}>导航总览</div>
|
||||||
|
<div className={styles.title}>{routeName || '未命名路线'}</div>
|
||||||
|
<div className={styles.headerMeta}>
|
||||||
|
<span><RadarChartOutlined /> 总里程 {formatDistance(totalDistance)}</span>
|
||||||
|
<span><FlagOutlined /> {waypoints.length} 航点</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.statusTag}>
|
||||||
|
<div className={styles.pulseDot} />
|
||||||
|
{modeText}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.progressCard}>
|
||||||
|
<div className={styles.progressHead}>
|
||||||
|
<span>路线进度</span>
|
||||||
|
<span>{Math.round(safeProgress)}%</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.progressBar}>
|
||||||
|
<div
|
||||||
|
className={styles.progressFill}
|
||||||
|
style={{ width: `${safeProgress}%` }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={styles.metricRow}>
|
||||||
|
<div className={styles.metricItem}>
|
||||||
|
<span className={styles.metricLabel}><EnvironmentOutlined /> 剩余</span>
|
||||||
|
<span className={styles.metricValue}>{formatDistance(remainingDistance)}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.metricItem}>
|
||||||
|
<span className={styles.metricLabel}><ClockCircleOutlined /> 预计</span>
|
||||||
|
<span className={styles.metricValue}>{formatTime(estimatedRemainingTime)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.waypointList}>
|
||||||
|
{visibleWaypoints.map((wp, i) => {
|
||||||
|
const isPassed = wp.waypointIndex < currentWaypointIndex;
|
||||||
|
const isCurrent = wp.waypointIndex === currentWaypointIndex;
|
||||||
|
const isUpcoming = wp.waypointIndex > currentWaypointIndex;
|
||||||
|
const isLastVisible = i === visibleWaypoints.length - 1;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`${wp.waypointIndex}-${wp.name}`}
|
||||||
|
className={[
|
||||||
|
styles.waypointItem,
|
||||||
|
isPassed ? styles.itemPassed : '',
|
||||||
|
isCurrent ? styles.itemCurrent : '',
|
||||||
|
isUpcoming ? styles.itemUpcoming : '',
|
||||||
|
].filter(Boolean).join(' ')}
|
||||||
|
>
|
||||||
|
<div className={styles.trackColumn}>
|
||||||
|
<div className={styles.iconWrapper}>
|
||||||
|
{isPassed && <CheckCircleFilled className={styles.passedIcon} />}
|
||||||
|
{isCurrent && (
|
||||||
|
<div className={styles.currentIcon}>
|
||||||
|
<div className={styles.currentInner} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{isUpcoming && <div className={styles.upcomingIcon} />}
|
||||||
|
</div>
|
||||||
|
{!isLastVisible && (
|
||||||
|
<div className={[
|
||||||
|
styles.connectingLine,
|
||||||
|
(isPassed && wp.waypointIndex < currentWaypointIndex - 1) ? styles.linePassed : '',
|
||||||
|
(isPassed && wp.waypointIndex === currentWaypointIndex - 1) ? styles.lineCurrent : '',
|
||||||
|
].filter(Boolean).join(' ')} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.contentColumn}>
|
||||||
|
<span className={styles.name}>{`${wp.waypointIndex + 1}. ${wp.name}`}</span>
|
||||||
|
<span className={styles.stateText}>{isCurrent ? '当前' : isPassed ? '已过' : '待达'}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.footer}>
|
||||||
|
<span>{`已通过 ${completedCount}/${waypoints.length} 航点`}</span>
|
||||||
|
<span>{`当前第 ${Math.max(1, currentWaypointIndex + 1)} 航点`}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default NavigationOverlay;
|
||||||
@@ -1,3 +1,15 @@
|
|||||||
|
/* ========== 玻璃拟态变量 ========== */
|
||||||
|
@glass-border: rgba(65, 170, 255, 0.28);
|
||||||
|
@glass-border-light: rgba(92, 211, 255, 0.18);
|
||||||
|
@accent-cyan: #00d4ff;
|
||||||
|
@accent-blue: #0096ff;
|
||||||
|
@text-primary: #eaf6ff;
|
||||||
|
@text-secondary: rgba(255, 255, 255, 0.55);
|
||||||
|
@text-dim: rgba(255, 255, 255, 0.4);
|
||||||
|
@card-bg: linear-gradient(145deg, rgba(10, 24, 48, 0.7), rgba(8, 18, 38, 0.5));
|
||||||
|
@card-shadow: 0 2px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||||
|
@transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -8,14 +20,39 @@
|
|||||||
|
|
||||||
.section {
|
.section {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
border-bottom: 1px solid rgba(0, 212, 255, 0.1);
|
border-bottom: 1px solid @glass-border-light;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
bottom: -1px;
|
||||||
|
left: 16px;
|
||||||
|
right: 16px;
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.15), transparent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sectionTitle {
|
.sectionTitle {
|
||||||
font-size: 14px;
|
font-size: 13px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: rgba(255, 255, 255, 0.9);
|
color: @text-secondary;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 14px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1.5px;
|
||||||
|
font-family: 'Rajdhani', 'DIN', sans-serif;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
width: 3px;
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 2px;
|
||||||
|
background: linear-gradient(180deg, @accent-cyan, @accent-blue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 罗盘 ========== */
|
/* ========== 罗盘 ========== */
|
||||||
@@ -23,13 +60,19 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 14px;
|
||||||
|
padding: 12px;
|
||||||
|
background: @card-bg;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(0, 100, 200, 0.15);
|
||||||
|
box-shadow: @card-shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
.compass {
|
.compass {
|
||||||
width: 180px;
|
width: 180px;
|
||||||
height: 180px;
|
height: 180px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
filter: drop-shadow(0 0 8px rgba(0, 150, 255, 0.15));
|
||||||
}
|
}
|
||||||
|
|
||||||
.compassSvg {
|
.compassSvg {
|
||||||
@@ -41,18 +84,24 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
margin-top: 4px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.headingLabel {
|
.headingLabel {
|
||||||
font-size: 12px;
|
font-size: 11px;
|
||||||
color: rgba(255, 255, 255, 0.5);
|
color: @text-dim;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-family: 'Rajdhani', 'DIN', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.headingValue {
|
.headingValue {
|
||||||
font-size: 22px;
|
font-size: 24px;
|
||||||
font-weight: bold;
|
font-weight: 700;
|
||||||
color: #0070d4;
|
color: @accent-cyan;
|
||||||
|
font-family: 'Rajdhani', 'DIN', monospace;
|
||||||
|
text-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
|
||||||
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 左转/右转 ========== */
|
/* ========== 左转/右转 ========== */
|
||||||
@@ -64,30 +113,34 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.turnBtn {
|
.turnBtn {
|
||||||
width: 48px;
|
width: 52px;
|
||||||
height: 36px;
|
height: 38px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
border-radius: 6px;
|
border-radius: 8px;
|
||||||
border: 1px solid rgba(0, 150, 220, 0.4);
|
border: 1px solid rgba(0, 150, 220, 0.35);
|
||||||
background: rgba(0, 60, 100, 0.35);
|
background: linear-gradient(145deg, rgba(0, 60, 120, 0.35), rgba(0, 40, 80, 0.25));
|
||||||
color: rgba(255, 255, 255, 0.8);
|
backdrop-filter: blur(6px);
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.15s;
|
transition: @transition-fast;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: rgba(0, 100, 160, 0.5);
|
background: linear-gradient(145deg, rgba(0, 80, 160, 0.5), rgba(0, 60, 120, 0.35));
|
||||||
border-color: rgba(0, 180, 255, 0.6);
|
border-color: rgba(0, 180, 255, 0.5);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
box-shadow: 0 2px 12px rgba(0, 100, 200, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
background: rgba(0, 130, 200, 0.7);
|
background: linear-gradient(145deg, rgba(0, 100, 200, 0.6), rgba(0, 80, 160, 0.45));
|
||||||
border-color: #00b4ff;
|
border-color: @accent-cyan;
|
||||||
transform: scale(0.95);
|
transform: scale(0.95);
|
||||||
|
box-shadow: 0 0 16px rgba(0, 180, 255, 0.3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,46 +150,58 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
padding: 0 4px;
|
padding: 10px 12px;
|
||||||
|
background: @card-bg;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid rgba(0, 100, 200, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
.speedLabel {
|
.speedLabel {
|
||||||
font-size: 12px;
|
font-size: 11px;
|
||||||
color: rgba(255, 255, 255, 0.5);
|
color: @text-dim;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
font-family: 'Rajdhani', 'DIN', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.speedSlider {
|
.speedSlider {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
:global(.ant-slider-rail) {
|
:global(.ant-slider-rail) {
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.ant-slider-track) {
|
:global(.ant-slider-track) {
|
||||||
background: #0070d4;
|
background: linear-gradient(90deg, @accent-blue, @accent-cyan);
|
||||||
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.ant-slider-handle)::after {
|
:global(.ant-slider-handle)::after {
|
||||||
box-shadow: 0 0 6px rgba(0, 112, 212, 0.6);
|
box-shadow: 0 0 8px rgba(0, 180, 255, 0.5);
|
||||||
|
border-color: @accent-cyan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.speedValue {
|
.speedValue {
|
||||||
font-size: 13px;
|
font-size: 14px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
color: #0070d4;
|
color: @accent-cyan;
|
||||||
|
font-family: 'Rajdhani', 'DIN', monospace;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
min-width: 60px;
|
min-width: 60px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 紧急停靠 ========== */
|
/* ========== 紧急停靠 ========== */
|
||||||
.emergencyBtn {
|
.emergencyBtn {
|
||||||
height: 42px;
|
height: 44px;
|
||||||
border-radius: 6px;
|
border-radius: 8px;
|
||||||
border: none;
|
border: 1px solid rgba(255, 60, 60, 0.4);
|
||||||
background: #d4380d;
|
background: linear-gradient(145deg, rgba(180, 30, 10, 0.7), rgba(140, 20, 5, 0.5));
|
||||||
|
backdrop-filter: blur(6px);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
@@ -145,62 +210,85 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s;
|
transition: @transition-fast;
|
||||||
letter-spacing: 2px;
|
letter-spacing: 2px;
|
||||||
|
box-shadow: 0 2px 12px rgba(180, 30, 10, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #e84820;
|
background: linear-gradient(145deg, rgba(200, 40, 15, 0.8), rgba(160, 30, 10, 0.6));
|
||||||
|
border-color: rgba(255, 80, 60, 0.5);
|
||||||
|
box-shadow: 0 4px 20px rgba(200, 40, 15, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
background: #cf1322;
|
background: linear-gradient(145deg, rgba(160, 20, 5, 0.8), rgba(120, 15, 0, 0.6));
|
||||||
transform: scale(0.98);
|
transform: scale(0.98);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========== 实时数据卡片 ========== */
|
/* ========== 实时数据卡片 ========== */
|
||||||
.dataCard {
|
.dataCard {
|
||||||
border-radius: 8px;
|
border-radius: 10px;
|
||||||
padding: 12px;
|
padding: 14px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
backdrop-filter: blur(6px);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
// 顶部高光线
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 10%;
|
||||||
|
right: 10%;
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
|
||||||
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 三级透明层次 */
|
/* 三级玻璃层次 */
|
||||||
.dataCardLevel1 {
|
.dataCardLevel1 {
|
||||||
background: rgba(0, 112, 212, 0.12);
|
background: linear-gradient(145deg, rgba(0, 80, 160, 0.18), rgba(0, 60, 120, 0.1));
|
||||||
border: 1px solid rgba(0, 112, 212, 0.25);
|
border: 1px solid rgba(0, 112, 212, 0.28);
|
||||||
|
box-shadow: @card-shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataCardLevel2 {
|
.dataCardLevel2 {
|
||||||
background: rgba(0, 180, 150, 0.08);
|
background: linear-gradient(145deg, rgba(0, 140, 120, 0.12), rgba(0, 100, 80, 0.06));
|
||||||
border: 1px solid rgba(0, 180, 150, 0.2);
|
border: 1px solid rgba(0, 180, 150, 0.22);
|
||||||
|
box-shadow: @card-shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataCardLevel3 {
|
.dataCardLevel3 {
|
||||||
background: rgba(0, 212, 255, 0.05);
|
background: linear-gradient(145deg, rgba(0, 160, 200, 0.1), rgba(0, 120, 160, 0.05));
|
||||||
border: 1px solid rgba(0, 212, 255, 0.15);
|
border: 1px solid rgba(0, 212, 255, 0.18);
|
||||||
|
box-shadow: @card-shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataCardHeader {
|
.dataCardHeader {
|
||||||
font-size: 12px;
|
font-size: 11px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
color: #0070d4;
|
color: @accent-blue;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 10px;
|
||||||
padding-bottom: 6px;
|
padding-bottom: 8px;
|
||||||
border-bottom: 1px solid rgba(0, 112, 212, 0.15);
|
border-bottom: 1px solid rgba(0, 112, 212, 0.15);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1.2px;
|
||||||
|
font-family: 'Rajdhani', 'DIN', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataCardHeaderGreen {
|
.dataCardHeaderGreen {
|
||||||
color: #00b496;
|
color: #00c8a0;
|
||||||
border-bottom-color: rgba(0, 180, 150, 0.15);
|
border-bottom-color: rgba(0, 200, 160, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataCardHeaderCyan {
|
.dataCardHeaderCyan {
|
||||||
color: #00a0cc;
|
color: @accent-cyan;
|
||||||
border-bottom-color: rgba(0, 212, 255, 0.12);
|
border-bottom-color: rgba(0, 212, 255, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,16 +296,19 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 4px 0;
|
padding: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataLabel {
|
.dataLabel {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: rgba(255, 255, 255, 0.45);
|
color: @text-dim;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataValue {
|
.dataValue {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: rgba(255, 255, 255, 0.9);
|
color: @text-primary;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
|
font-family: 'Rajdhani', 'DIN', monospace;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* 设备认证与登出逻辑
|
||||||
|
* 从 sessionStorage 读取设备信息,提供登出操作
|
||||||
|
*/
|
||||||
|
import { useEffect, useState, useCallback, useMemo } from 'react';
|
||||||
|
import { history } from 'umi';
|
||||||
|
import { Modal } from 'antd';
|
||||||
|
|
||||||
|
interface DeviceInfo {
|
||||||
|
deviceSn: string;
|
||||||
|
deviceName: string;
|
||||||
|
deviceType: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UseClientAuthReturn {
|
||||||
|
deviceSn: string;
|
||||||
|
deviceInfo: DeviceInfo | null;
|
||||||
|
handleLogout: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useClientAuth(onBeforeLogout?: () => void): UseClientAuthReturn {
|
||||||
|
const [deviceInfo, setDeviceInfo] = useState<DeviceInfo | null>(null);
|
||||||
|
const deviceSn = useMemo(() => sessionStorage.getItem('client_device_sn') || '', []);
|
||||||
|
|
||||||
|
// 校验登录状态
|
||||||
|
useEffect(() => {
|
||||||
|
const sn = sessionStorage.getItem('client_device_sn');
|
||||||
|
const info = sessionStorage.getItem('client_device_info');
|
||||||
|
if (!sn || !info) {
|
||||||
|
history.push('/client/login');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
setDeviceInfo(JSON.parse(info));
|
||||||
|
} catch {
|
||||||
|
history.push('/client/login');
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleLogout = useCallback(() => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认退出',
|
||||||
|
content: '退出后需要重新输入设备SN登录',
|
||||||
|
okText: '退出',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
onBeforeLogout?.();
|
||||||
|
sessionStorage.removeItem('client_device_sn');
|
||||||
|
sessionStorage.removeItem('client_device_info');
|
||||||
|
history.push('/client/login');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, [onBeforeLogout]);
|
||||||
|
|
||||||
|
return { deviceSn, deviceInfo, handleLogout };
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/**
|
||||||
|
* 模拟遥测数据生成
|
||||||
|
* SSE 未连接时自动生成模拟船只遥测数据
|
||||||
|
*/
|
||||||
|
import { useEffect, useState, useCallback, useRef } from 'react';
|
||||||
|
import type { BoatTelemetryData } from '@/types/boatRoute';
|
||||||
|
|
||||||
|
/** 生成一帧模拟遥测 */
|
||||||
|
const createMockTelemetry = (
|
||||||
|
deviceSn: string,
|
||||||
|
prevData?: BoatTelemetryData | null,
|
||||||
|
initLon?: number,
|
||||||
|
initLat?: number,
|
||||||
|
): BoatTelemetryData => {
|
||||||
|
const baseLon = prevData?.longitude ?? initLon ?? 108.366;
|
||||||
|
const baseLat = prevData?.latitude ?? initLat ?? 22.817;
|
||||||
|
const baseHeading = prevData?.heading ?? 45;
|
||||||
|
|
||||||
|
const headingRad = (baseHeading + (Math.random() - 0.5) * 10) * Math.PI / 180;
|
||||||
|
const moveDistance = 0.00002 + Math.random() * 0.00003;
|
||||||
|
const newLon = baseLon + Math.cos(headingRad) * moveDistance;
|
||||||
|
const newLat = baseLat + Math.sin(headingRad) * moveDistance;
|
||||||
|
const newHeading = ((baseHeading + (Math.random() - 0.5) * 10) + 360) % 360;
|
||||||
|
|
||||||
|
return {
|
||||||
|
deviceSn,
|
||||||
|
longitude: newLon,
|
||||||
|
latitude: newLat,
|
||||||
|
heading: Number(newHeading.toFixed(1)),
|
||||||
|
speed: Number((1.5 + Math.random() * 2).toFixed(1)),
|
||||||
|
battery: Math.max(20, (prevData?.battery ?? 85) - Math.random() * 0.1),
|
||||||
|
signalStrength: 60 + Math.floor(Math.random() * 30),
|
||||||
|
status: '巡航中',
|
||||||
|
recordTime: new Date().toISOString(),
|
||||||
|
taskId: undefined,
|
||||||
|
currentWaypointIndex: undefined,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
interface UseMockTelemetryReturn {
|
||||||
|
/** 合并后的遥测数据(SSE 优先,回退到模拟) */
|
||||||
|
boatData: BoatTelemetryData | null;
|
||||||
|
/** 模型中心位���回调,���于重置模拟数据起点 */
|
||||||
|
handleModelCenter: (lon: number, lat: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useMockTelemetry(
|
||||||
|
deviceSn: string,
|
||||||
|
sseBoatData: BoatTelemetryData | null,
|
||||||
|
): UseMockTelemetryReturn {
|
||||||
|
const [mockBoatData, setMockBoatData] = useState<BoatTelemetryData | null>(null);
|
||||||
|
const mockTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
const mockDataRef = useRef<BoatTelemetryData | null>(null);
|
||||||
|
const modelCenterRef = useRef<{ lon: number; lat: number } | null>(null);
|
||||||
|
|
||||||
|
const handleModelCenter = useCallback((lon: number, lat: number) => {
|
||||||
|
modelCenterRef.current = { lon, lat };
|
||||||
|
if (mockDataRef.current) {
|
||||||
|
const newData = {
|
||||||
|
...mockDataRef.current,
|
||||||
|
longitude: lon + (Math.random() - 0.5) * 0.001,
|
||||||
|
latitude: lat + (Math.random() - 0.5) * 0.001,
|
||||||
|
};
|
||||||
|
mockDataRef.current = newData;
|
||||||
|
setMockBoatData(newData);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// 有真实 SSE 数据时停止模拟
|
||||||
|
if (sseBoatData) {
|
||||||
|
if (mockTimerRef.current) {
|
||||||
|
clearInterval(mockTimerRef.current);
|
||||||
|
mockTimerRef.current = null;
|
||||||
|
}
|
||||||
|
setMockBoatData(null);
|
||||||
|
mockDataRef.current = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 无真实数据且无模拟定时器,启动模拟
|
||||||
|
if (!mockTimerRef.current && deviceSn) {
|
||||||
|
const center = modelCenterRef.current;
|
||||||
|
const firstData = createMockTelemetry(deviceSn, null, center?.lon, center?.lat);
|
||||||
|
mockDataRef.current = firstData;
|
||||||
|
setMockBoatData(firstData);
|
||||||
|
|
||||||
|
mockTimerRef.current = setInterval(() => {
|
||||||
|
const center2 = modelCenterRef.current;
|
||||||
|
const newData = createMockTelemetry(deviceSn, mockDataRef.current, center2?.lon, center2?.lat);
|
||||||
|
mockDataRef.current = newData;
|
||||||
|
setMockBoatData(newData);
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (mockTimerRef.current) {
|
||||||
|
clearInterval(mockTimerRef.current);
|
||||||
|
mockTimerRef.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [sseBoatData, deviceSn]);
|
||||||
|
|
||||||
|
const boatData = sseBoatData || mockBoatData;
|
||||||
|
|
||||||
|
return { boatData, handleModelCenter };
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
* 导航计算
|
||||||
|
* 根据当前遥测数据和航线信息,计算 HUD / Overlay 所需的导航指标
|
||||||
|
*/
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
import type { BoatRouteListVO, BoatTelemetryData, BoatWaypointVO } from '@/types/boatRoute';
|
||||||
|
|
||||||
|
interface NextWaypoint {
|
||||||
|
name: string;
|
||||||
|
distance: number;
|
||||||
|
estimatedTime: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NavigationDataResult {
|
||||||
|
/** 当前激活航线的航点列表 */
|
||||||
|
activeWaypoints: BoatWaypointVO[];
|
||||||
|
/** 当前激活航线的基本信息 */
|
||||||
|
activeRouteInfo: BoatRouteListVO | null;
|
||||||
|
/** 下一航点信息 */
|
||||||
|
nextWaypoint: NextWaypoint | undefined;
|
||||||
|
/** 剩余距离(米) */
|
||||||
|
remainingDistance: number;
|
||||||
|
/** 预计剩余时间(秒) */
|
||||||
|
estimatedRemainingTime: number;
|
||||||
|
/** 进度百分比 0-100 */
|
||||||
|
progress: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useNavigationData(
|
||||||
|
activeRouteId: string | null,
|
||||||
|
routes: BoatRouteListVO[],
|
||||||
|
routeWaypointsMap: Record<string, BoatWaypointVO[]>,
|
||||||
|
boatData: BoatTelemetryData | null,
|
||||||
|
currentWaypointIndex: number,
|
||||||
|
): NavigationDataResult {
|
||||||
|
const activeWaypoints = useMemo(() => {
|
||||||
|
if (!activeRouteId) return [];
|
||||||
|
return routeWaypointsMap[activeRouteId] || [];
|
||||||
|
}, [activeRouteId, routeWaypointsMap]);
|
||||||
|
|
||||||
|
const activeRouteInfo = useMemo(() => {
|
||||||
|
if (!activeRouteId) return null;
|
||||||
|
return routes.find((r) => r.routeId === activeRouteId) || null;
|
||||||
|
}, [activeRouteId, routes]);
|
||||||
|
|
||||||
|
const { nextWaypoint, remainingDistance, estimatedRemainingTime, progress } = useMemo(() => {
|
||||||
|
if (!activeWaypoints.length || !boatData) {
|
||||||
|
return { nextWaypoint: undefined, remainingDistance: 0, estimatedRemainingTime: 0, progress: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
const wpIdx = boatData.currentWaypointIndex ?? currentWaypointIndex;
|
||||||
|
const nextIdx = Math.min(wpIdx + 1, activeWaypoints.length - 1);
|
||||||
|
const nextWp = activeWaypoints[nextIdx];
|
||||||
|
|
||||||
|
// Haversine 距离计算
|
||||||
|
const R = 6371000;
|
||||||
|
const dLat = ((nextWp?.latitude ?? 0) - (boatData.latitude ?? 0)) * Math.PI / 180;
|
||||||
|
const dLon = ((nextWp?.longitude ?? 0) - (boatData.longitude ?? 0)) * Math.PI / 180;
|
||||||
|
const a = Math.sin(dLat / 2) ** 2 +
|
||||||
|
Math.cos((boatData.latitude ?? 0) * Math.PI / 180) *
|
||||||
|
Math.cos((nextWp?.latitude ?? 0) * Math.PI / 180) *
|
||||||
|
Math.sin(dLon / 2) ** 2;
|
||||||
|
const distToNext = R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||||
|
|
||||||
|
const totalDist = activeRouteInfo?.totalDistance ?? 1;
|
||||||
|
const prog = Math.min(100, Math.round((wpIdx / Math.max(1, activeWaypoints.length - 1)) * 100));
|
||||||
|
const remainDist = totalDist * (1 - prog / 100);
|
||||||
|
const estTime = boatData.speed > 0 ? remainDist / boatData.speed : 0;
|
||||||
|
|
||||||
|
return {
|
||||||
|
nextWaypoint: nextWp ? {
|
||||||
|
name: nextWp.pointName || `航点${nextIdx + 1}`,
|
||||||
|
distance: Math.round(distToNext),
|
||||||
|
estimatedTime: Math.round(boatData.speed > 0 ? distToNext / boatData.speed : 0),
|
||||||
|
} : undefined,
|
||||||
|
remainingDistance: Math.round(remainDist),
|
||||||
|
estimatedRemainingTime: Math.round(estTime),
|
||||||
|
progress: prog,
|
||||||
|
};
|
||||||
|
}, [activeWaypoints, boatData, currentWaypointIndex, activeRouteInfo]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeWaypoints,
|
||||||
|
activeRouteInfo,
|
||||||
|
nextWaypoint,
|
||||||
|
remainingDistance,
|
||||||
|
estimatedRemainingTime,
|
||||||
|
progress,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
/**
|
||||||
|
* 沉浸模式状态机
|
||||||
|
* 管理 sailing / preview / idle 三态切换及相关操作回调
|
||||||
|
*/
|
||||||
|
import { useState, useCallback } from 'react';
|
||||||
|
import { Modal, message } from 'antd';
|
||||||
|
import { sendBoatCommand } from '../services/clientApi';
|
||||||
|
|
||||||
|
type ActiveRouteMode = 'sailing' | 'preview' | null;
|
||||||
|
|
||||||
|
interface ActiveRouteState {
|
||||||
|
mode: ActiveRouteMode;
|
||||||
|
routeId: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UseNavigationStateReturn {
|
||||||
|
activeRoute: ActiveRouteState;
|
||||||
|
isPaused: boolean;
|
||||||
|
currentWaypointIndex: number;
|
||||||
|
previewStopSignal: number;
|
||||||
|
isSailing: boolean;
|
||||||
|
isPreviewing: boolean;
|
||||||
|
isImmersive: boolean;
|
||||||
|
activeRouteId: string | null;
|
||||||
|
handleStartSailing: (routeId: string) => void;
|
||||||
|
handlePauseSailing: () => void;
|
||||||
|
handleResumeSailing: () => void;
|
||||||
|
handleStopSailing: () => void;
|
||||||
|
handleStopPreview: () => void;
|
||||||
|
handleEmergencyStop: () => void;
|
||||||
|
handlePreviewChange: (previewing: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useNavigationState(
|
||||||
|
deviceSn: string,
|
||||||
|
selectedRouteId: string | null,
|
||||||
|
setSelectedRouteId: (id: string | null) => void,
|
||||||
|
): UseNavigationStateReturn {
|
||||||
|
const [activeRoute, setActiveRoute] = useState<ActiveRouteState>({ mode: null, routeId: null });
|
||||||
|
const [isPaused, setIsPaused] = useState(false);
|
||||||
|
const [currentWaypointIndex, setCurrentWaypointIndex] = useState(0);
|
||||||
|
const [previewStopSignal, setPreviewStopSignal] = useState(0);
|
||||||
|
|
||||||
|
const isSailing = activeRoute.mode === 'sailing';
|
||||||
|
const isPreviewing = activeRoute.mode === 'preview';
|
||||||
|
const isImmersive = activeRoute.mode !== null;
|
||||||
|
const activeRouteId = activeRoute.routeId;
|
||||||
|
|
||||||
|
const handleStartSailing = useCallback((routeId: string) => {
|
||||||
|
if (activeRoute.mode === 'preview') {
|
||||||
|
setPreviewStopSignal((prev) => prev + 1);
|
||||||
|
}
|
||||||
|
setActiveRoute({ mode: 'sailing', routeId });
|
||||||
|
setSelectedRouteId(routeId);
|
||||||
|
setIsPaused(false);
|
||||||
|
setCurrentWaypointIndex(0);
|
||||||
|
}, [activeRoute.mode, setSelectedRouteId]);
|
||||||
|
|
||||||
|
const handlePauseSailing = useCallback(() => {
|
||||||
|
if (!isSailing) return;
|
||||||
|
setIsPaused(true);
|
||||||
|
sendBoatCommand(deviceSn, 'pause', 'press').catch(() => {
|
||||||
|
message.error('暂停指令发送失败');
|
||||||
|
});
|
||||||
|
}, [deviceSn, isSailing]);
|
||||||
|
|
||||||
|
const handleResumeSailing = useCallback(() => {
|
||||||
|
if (!isSailing) return;
|
||||||
|
setIsPaused(false);
|
||||||
|
sendBoatCommand(deviceSn, 'resume', 'press').catch(() => {
|
||||||
|
message.error('继续指令发送失败');
|
||||||
|
});
|
||||||
|
}, [deviceSn, isSailing]);
|
||||||
|
|
||||||
|
const handleStopSailing = useCallback(() => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认结束航行',
|
||||||
|
content: '结束后将退��导航模式,返回线路选择',
|
||||||
|
okText: '结束航行',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
setActiveRoute({ mode: null, routeId: null });
|
||||||
|
setIsPaused(false);
|
||||||
|
setCurrentWaypointIndex(0);
|
||||||
|
sendBoatCommand(deviceSn, 'stop', 'press').catch(() => {});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, [deviceSn]);
|
||||||
|
|
||||||
|
const handleStopPreview = useCallback(() => {
|
||||||
|
setPreviewStopSignal((prev) => prev + 1);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleEmergencyStop = useCallback(() => {
|
||||||
|
setActiveRoute({ mode: null, routeId: null });
|
||||||
|
setIsPaused(false);
|
||||||
|
setCurrentWaypointIndex(0);
|
||||||
|
sendBoatCommand(deviceSn, 'stop', 'press').catch(() => {
|
||||||
|
message.error('紧急停靠指令发送失败');
|
||||||
|
});
|
||||||
|
message.warning('已执行紧急停靠');
|
||||||
|
}, [deviceSn]);
|
||||||
|
|
||||||
|
const handlePreviewChange = useCallback((previewing: boolean) => {
|
||||||
|
setActiveRoute((prev) => {
|
||||||
|
if (previewing) {
|
||||||
|
if (prev.mode === 'sailing') return prev;
|
||||||
|
const nextRouteId = selectedRouteId ?? prev.routeId;
|
||||||
|
if (!nextRouteId) return prev;
|
||||||
|
return { mode: 'preview', routeId: nextRouteId };
|
||||||
|
}
|
||||||
|
if (prev.mode === 'preview') {
|
||||||
|
return { mode: null, routeId: null };
|
||||||
|
}
|
||||||
|
return prev;
|
||||||
|
});
|
||||||
|
}, [selectedRouteId]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeRoute,
|
||||||
|
isPaused,
|
||||||
|
currentWaypointIndex,
|
||||||
|
previewStopSignal,
|
||||||
|
isSailing,
|
||||||
|
isPreviewing,
|
||||||
|
isImmersive,
|
||||||
|
activeRouteId,
|
||||||
|
handleStartSailing,
|
||||||
|
handlePauseSailing,
|
||||||
|
handleResumeSailing,
|
||||||
|
handleStopSailing,
|
||||||
|
handleStopPreview,
|
||||||
|
handleEmergencyStop,
|
||||||
|
handlePreviewChange,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* 航线列表加载 + 航点详情预加载
|
||||||
|
*/
|
||||||
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import { getClientRoutes } from '../services/clientApi';
|
||||||
|
import { getBoatRouteDetail } from '@/services/boatRoute';
|
||||||
|
import type { BoatRouteListVO, BoatWaypointVO } from '@/types/boatRoute';
|
||||||
|
|
||||||
|
interface UseRouteDataReturn {
|
||||||
|
routes: BoatRouteListVO[];
|
||||||
|
routeWaypointsMap: Record<string, BoatWaypointVO[]>;
|
||||||
|
selectedRouteId: string | null;
|
||||||
|
setSelectedRouteId: (id: string | null) => void;
|
||||||
|
routeLoading: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRouteData(deviceSn: string): UseRouteDataReturn {
|
||||||
|
const [routes, setRoutes] = useState<BoatRouteListVO[]>([]);
|
||||||
|
const [routeWaypointsMap, setRouteWaypointsMap] = useState<Record<string, BoatWaypointVO[]>>({});
|
||||||
|
const [selectedRouteId, setSelectedRouteId] = useState<string | null>(null);
|
||||||
|
const [routeLoading, setRouteLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!deviceSn) return;
|
||||||
|
setRouteLoading(true);
|
||||||
|
getClientRoutes(deviceSn)
|
||||||
|
.then(async (res) => {
|
||||||
|
const routeList = res.data;
|
||||||
|
if (res.resp_code === 0 && routeList && routeList.length > 0) {
|
||||||
|
setRoutes(routeList);
|
||||||
|
// 并行预加载所有线路的航点详情
|
||||||
|
const detailResults = await Promise.allSettled(
|
||||||
|
routeList.map((r) => getBoatRouteDetail(r.routeId)),
|
||||||
|
);
|
||||||
|
const wpMap: Record<string, BoatWaypointVO[]> = {};
|
||||||
|
detailResults.forEach((result, idx) => {
|
||||||
|
if (result.status === 'fulfilled' && result.value.resp_code === 0 && result.value.data?.waypoints) {
|
||||||
|
wpMap[routeList[idx].routeId] = result.value.data.waypoints;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setRouteWaypointsMap(wpMap);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => message.error('线路加载失败'))
|
||||||
|
.finally(() => setRouteLoading(false));
|
||||||
|
}, [deviceSn]);
|
||||||
|
|
||||||
|
return { routes, routeWaypointsMap, selectedRouteId, setSelectedRouteId, routeLoading };
|
||||||
|
}
|
||||||
@@ -1,51 +1,132 @@
|
|||||||
|
/* ========== 全局变量 ========== */
|
||||||
|
@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);
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
background: #0a1628;
|
background: #060e1a;
|
||||||
color: #fff;
|
color: @text-primary;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.leftPanel {
|
.leftPanel {
|
||||||
width: 280px;
|
width: 290px;
|
||||||
height: calc(100vh - 36px);
|
height: calc(100vh - 40px);
|
||||||
background: rgba(15, 25, 40, 0.95);
|
background: @glass-bg;
|
||||||
border-right: 1px solid rgba(0, 212, 255, 0.15);
|
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;
|
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 {
|
.centerView {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: calc(100vh - 36px);
|
height: calc(100vh - 40px);
|
||||||
position: relative;
|
position: relative;
|
||||||
|
transition: @transition-smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rightPanel {
|
.rightPanel {
|
||||||
width: 320px;
|
width: 320px;
|
||||||
height: calc(100vh - 36px);
|
height: calc(100vh - 40px);
|
||||||
background: rgba(15, 25, 40, 0.95);
|
background: @glass-bg;
|
||||||
border-left: 1px solid rgba(0, 212, 255, 0.15);
|
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;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========== 沉浸模式 ========== */
|
||||||
|
.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 {
|
.statusBar {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
height: 36px;
|
height: 40px;
|
||||||
background: rgba(10, 18, 32, 0.95);
|
background: linear-gradient(180deg, rgba(7, 16, 32, 0.92), rgba(5, 12, 24, 0.96));
|
||||||
border-top: 1px solid rgba(0, 212, 255, 0.15);
|
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 16px;
|
padding: 0 20px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: rgba(255, 255, 255, 0.6);
|
color: @text-secondary;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
transition: @transition-smooth;
|
||||||
|
font-family: 'Rajdhani', 'DIN', 'Roboto Mono', monospace;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.statusDot {
|
.statusDot {
|
||||||
@@ -54,18 +135,29 @@
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
box-shadow: 0 0 6px currentColor;
|
||||||
|
animation: statusPulse 2s ease-in-out infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 滚动条样式 */
|
@keyframes statusPulse {
|
||||||
|
0%, 100% { opacity: 1; }
|
||||||
|
50% { opacity: 0.5; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========== 滚动条 ========== */
|
||||||
.leftPanel::-webkit-scrollbar,
|
.leftPanel::-webkit-scrollbar,
|
||||||
.rightPanel::-webkit-scrollbar {
|
.rightPanel::-webkit-scrollbar {
|
||||||
width: 4px;
|
width: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.leftPanel::-webkit-scrollbar-thumb,
|
.leftPanel::-webkit-scrollbar-thumb,
|
||||||
.rightPanel::-webkit-scrollbar-thumb {
|
.rightPanel::-webkit-scrollbar-thumb {
|
||||||
background: rgba(0, 212, 255, 0.3);
|
background: rgba(0, 212, 255, 0.25);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(0, 212, 255, 0.4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.leftPanel::-webkit-scrollbar-track,
|
.leftPanel::-webkit-scrollbar-track,
|
||||||
|
|||||||
@@ -1,181 +1,62 @@
|
|||||||
import React, { useEffect, useState, useMemo, useCallback, useRef } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { history } from 'umi';
|
import { ConfigProvider, Button } from 'antd';
|
||||||
import { ConfigProvider, message, Button, Modal } from 'antd';
|
|
||||||
import { LogoutOutlined } from '@ant-design/icons';
|
import { LogoutOutlined } 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 RightPanel from './components/RightPanel';
|
||||||
|
import NavigationHUD from './components/NavigationHUD';
|
||||||
|
import NavigationOverlay from './components/NavigationOverlay';
|
||||||
|
import EmergencyButton from './components/EmergencyButton';
|
||||||
|
import { useClientAuth } from './hooks/useClientAuth';
|
||||||
import { useClientSSE } from './hooks/useClientSSE';
|
import { useClientSSE } from './hooks/useClientSSE';
|
||||||
import { getClientRoutes } from './services/clientApi';
|
import { useRouteData } from './hooks/useRouteData';
|
||||||
import { getBoatRouteDetail } from '@/services/boatRoute';
|
import { useMockTelemetry } from './hooks/useMockTelemetry';
|
||||||
import type { BoatRouteListVO, BoatTelemetryData, BoatWaypointVO } from '@/types/boatRoute';
|
import { useNavigationState } from './hooks/useNavigationState';
|
||||||
|
import { useNavigationData } from './hooks/useNavigationData';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
// 模拟遥测数据生成器
|
|
||||||
const createMockTelemetry = (deviceSn: string, prevData?: BoatTelemetryData | null, initLon?: number, initLat?: number): BoatTelemetryData => {
|
|
||||||
// 使用传入的初始位置,或者前次位置,或默认位置
|
|
||||||
const baseLon = prevData?.longitude ?? initLon ?? 108.366;
|
|
||||||
const baseLat = prevData?.latitude ?? initLat ?? 22.817;
|
|
||||||
const baseHeading = prevData?.heading ?? 45;
|
|
||||||
|
|
||||||
// 模拟船只缓慢移动
|
|
||||||
const headingRad = (baseHeading + (Math.random() - 0.5) * 10) * Math.PI / 180;
|
|
||||||
const moveDistance = 0.00002 + Math.random() * 0.00003; // ~2-5m
|
|
||||||
const newLon = baseLon + Math.cos(headingRad) * moveDistance;
|
|
||||||
const newLat = baseLat + Math.sin(headingRad) * moveDistance;
|
|
||||||
const newHeading = ((baseHeading + (Math.random() - 0.5) * 10) + 360) % 360;
|
|
||||||
|
|
||||||
return {
|
|
||||||
deviceSn,
|
|
||||||
longitude: newLon,
|
|
||||||
latitude: newLat,
|
|
||||||
heading: Number(newHeading.toFixed(1)),
|
|
||||||
speed: Number((1.5 + Math.random() * 2).toFixed(1)),
|
|
||||||
battery: Math.max(20, (prevData?.battery ?? 85) - Math.random() * 0.1),
|
|
||||||
signalStrength: 60 + Math.floor(Math.random() * 30),
|
|
||||||
status: '巡航中',
|
|
||||||
recordTime: new Date().toISOString(),
|
|
||||||
taskId: undefined,
|
|
||||||
currentWaypointIndex: undefined,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const ClientPage: React.FC = () => {
|
const ClientPage: React.FC = () => {
|
||||||
const [deviceInfo, setDeviceInfo] = useState<any>(null);
|
// ── 认证 ──
|
||||||
const [routes, setRoutes] = useState<BoatRouteListVO[]>([]);
|
|
||||||
const [routeWaypointsMap, setRouteWaypointsMap] = useState<Record<string, BoatWaypointVO[]>>({});
|
|
||||||
const [selectedRouteId, setSelectedRouteId] = useState<string | null>(null);
|
|
||||||
const [routeLoading, setRouteLoading] = useState(false);
|
|
||||||
|
|
||||||
const { boatData: sseBoatData, sseConnected, connectSSE, disconnectSSE } = useClientSSE();
|
const { boatData: sseBoatData, sseConnected, connectSSE, disconnectSSE } = useClientSSE();
|
||||||
|
const { deviceSn, deviceInfo, handleLogout } = useClientAuth(disconnectSSE);
|
||||||
|
|
||||||
const deviceSn = useMemo(() => sessionStorage.getItem('client_device_sn') || '', []);
|
// ── 航线数据 ──
|
||||||
|
const { routes, routeWaypointsMap, selectedRouteId, setSelectedRouteId, routeLoading } =
|
||||||
|
useRouteData(deviceSn);
|
||||||
|
|
||||||
// 模拟数据:SSE未连接时自动生成模拟遥测数据
|
// ── 模拟遥测 ──
|
||||||
const [mockBoatData, setMockBoatData] = useState<BoatTelemetryData | null>(null);
|
const { boatData, handleModelCenter } = useMockTelemetry(deviceSn, sseBoatData);
|
||||||
const mockTimerRef = useRef<NodeJS.Timeout | null>(null);
|
|
||||||
const mockDataRef = useRef<BoatTelemetryData | null>(null);
|
|
||||||
const modelCenterRef = useRef<{ lon: number; lat: number } | null>(null);
|
|
||||||
|
|
||||||
// 模型中心位置回调:当模型加载完成后,重置模拟数据起始位置到模型附近
|
// ── 沉浸模式状态机 ──
|
||||||
const handleModelCenter = useCallback((lon: number, lat: number) => {
|
const {
|
||||||
modelCenterRef.current = { lon, lat };
|
isPaused,
|
||||||
// 立即重置当前模拟数据位置到模型中心附近
|
currentWaypointIndex,
|
||||||
if (mockDataRef.current) {
|
previewStopSignal,
|
||||||
const newData = {
|
isSailing,
|
||||||
...mockDataRef.current,
|
isPreviewing,
|
||||||
longitude: lon + (Math.random() - 0.5) * 0.001,
|
isImmersive,
|
||||||
latitude: lat + (Math.random() - 0.5) * 0.001,
|
activeRouteId,
|
||||||
};
|
handleStartSailing,
|
||||||
mockDataRef.current = newData;
|
handlePauseSailing,
|
||||||
setMockBoatData(newData);
|
handleResumeSailing,
|
||||||
}
|
handleStopSailing,
|
||||||
}, []);
|
handleStopPreview,
|
||||||
|
handleEmergencyStop,
|
||||||
|
handlePreviewChange,
|
||||||
|
} = useNavigationState(deviceSn, selectedRouteId, setSelectedRouteId);
|
||||||
|
|
||||||
// 启动/停止模拟数据:当真实SSE数据到达时停止模拟,否则持续模拟
|
// ── 导航计算 ──
|
||||||
useEffect(() => {
|
const {
|
||||||
// 有真实SSE数据,停止模拟
|
activeWaypoints,
|
||||||
if (sseBoatData) {
|
activeRouteInfo,
|
||||||
if (mockTimerRef.current) {
|
nextWaypoint,
|
||||||
clearInterval(mockTimerRef.current);
|
remainingDistance,
|
||||||
mockTimerRef.current = null;
|
estimatedRemainingTime,
|
||||||
}
|
progress,
|
||||||
setMockBoatData(null);
|
} = useNavigationData(activeRouteId, routes, routeWaypointsMap, boatData, currentWaypointIndex);
|
||||||
mockDataRef.current = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 无真实数据且无模拟定时器,启动模拟
|
// ── SSE 连接 ──
|
||||||
if (!mockTimerRef.current && deviceSn) {
|
|
||||||
console.log('[Mock] 启动模拟数据');
|
|
||||||
// 立即生成第一帧
|
|
||||||
const center = modelCenterRef.current;
|
|
||||||
const firstData = createMockTelemetry(deviceSn, null, center?.lon, center?.lat);
|
|
||||||
mockDataRef.current = firstData;
|
|
||||||
setMockBoatData(firstData);
|
|
||||||
|
|
||||||
mockTimerRef.current = setInterval(() => {
|
|
||||||
const center2 = modelCenterRef.current;
|
|
||||||
const newData = createMockTelemetry(
|
|
||||||
deviceSn,
|
|
||||||
mockDataRef.current,
|
|
||||||
center2?.lon,
|
|
||||||
center2?.lat,
|
|
||||||
);
|
|
||||||
mockDataRef.current = newData;
|
|
||||||
setMockBoatData(newData);
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
if (mockTimerRef.current) {
|
|
||||||
clearInterval(mockTimerRef.current);
|
|
||||||
mockTimerRef.current = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, [sseBoatData, deviceSn]);
|
|
||||||
|
|
||||||
// 优先使用真实SSE数据,回退到模拟数据
|
|
||||||
const boatData = sseBoatData || mockBoatData;
|
|
||||||
|
|
||||||
// 退出登录
|
|
||||||
const handleLogout = useCallback(() => {
|
|
||||||
Modal.confirm({
|
|
||||||
title: '确认退出',
|
|
||||||
content: '退出后需要重新输入设备SN登录',
|
|
||||||
okText: '退出',
|
|
||||||
cancelText: '取消',
|
|
||||||
onOk: () => {
|
|
||||||
disconnectSSE();
|
|
||||||
sessionStorage.removeItem('client_device_sn');
|
|
||||||
sessionStorage.removeItem('client_device_info');
|
|
||||||
history.push('/client/login');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, [disconnectSSE]);
|
|
||||||
|
|
||||||
// 校验登录状态
|
|
||||||
useEffect(() => {
|
|
||||||
const sn = sessionStorage.getItem('client_device_sn');
|
|
||||||
const info = sessionStorage.getItem('client_device_info');
|
|
||||||
if (!sn || !info) {
|
|
||||||
history.push('/client/login');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
setDeviceInfo(JSON.parse(info));
|
|
||||||
} catch {
|
|
||||||
history.push('/client/login');
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// 加载游览线路列表 + 预加载航点详情
|
|
||||||
useEffect(() => {
|
|
||||||
if (!deviceSn) return;
|
|
||||||
setRouteLoading(true);
|
|
||||||
getClientRoutes(deviceSn)
|
|
||||||
.then(async (res) => {
|
|
||||||
if (res.resp_code === 0 && res.data) {
|
|
||||||
setRoutes(res.data);
|
|
||||||
// 并行预加载所有线路的航点详情
|
|
||||||
const detailResults = await Promise.allSettled(
|
|
||||||
res.data.map((r) => getBoatRouteDetail(r.routeId)),
|
|
||||||
);
|
|
||||||
const wpMap: Record<string, BoatWaypointVO[]> = {};
|
|
||||||
detailResults.forEach((result, idx) => {
|
|
||||||
if (result.status === 'fulfilled' && result.value.resp_code === 0 && result.value.data?.waypoints) {
|
|
||||||
wpMap[res.data[idx].routeId] = result.value.data.waypoints;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setRouteWaypointsMap(wpMap);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => message.error('线路加载失败'))
|
|
||||||
.finally(() => setRouteLoading(false));
|
|
||||||
}, [deviceSn]);
|
|
||||||
|
|
||||||
// 连接SSE
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!deviceSn) return;
|
if (!deviceSn) return;
|
||||||
connectSSE(deviceSn);
|
connectSSE(deviceSn);
|
||||||
@@ -184,9 +65,10 @@ const ClientPage: React.FC = () => {
|
|||||||
|
|
||||||
if (!deviceInfo) return null;
|
if (!deviceInfo) return null;
|
||||||
|
|
||||||
|
// ── 渲染 ──
|
||||||
return (
|
return (
|
||||||
<ConfigProvider theme={darkTheme}>
|
<ConfigProvider theme={darkTheme}>
|
||||||
<div className={styles.container}>
|
<div className={`${styles.container} ${isImmersive ? styles.sailing : ''}`}>
|
||||||
{/* 左侧游览线路 */}
|
{/* 左侧游览线路 */}
|
||||||
<div className={styles.leftPanel}>
|
<div className={styles.leftPanel}>
|
||||||
<LeftPanel
|
<LeftPanel
|
||||||
@@ -206,16 +88,56 @@ const ClientPage: React.FC = () => {
|
|||||||
selectedRouteId={selectedRouteId}
|
selectedRouteId={selectedRouteId}
|
||||||
boatData={boatData}
|
boatData={boatData}
|
||||||
onModelCenter={handleModelCenter}
|
onModelCenter={handleModelCenter}
|
||||||
|
isSailing={isSailing}
|
||||||
|
previewStopSignal={previewStopSignal}
|
||||||
|
onStartSailing={handleStartSailing}
|
||||||
|
onPreviewChange={handlePreviewChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* 沉浸模式浮层(航行或预览) */}
|
||||||
|
{isImmersive && (
|
||||||
|
<>
|
||||||
|
{!!activeRouteId && (
|
||||||
|
<NavigationOverlay
|
||||||
|
mode={isPreviewing ? 'preview' : 'sailing'}
|
||||||
|
routeName={activeRouteInfo?.routeName || ''}
|
||||||
|
waypoints={activeWaypoints.map((wp) => ({
|
||||||
|
name: wp.pointName || `航点${wp.waypointIndex + 1}`,
|
||||||
|
waypointIndex: wp.waypointIndex,
|
||||||
|
}))}
|
||||||
|
currentWaypointIndex={boatData?.currentWaypointIndex ?? currentWaypointIndex}
|
||||||
|
totalDistance={activeRouteInfo?.totalDistance ?? 0}
|
||||||
|
remainingDistance={remainingDistance}
|
||||||
|
estimatedRemainingTime={estimatedRemainingTime}
|
||||||
|
progress={progress}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{isSailing && (
|
||||||
|
<EmergencyButton onEmergencyStop={handleEmergencyStop} deviceSn={deviceSn} />
|
||||||
|
)}
|
||||||
|
<NavigationHUD
|
||||||
|
mode={isPreviewing ? 'preview' : 'sailing'}
|
||||||
|
routeName={activeRouteInfo?.routeName || ''}
|
||||||
|
speed={boatData?.speed ?? 0}
|
||||||
|
heading={boatData?.heading ?? 0}
|
||||||
|
battery={boatData?.battery ?? 0}
|
||||||
|
signalStrength={boatData?.signalStrength}
|
||||||
|
nextWaypoint={nextWaypoint}
|
||||||
|
remainingDistance={remainingDistance}
|
||||||
|
estimatedRemainingTime={estimatedRemainingTime}
|
||||||
|
progress={progress}
|
||||||
|
isPaused={isPaused && isSailing}
|
||||||
|
onPause={handlePauseSailing}
|
||||||
|
onResume={handleResumeSailing}
|
||||||
|
onStop={isPreviewing ? handleStopPreview : handleStopSailing}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 右侧设备信息 */}
|
{/* 右侧设备信息 */}
|
||||||
<div className={styles.rightPanel}>
|
<div className={styles.rightPanel}>
|
||||||
<RightPanel
|
<RightPanel deviceInfo={deviceInfo} boatData={boatData} sseConnected={sseConnected} />
|
||||||
deviceInfo={deviceInfo}
|
|
||||||
boatData={boatData}
|
|
||||||
sseConnected={sseConnected}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 底部状态栏 */}
|
{/* 底部状态栏 */}
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ export function useBoundaryDrawing(options: UseBoundaryDrawingOptions = {}): Use
|
|||||||
/**
|
/**
|
||||||
* 添加顶点
|
* 添加顶点
|
||||||
*/
|
*/
|
||||||
const addVertex = useCallback((point: { longitude: number; latitude: number }) => {
|
const addVertex = useCallback((point: { longitude: number; latitude: number; height?: number }) => {
|
||||||
const newVertex: BoundaryVertex = {
|
const newVertex: BoundaryVertex = {
|
||||||
longitude: point.longitude,
|
longitude: point.longitude,
|
||||||
latitude: point.latitude,
|
latitude: point.latitude,
|
||||||
|
|||||||
+20
-14
@@ -169,6 +169,12 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
const waylineEntityRef = useRef<any>(null);
|
const waylineEntityRef = useRef<any>(null);
|
||||||
const waypointEntitiesRef = useRef<any[]>([]);
|
const waypointEntitiesRef = useRef<any[]>([]);
|
||||||
|
|
||||||
|
// 前向引用 ref(解决 useCallback 声明顺序问题)
|
||||||
|
const loadWaypointsRef = useRef<any>(null);
|
||||||
|
const drawWaylineOnMapRef = useRef<any>(null);
|
||||||
|
const flyToWaylineRef = useRef<any>(null);
|
||||||
|
const clearWaylineEntitiesRef = useRef<any>(null);
|
||||||
|
|
||||||
// 实时位置 - 区分相对高度和海拔高度
|
// 实时位置 - 区分相对高度和海拔高度
|
||||||
const realtimePosition = useMemo(() => {
|
const realtimePosition = useMemo(() => {
|
||||||
if (!droneData) return null;
|
if (!droneData) return null;
|
||||||
@@ -190,7 +196,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
loadRoutesByDevice(deviceSn);
|
loadRoutesByDevice(deviceSn);
|
||||||
loadMissionsByDevice(deviceSn);
|
loadMissionsByDevice(deviceSn);
|
||||||
return () => {
|
return () => {
|
||||||
clearWaylineEntities();
|
clearWaylineEntitiesRef.current?.();
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
setPosition({ x: 0, y: 0 });
|
setPosition({ x: 0, y: 0 });
|
||||||
@@ -256,7 +262,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
if (!selectedRouteId && unifiedRoutes.length > 0) {
|
if (!selectedRouteId && unifiedRoutes.length > 0) {
|
||||||
const first = unifiedRoutes[0];
|
const first = unifiedRoutes[0];
|
||||||
setSelectedRouteId(first.routeId);
|
setSelectedRouteId(first.routeId);
|
||||||
loadWaypoints(first.routeId, first.routeType);
|
loadWaypointsRef.current?.(first.routeId, first.routeType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn('[TaskPanel] 加载无人船航线失败:', res);
|
console.warn('[TaskPanel] 加载无人船航线失败:', res);
|
||||||
@@ -283,7 +289,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
if (!selectedRouteId && unifiedRoutes.length > 0) {
|
if (!selectedRouteId && unifiedRoutes.length > 0) {
|
||||||
const first = unifiedRoutes[0];
|
const first = unifiedRoutes[0];
|
||||||
setSelectedRouteId(first.routeId);
|
setSelectedRouteId(first.routeId);
|
||||||
loadWaypoints(first.routeId, first.routeType);
|
loadWaypointsRef.current?.(first.routeId, first.routeType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn('[TaskPanel] 加载无人机航线失败:', res);
|
console.warn('[TaskPanel] 加载无人机航线失败:', res);
|
||||||
@@ -297,7 +303,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
} finally {
|
} finally {
|
||||||
setRouteLoading(false);
|
setRouteLoading(false);
|
||||||
}
|
}
|
||||||
}, [isBoatDevice, selectedRouteId, loadWaypoints]);
|
}, [isBoatDevice, selectedRouteId]);
|
||||||
|
|
||||||
// 加载任务列表
|
// 加载任务列表
|
||||||
const loadMissionsByDevice = useCallback(async (sn: string) => {
|
const loadMissionsByDevice = useCallback(async (sn: string) => {
|
||||||
@@ -343,7 +349,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
}));
|
}));
|
||||||
setWaypoints(unifiedWaypoints);
|
setWaypoints(unifiedWaypoints);
|
||||||
if (viewer && Cesium) {
|
if (viewer && Cesium) {
|
||||||
await drawWaylineOnMap(unifiedWaypoints);
|
await drawWaylineOnMapRef.current?.(unifiedWaypoints);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn('[TaskPanel] 加载无人船航点失败:', res);
|
console.warn('[TaskPanel] 加载无人船航点失败:', res);
|
||||||
@@ -364,7 +370,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
}));
|
}));
|
||||||
setWaypoints(unifiedWaypoints);
|
setWaypoints(unifiedWaypoints);
|
||||||
if (viewer && Cesium) {
|
if (viewer && Cesium) {
|
||||||
await drawWaylineOnMap(unifiedWaypoints);
|
await drawWaylineOnMapRef.current?.(unifiedWaypoints);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn('[TaskPanel] 加载无人机航点失败:', res);
|
console.warn('[TaskPanel] 加载无人机航点失败:', res);
|
||||||
@@ -374,7 +380,8 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
console.error('[TaskPanel] 加载航点失败:', e);
|
console.error('[TaskPanel] 加载航点失败:', e);
|
||||||
message.error('加载航点失败');
|
message.error('加载航点失败');
|
||||||
}
|
}
|
||||||
}, [viewer, Cesium, routeList, drawWaylineOnMap, isBoatDevice]);
|
}, [viewer, Cesium, routeList, isBoatDevice]);
|
||||||
|
loadWaypointsRef.current = loadWaypoints;
|
||||||
|
|
||||||
// 绘制航线 - 支持无人机和无人船航线,使用clampToHeightMostDetailed贴模型
|
// 绘制航线 - 支持无人机和无人船航线,使用clampToHeightMostDetailed贴模型
|
||||||
const drawWaylineOnMap = useCallback(async (waypoints: UnifiedWaypoint[]) => {
|
const drawWaylineOnMap = useCallback(async (waypoints: UnifiedWaypoint[]) => {
|
||||||
@@ -536,8 +543,9 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 飞到航线,传递渲染后的positions用于精确计算视角
|
// 飞到航线,传递渲染后的positions用于精确计算视角
|
||||||
flyToWayline(waypoints, polylinePositions.length >= 2 ? polylinePositions : waypointPositions);
|
flyToWaylineRef.current?.(waypoints, polylinePositions.length >= 2 ? polylinePositions : waypointPositions);
|
||||||
}, [viewer, Cesium, flyToWayline, clearWaylineEntities]);
|
}, [viewer, Cesium]);
|
||||||
|
drawWaylineOnMapRef.current = drawWaylineOnMap;
|
||||||
|
|
||||||
// 飞到航线位置 - 参考航线规划页面的实现
|
// 飞到航线位置 - 参考航线规划页面的实现
|
||||||
const flyToWayline = useCallback((waypoints: UnifiedWaypoint[], positions?: any[]) => {
|
const flyToWayline = useCallback((waypoints: UnifiedWaypoint[], positions?: any[]) => {
|
||||||
@@ -600,8 +608,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
console.error('[航线视角] 飞到航线失败:', e);
|
console.error('[航线视角] 飞到航线失败:', e);
|
||||||
}
|
}
|
||||||
}, [viewer, Cesium]);
|
}, [viewer, Cesium]);
|
||||||
|
flyToWaylineRef.current = flyToWayline;
|
||||||
// 检查 viewer 是否有效
|
|
||||||
const isViewerValid = useCallback(() => {
|
const isViewerValid = useCallback(() => {
|
||||||
return viewer && !viewer.isDestroyed?.();
|
return viewer && !viewer.isDestroyed?.();
|
||||||
}, [viewer]);
|
}, [viewer]);
|
||||||
@@ -624,8 +631,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
});
|
});
|
||||||
waypointEntitiesRef.current = [];
|
waypointEntitiesRef.current = [];
|
||||||
}, [viewer, isViewerValid]);
|
}, [viewer, isViewerValid]);
|
||||||
|
clearWaylineEntitiesRef.current = clearWaylineEntities;
|
||||||
// 选择航线
|
|
||||||
const handleSelectRoute = useCallback((routeId: string) => {
|
const handleSelectRoute = useCallback((routeId: string) => {
|
||||||
setSelectedRouteId(routeId);
|
setSelectedRouteId(routeId);
|
||||||
loadWaypoints(routeId);
|
loadWaypoints(routeId);
|
||||||
@@ -978,7 +984,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
|||||||
allowClear
|
allowClear
|
||||||
onClear={() => {
|
onClear={() => {
|
||||||
setSelectedRouteId(null);
|
setSelectedRouteId(null);
|
||||||
clearWaylineEntities();
|
clearWaylineEntitiesRef.current?.();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{routeList.map(route => (
|
{routeList.map(route => (
|
||||||
|
|||||||
+9
-9
@@ -22,8 +22,8 @@ interface UseCesiumRouteRendererOptions {
|
|||||||
mode: EditorMode; // 'view' | 'draw' | 'select' | 'edit'
|
mode: EditorMode; // 'view' | 'draw' | 'select' | 'edit'
|
||||||
boundaryGeoJson?: string; // 用于边界检测
|
boundaryGeoJson?: string; // 用于边界检测
|
||||||
obstacles?: RouteObstacleItem[]; // 障碍物边界(多边形)
|
obstacles?: RouteObstacleItem[]; // 障碍物边界(多边形)
|
||||||
onWaypointAdd: (point: { longitude: number; latitude: number }) => void;
|
onWaypointAdd: (point: { longitude: number; latitude: number; altitude?: number }) => void;
|
||||||
onWaypointMove: (index: number, point: { longitude: number; latitude: number }) => void;
|
onWaypointMove: (index: number, point: { longitude: number; latitude: number; altitude?: number }) => void;
|
||||||
onWaypointSelect: (index: number) => void;
|
onWaypointSelect: (index: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +96,13 @@ export function useCesiumRouteRenderer(options: UseCesiumRouteRendererOptions) {
|
|||||||
timer: null,
|
timer: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Cesium对象(提前声明,供后续 useCallback 引用)
|
||||||
|
*/
|
||||||
|
const getCesium = useCallback(() => {
|
||||||
|
return (window as any).Cesium;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const applyHeightOffset = useCallback((cartesian: any) => {
|
const applyHeightOffset = useCallback((cartesian: any) => {
|
||||||
const Cesium = getCesium();
|
const Cesium = getCesium();
|
||||||
if (!Cesium || !cartesian) return cartesian;
|
if (!Cesium || !cartesian) return cartesian;
|
||||||
@@ -153,13 +160,6 @@ export function useCesiumRouteRenderer(options: UseCesiumRouteRendererOptions) {
|
|||||||
return result;
|
return result;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Cesium对象
|
|
||||||
*/
|
|
||||||
const getCesium = useCallback(() => {
|
|
||||||
return (window as any).Cesium;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const normalizeRing = useCallback((ring: any): Array<[number, number]> => {
|
const normalizeRing = useCallback((ring: any): Array<[number, number]> => {
|
||||||
if (!Array.isArray(ring)) return [];
|
if (!Array.isArray(ring)) return [];
|
||||||
const coords = ring
|
const coords = ring
|
||||||
|
|||||||
@@ -69,18 +69,6 @@ const RouteEditor: React.FC<RouteEditorProps> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setActiveRouteId(routeId);
|
setActiveRouteId(routeId);
|
||||||
}, [routeId]);
|
}, [routeId]);
|
||||||
|
|
||||||
const goLibraryAfterSave = useCallback(async (savedRouteId: string) => {
|
|
||||||
// 退出“编辑态”,让航线出现在航线库列表中
|
|
||||||
setActiveRouteId(undefined);
|
|
||||||
setMode('view');
|
|
||||||
selectWaypoint(null);
|
|
||||||
setWaypoints([]);
|
|
||||||
setActiveTabKey('library');
|
|
||||||
setLibrarySelectedId(savedRouteId);
|
|
||||||
await loadRouteLibrary();
|
|
||||||
}, [loadRouteLibrary, selectWaypoint, setMode, setWaypoints]);
|
|
||||||
|
|
||||||
// 加载设备绑定的水域边界(用于规划航线)
|
// 加载设备绑定的水域边界(用于规划航线)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const sn = String(deviceSn || '').trim();
|
const sn = String(deviceSn || '').trim();
|
||||||
@@ -279,6 +267,17 @@ const RouteEditor: React.FC<RouteEditorProps> = ({
|
|||||||
loadRouteLibrary();
|
loadRouteLibrary();
|
||||||
}, [loadRouteLibrary]);
|
}, [loadRouteLibrary]);
|
||||||
|
|
||||||
|
const goLibraryAfterSave = useCallback(async (savedRouteId: string) => {
|
||||||
|
// 退出“编辑态”,让航线出现在航线库列表中
|
||||||
|
setActiveRouteId(undefined);
|
||||||
|
setMode('view');
|
||||||
|
selectWaypoint(null);
|
||||||
|
setWaypoints([]);
|
||||||
|
setActiveTabKey('library');
|
||||||
|
setLibrarySelectedId(savedRouteId);
|
||||||
|
await loadRouteLibrary();
|
||||||
|
}, [loadRouteLibrary, selectWaypoint, setMode, setWaypoints]);
|
||||||
|
|
||||||
const ensureRouteDetail = useCallback(async (id: string) => {
|
const ensureRouteDetail = useCallback(async (id: string) => {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
if (routeDetailsRef.current[id]?.length) return;
|
if (routeDetailsRef.current[id]?.length) return;
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ const customTheme = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const darkTheme = customTheme;
|
||||||
|
|
||||||
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||||
return (
|
return (
|
||||||
<ConfigProvider theme={customTheme} locale={zhCN}>
|
<ConfigProvider theme={customTheme} locale={zhCN}>
|
||||||
|
|||||||
Reference in New Issue
Block a user