parent
2b2ee3a8c9
commit
8e51aeb0ff
@ -1,8 +0,0 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(curl -sL \"https://unpkg.com/roslib@2.1.0/dist/\")",
|
||||
"Bash(curl -sL \"https://unpkg.com/roslib@1.3.0/build/roslib.min.js\" -o \"d:/29578/Documents/Study/computer/S_E/软件体系结构与设计/软件前端/js/roslib.min.js\" -w \"%{http_code} %{size_download}\")"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1,383 +0,0 @@
|
||||
/* ===== 全局样式 ===== */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
background: #f0f2f5;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* ===== 顶部状态栏 ===== */
|
||||
.top-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 48px;
|
||||
padding: 0 16px;
|
||||
background: #1a1a2e;
|
||||
color: #e0e0e0;
|
||||
flex-shrink: 0;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.top-bar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
font-size: 13px;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.status-item strong {
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.top-bar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.top-bar-right input {
|
||||
width: 220px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #444;
|
||||
border-radius: 4px;
|
||||
background: #2a2a3e;
|
||||
color: #e0e0e0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* ===== 连接模式切换 ===== */
|
||||
.conn-mode-group {
|
||||
display: flex;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #444;
|
||||
}
|
||||
|
||||
.mode-btn {
|
||||
padding: 4px 12px;
|
||||
background: #2a2a3e;
|
||||
color: #aaa;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.mode-btn:hover { color: #ddd; }
|
||||
|
||||
.mode-btn.active {
|
||||
background: #007aff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.conn-mode-tag {
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 3px;
|
||||
background: #2a2a3e;
|
||||
color: #888;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ===== 标签 ===== */
|
||||
.tag {
|
||||
display: inline-block;
|
||||
padding: 2px 10px;
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tag-success { background: #f6ffed; color: #52c41a; }
|
||||
.tag-danger { background: #fff1f0; color: #ff4d4f; }
|
||||
.tag-warning { background: #fffbe6; color: #faad14; }
|
||||
.tag-info { background: #e6f7ff; color: #007aff; }
|
||||
|
||||
/* ===== 按钮 ===== */
|
||||
.btn {
|
||||
padding: 7px 14px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn:not(:disabled):hover { opacity: 0.85; }
|
||||
|
||||
.btn-primary { background: #007aff; color: #fff; }
|
||||
.btn-success { background: #52c41a; color: #fff; }
|
||||
.btn-warning { background: #faad14; color: #fff; }
|
||||
.btn-danger { background: #ff4d4f; color: #fff; }
|
||||
.btn-secondary { background: #e0e0e0; color: #333; }
|
||||
.btn.wide { width: 100%; }
|
||||
|
||||
.btn-link {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btn-link:hover { color: #007aff; }
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.btn-group .btn { flex: 1; }
|
||||
|
||||
/* ===== 主内容区 ===== */
|
||||
.main-content {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* ===== 地图 ===== */
|
||||
.map-container {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* ===== 右侧控制面板 ===== */
|
||||
.control-panel {
|
||||
width: 300px;
|
||||
flex-shrink: 0;
|
||||
background: #fff;
|
||||
border-left: 1px solid #e0e0e0;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.panel-section {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.panel-header span:last-child {
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* ===== 航点列表 ===== */
|
||||
.waypoint-list {
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
text-align: center;
|
||||
color: #bbb;
|
||||
font-size: 13px;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.wp-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 8px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 4px;
|
||||
background: #f8f9fa;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.wp-item:hover { background: #e6f7ff; }
|
||||
|
||||
.wp-item.active { background: #e6f7ff; border: 1px solid #91d5ff; }
|
||||
|
||||
.wp-index {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 50%;
|
||||
background: #007aff;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
margin-right: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wp-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.wp-coord {
|
||||
font-size: 11px;
|
||||
color: #666;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.wp-alt {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.wp-delete {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: none;
|
||||
background: none;
|
||||
color: #ccc;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wp-delete:hover { color: #ff4d4f; }
|
||||
|
||||
.wp-params {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.wp-params input {
|
||||
width: 60px;
|
||||
padding: 3px 6px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ===== 数据面板 ===== */
|
||||
.data-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.data-item {
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.data-label {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.data-value {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* ===== 底部日志栏 ===== */
|
||||
.log-bar {
|
||||
height: 120px;
|
||||
flex-shrink: 0;
|
||||
background: #1e1e1e;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.log-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 12px;
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
background: #2a2a2a;
|
||||
border-bottom: 1px solid #333;
|
||||
}
|
||||
|
||||
.log-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px 12px;
|
||||
font-family: 'Consolas', 'Monaco', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.log-entry {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.log-entry .time { color: #666; margin-right: 8px; }
|
||||
.log-entry.success { color: #52c41a; }
|
||||
.log-entry.error { color: #ff4d4f; }
|
||||
.log-entry.warning { color: #faad14; }
|
||||
.log-entry.info { color: #aaa; }
|
||||
|
||||
/* ===== Leaflet 自定义 ===== */
|
||||
.drone-icon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.drone-icon-inner {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 10px solid transparent;
|
||||
border-right: 10px solid transparent;
|
||||
border-bottom: 20px solid #007aff;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
transform-origin: center 60%;
|
||||
}
|
||||
@ -1,118 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>P600 无人机定点巡航控制系统</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- 顶部状态栏 -->
|
||||
<header class="top-bar">
|
||||
<div class="top-bar-left">
|
||||
<span class="logo">P600 定点巡航控制系统</span>
|
||||
<span id="conn-status" class="tag tag-danger">未连接</span>
|
||||
<span class="status-item">模式: <strong id="flight-mode">--</strong></span>
|
||||
<span class="status-item">电量: <strong id="battery">--%</strong></span>
|
||||
<span class="status-item">GPS: <strong id="gps-status">--</strong></span>
|
||||
<span class="status-item">速度: <strong id="speed">-- m/s</strong></span>
|
||||
<span class="status-item">高度: <strong id="altitude">-- m</strong></span>
|
||||
</div>
|
||||
<div class="top-bar-right">
|
||||
<div class="conn-mode-group">
|
||||
<button id="btn-mode-sim" class="mode-btn active" title="Prometheus SITL 仿真 (rosbridge WebSocket)">仿真模式</button>
|
||||
<button id="btn-mode-real" class="mode-btn" title="P600 实机 WiFi 数传 (rosbridge WebSocket)">实机模式</button>
|
||||
</div>
|
||||
<input type="text" id="drone-url" value="ws://localhost:9090" placeholder="rosbridge 地址" />
|
||||
<button id="btn-connect" class="btn btn-primary">连接无人机</button>
|
||||
<span id="conn-mode-tag" class="conn-mode-tag">rosbridge</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<div class="main-content">
|
||||
<!-- 地图区域 -->
|
||||
<div id="map" class="map-container"></div>
|
||||
|
||||
<!-- 右侧控制面板 -->
|
||||
<aside class="control-panel">
|
||||
<!-- 航点列表 -->
|
||||
<div class="panel-section">
|
||||
<div class="panel-header">
|
||||
<span>航点列表</span>
|
||||
<span id="wp-count">0 个航点</span>
|
||||
</div>
|
||||
<div id="waypoint-list" class="waypoint-list">
|
||||
<div class="empty-hint">在地图上点击以添加航点</div>
|
||||
</div>
|
||||
<div class="wp-params">
|
||||
<label>默认高度: <input type="number" id="default-alt" value="15" min="1" max="100" /> 米</label>
|
||||
<label>默认悬停: <input type="number" id="default-hold" value="0" min="0" max="60" /> 秒</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 任务操作 -->
|
||||
<div class="panel-section">
|
||||
<div class="panel-header">任务操作</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-upload" class="btn btn-primary wide" disabled>上传任务</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-start" class="btn btn-success wide" disabled>开始任务</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-pause" class="btn btn-warning" disabled>暂停</button>
|
||||
<button id="btn-resume" class="btn btn-success" disabled>继续</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-rth" class="btn btn-danger" disabled>返航</button>
|
||||
<button id="btn-land" class="btn btn-danger" disabled>降落</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-clear" class="btn btn-secondary wide">清除所有航点</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 实时数据 -->
|
||||
<div class="panel-section">
|
||||
<div class="panel-header">实时数据</div>
|
||||
<div class="data-grid">
|
||||
<div class="data-item">
|
||||
<span class="data-label">纬度</span>
|
||||
<span class="data-value" id="data-lat">--</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span class="data-label">经度</span>
|
||||
<span class="data-value" id="data-lng">--</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span class="data-label">航向</span>
|
||||
<span class="data-value" id="data-heading">--</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span class="data-label">当前航点</span>
|
||||
<span class="data-value" id="data-wp">--</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<!-- 底部日志栏 -->
|
||||
<footer class="log-bar">
|
||||
<div class="log-header">
|
||||
<span>操作日志</span>
|
||||
<button id="btn-clear-log" class="btn-link">清空</button>
|
||||
</div>
|
||||
<div id="log-content" class="log-content"></div>
|
||||
</footer>
|
||||
|
||||
<!-- JS 依赖 -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
<script src="/js/roslib.min.js"></script>
|
||||
<script src="/js/map.js"></script>
|
||||
<script src="/js/websocket.js"></script>
|
||||
<script src="/js/ui.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
# 此文件已弃用 - 新架构通过 roslibjs + rosbridge_server 直接在浏览器端控制无人机
|
||||
# 无需 Python 后端处理无人机逻辑
|
||||
#
|
||||
# 新架构:
|
||||
# 浏览器 (roslibjs) ──WebSocket──► rosbridge_server ──ROS话题──► Prometheus/MAVROS ──► PX4
|
||||
#
|
||||
# 如需参考旧版 MAVSDK 实现,请查看 git 历史
|
||||
@ -0,0 +1,406 @@
|
||||
/* ===== 全局 ===== */
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
background: #f0f2f5;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* ===== 侧边栏 ===== */
|
||||
.sidebar {
|
||||
width: 200px;
|
||||
flex-shrink: 0;
|
||||
background: #1a1a2e;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid #2a2a3e;
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
font-size: 22px;
|
||||
width: 36px; height: 36px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
background: rgba(0, 122, 255, 0.2);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.logo-text { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 1px; }
|
||||
|
||||
.nav-menu { list-style: none; padding: 12px 8px; flex: 1; }
|
||||
|
||||
.nav-item {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 10px 12px; border-radius: 8px; cursor: pointer;
|
||||
font-size: 14px; color: #8888aa; margin-bottom: 4px; transition: all 0.2s;
|
||||
}
|
||||
|
||||
.nav-item:hover { background: rgba(0, 122, 255, 0.1); color: #c0c0d0; }
|
||||
.nav-item.active { background: rgba(0, 122, 255, 0.2); color: #58a6ff; }
|
||||
|
||||
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
|
||||
|
||||
.sidebar-footer { padding: 12px 16px; border-top: 1px solid #2a2a3e; }
|
||||
|
||||
.conn-indicator { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8888aa; }
|
||||
|
||||
.dot { width: 8px; height: 8px; border-radius: 50%; background: #484f58; display: inline-block; }
|
||||
|
||||
.conn-indicator.connected .dot { background: #3fb950; box-shadow: 0 0 6px rgba(63, 185, 80, 0.5); }
|
||||
.conn-indicator.connected { color: #3fb950; }
|
||||
|
||||
/* ===== 主区域 ===== */
|
||||
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
|
||||
|
||||
/* ===== 顶栏 ===== */
|
||||
.top-bar {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
height: 48px; padding: 0 20px; background: #1a1a2e; flex-shrink: 0; z-index: 100;
|
||||
}
|
||||
|
||||
.top-bar-left { display: flex; align-items: center; gap: 16px; }
|
||||
.top-bar-right { display: flex; align-items: center; gap: 8px; }
|
||||
|
||||
.page-title { font-size: 16px; font-weight: 600; color: #e6edf3; }
|
||||
|
||||
.status-item { font-size: 13px; color: #aaa; }
|
||||
.status-item strong { color: #e0e0e0; }
|
||||
|
||||
.status-chip {
|
||||
padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 600;
|
||||
background: #2a2a3e; color: #8888aa;
|
||||
}
|
||||
|
||||
/* ===== 标签 ===== */
|
||||
.tag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
|
||||
.tag-success { background: #f6ffed; color: #52c41a; }
|
||||
.tag-danger { background: #fff1f0; color: #ff4d4f; }
|
||||
.tag-warning { background: #fffbe6; color: #faad14; }
|
||||
.tag-info { background: #e6f7ff; color: #007aff; }
|
||||
|
||||
/* ===== 页面容器 ===== */
|
||||
.page-content { display: none; flex-direction: column; flex: 1; min-height: 0; }
|
||||
.page-content.active { display: flex; }
|
||||
|
||||
.page-body { flex: 1; overflow-y: auto; padding: 20px; }
|
||||
|
||||
/* ===== 按钮 ===== */
|
||||
.btn {
|
||||
padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer;
|
||||
font-size: 13px; font-weight: 600; transition: opacity 0.2s;
|
||||
}
|
||||
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
|
||||
.btn:not(:disabled):hover { opacity: 0.85; }
|
||||
.btn-primary { background: #007aff; color: #fff; }
|
||||
.btn-success { background: #52c41a; color: #fff; }
|
||||
.btn-warning { background: #faad14; color: #fff; }
|
||||
.btn-danger { background: #ff4d4f; color: #fff; }
|
||||
.btn-secondary { background: #e0e0e0; color: #333; }
|
||||
.btn.wide { width: 100%; }
|
||||
.btn-link { background: none; border: none; color: #999; cursor: pointer; font-size: 12px; }
|
||||
.btn-link:hover { color: #007aff; }
|
||||
|
||||
/* ===== 统计卡片 ===== */
|
||||
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
|
||||
|
||||
.stat-card {
|
||||
background: #fff; border-radius: 10px; padding: 16px 20px;
|
||||
border-left: 3px solid transparent; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
|
||||
}
|
||||
.stat-card.stat-pending { border-left-color: #faad14; }
|
||||
.stat-card.stat-active { border-left-color: #007aff; }
|
||||
.stat-card.stat-done { border-left-color: #52c41a; }
|
||||
.stat-card.stat-drone { border-left-color: #58a6ff; }
|
||||
|
||||
.stat-value { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
|
||||
.stat-card.stat-pending .stat-value { color: #faad14; }
|
||||
.stat-card.stat-active .stat-value { color: #007aff; }
|
||||
.stat-card.stat-done .stat-value { color: #52c41a; }
|
||||
.stat-label { font-size: 13px; color: #999; }
|
||||
|
||||
.dashboard-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
||||
|
||||
/* ===== 卡片 ===== */
|
||||
.card { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
|
||||
|
||||
.card-header {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 12px 16px; border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.card-title { font-size: 14px; font-weight: 600; color: #333; }
|
||||
|
||||
.card-badge { padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; background: rgba(250, 173, 20, 0.15); color: #faad14; }
|
||||
.card-badge.active { background: rgba(0, 122, 255, 0.15); color: #007aff; }
|
||||
|
||||
/* ===== 任务列表 ===== */
|
||||
.list-card { max-height: 400px; display: flex; flex-direction: column; }
|
||||
.task-list { flex: 1; overflow-y: auto; padding: 8px; }
|
||||
|
||||
.task-item {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
padding: 10px 12px; border-radius: 8px; cursor: pointer;
|
||||
margin-bottom: 4px; transition: background 0.15s;
|
||||
}
|
||||
.task-item:hover { background: #f0f7ff; }
|
||||
|
||||
.task-priority { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; flex-shrink: 0; }
|
||||
.priority-urgent { background: rgba(255, 77, 79, 0.1); color: #ff4d4f; }
|
||||
.priority-high { background: rgba(250, 173, 20, 0.1); color: #faad14; }
|
||||
.priority-normal { background: rgba(0, 122, 255, 0.1); color: #007aff; }
|
||||
|
||||
.task-info { flex: 1; min-width: 0; }
|
||||
.task-name { font-size: 13px; font-weight: 600; color: #333; margin-bottom: 2px; }
|
||||
.task-desc { font-size: 11px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.task-arrow { color: #ccc; font-size: 14px; flex-shrink: 0; }
|
||||
|
||||
.empty-hint { text-align: center; color: #bbb; font-size: 13px; padding: 20px 0; }
|
||||
|
||||
/* ===== 连接设置 ===== */
|
||||
.conn-card { flex-shrink: 0; }
|
||||
|
||||
.conn-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
|
||||
|
||||
.conn-url-row {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.conn-url-row input {
|
||||
flex: 1;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
outline: none;
|
||||
font-family: 'Consolas', 'Monaco', monospace;
|
||||
}
|
||||
|
||||
.conn-url-row input:focus { border-color: #007aff; }
|
||||
|
||||
/* ===== 士兵标记 (地图) ===== */
|
||||
.soldier-marker {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.soldier-marker-dot {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background: #52c41a;
|
||||
border: 2px solid #fff;
|
||||
box-shadow: 0 0 6px rgba(82, 196, 26, 0.5);
|
||||
}
|
||||
.soldier-marker-name {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
background: rgba(82, 196, 26, 0.85);
|
||||
padding: 1px 6px;
|
||||
border-radius: 3px;
|
||||
margin-top: 2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ===== 危险区域标记 (地图) ===== */
|
||||
.danger-zone-marker { pointer-events: auto; }
|
||||
.danger-zone-icon {
|
||||
font-size: 20px;
|
||||
color: #ff4d4f;
|
||||
text-shadow: 0 0 4px rgba(255, 77, 79, 0.6);
|
||||
text-align: center;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
/* ===== 士兵列表 ===== */
|
||||
.soldier-card { flex-shrink: 0; }
|
||||
.soldier-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 2px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.soldier-item:hover { background: #f0fff0; }
|
||||
.soldier-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: #52c41a;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.soldier-info { flex: 1; min-width: 0; }
|
||||
.soldier-name { font-size: 13px; font-weight: 600; color: #333; }
|
||||
.soldier-coord { font-size: 11px; color: #999; }
|
||||
|
||||
/* ===== 危险区域列表 ===== */
|
||||
.danger-card { flex-shrink: 0; }
|
||||
.card-badge.danger { background: rgba(255, 77, 79, 0.15); color: #ff4d4f; }
|
||||
.danger-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 2px;
|
||||
background: #fff1f0;
|
||||
}
|
||||
.danger-icon {
|
||||
font-size: 16px;
|
||||
color: #ff4d4f;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.danger-info { flex: 1; min-width: 0; }
|
||||
.danger-desc { font-size: 13px; font-weight: 600; color: #ff4d4f; }
|
||||
.danger-coord { font-size: 11px; color: #999; }
|
||||
|
||||
/* ===== 滚动列表容器 ===== */
|
||||
.list-scroll-content {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* ===== 监控页 ===== */
|
||||
.monitor-body { flex: 1; display: flex; min-height: 0; }
|
||||
|
||||
.map-container { flex: 1; min-width: 0; z-index: 1; }
|
||||
|
||||
.monitor-panel {
|
||||
width: 320px; flex-shrink: 0; background: #fff; border-left: 1px solid #e8e8e8;
|
||||
display: flex; flex-direction: column; overflow-y: auto;
|
||||
}
|
||||
|
||||
.drone-info-card { flex-shrink: 0; }
|
||||
|
||||
.drone-card-header {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 14px 16px; border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.drone-name { font-size: 16px; font-weight: 700; color: #333; }
|
||||
|
||||
.drone-meta {
|
||||
padding: 10px 16px; font-size: 12px; color: #999;
|
||||
display: flex; gap: 20px; border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
.drone-meta strong { color: #333; }
|
||||
|
||||
.monitor-data { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
||||
|
||||
.data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
||||
|
||||
.data-item { background: #f8f9fa; border-radius: 6px; padding: 8px; text-align: center; }
|
||||
.data-label { display: block; font-size: 11px; color: #999; margin-bottom: 2px; }
|
||||
.data-value { font-size: 13px; font-weight: 600; color: #333; }
|
||||
|
||||
.control-card { flex-shrink: 0; }
|
||||
.control-btns { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
|
||||
|
||||
.log-card { flex: 1; display: flex; flex-direction: column; min-height: 150px; }
|
||||
.log-content {
|
||||
flex: 1; overflow-y: auto; padding: 8px 12px;
|
||||
font-family: 'Consolas', 'Monaco', monospace; font-size: 11px; line-height: 1.6;
|
||||
}
|
||||
|
||||
.log-entry { white-space: nowrap; }
|
||||
.log-entry .time { color: #bbb; margin-right: 8px; }
|
||||
.log-entry.success { color: #52c41a; }
|
||||
.log-entry.error { color: #ff4d4f; }
|
||||
.log-entry.warning { color: #faad14; }
|
||||
.log-entry.info { color: #999; }
|
||||
|
||||
/* ===== 弹窗 ===== */
|
||||
.modal-overlay {
|
||||
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
|
||||
background: rgba(0,0,0,0.5); display: flex; align-items: center;
|
||||
justify-content: center; z-index: 9999;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: #fff; border-radius: 12px; width: 480px; max-height: 85vh;
|
||||
display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 14px 20px; border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.modal-title { font-size: 15px; font-weight: 700; color: #333; }
|
||||
|
||||
.modal-close { background: none; border: none; color: #999; font-size: 20px; cursor: pointer; }
|
||||
.modal-close:hover { color: #ff4d4f; }
|
||||
|
||||
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
|
||||
|
||||
.modal-footer {
|
||||
display: flex; justify-content: flex-end; gap: 10px;
|
||||
padding: 12px 20px; border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.detail-row { display: flex; margin-bottom: 10px; font-size: 13px; }
|
||||
.detail-label { width: 80px; color: #999; flex-shrink: 0; }
|
||||
.detail-value { color: #333; flex: 1; }
|
||||
|
||||
.detail-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
|
||||
.detail-section-title { font-size: 13px; font-weight: 600; color: #007aff; margin-bottom: 10px; }
|
||||
|
||||
/* 坐标输入 */
|
||||
.coord-group { margin-bottom: 12px; }
|
||||
.coord-label { font-size: 12px; font-weight: 600; color: #333; margin-bottom: 6px; }
|
||||
.coord-inputs { display: flex; gap: 10px; }
|
||||
.coord-inputs label { font-size: 12px; color: #666; display: flex; align-items: center; gap: 4px; }
|
||||
.coord-inputs input {
|
||||
width: 110px; padding: 5px 8px; border: 1px solid #ddd; border-radius: 4px;
|
||||
font-size: 12px; text-align: center; outline: none;
|
||||
}
|
||||
.coord-inputs input:focus { border-color: #007aff; }
|
||||
.coord-hint { font-size: 11px; color: #bbb; margin-top: 4px; }
|
||||
|
||||
.dispatch-option {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 8px 12px; border-radius: 8px; margin-bottom: 6px;
|
||||
cursor: pointer; border: 1px solid #e8e8e8; transition: all 0.2s;
|
||||
}
|
||||
.dispatch-option:hover { border-color: #007aff; }
|
||||
.dispatch-option.selected { border-color: #007aff; background: #f0f7ff; }
|
||||
.dispatch-option input[type="radio"] { accent-color: #007aff; }
|
||||
.dispatch-option label { font-size: 13px; color: #333; cursor: pointer; }
|
||||
|
||||
/* ===== Leaflet ===== */
|
||||
.drone-icon { width: 24px; height: 24px; position: relative; }
|
||||
.drone-icon-inner {
|
||||
width: 0; height: 0;
|
||||
border-left: 10px solid transparent; border-right: 10px solid transparent;
|
||||
border-bottom: 20px solid #007aff;
|
||||
position: absolute; top: 2px; left: 2px; transform-origin: center 60%;
|
||||
}
|
||||
|
||||
/* ===== 滚动条 ===== */
|
||||
::-webkit-scrollbar { width: 5px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
|
||||
|
||||
/* ===== 适配 ===== */
|
||||
@media (max-width: 1100px) {
|
||||
.stat-cards { grid-template-columns: repeat(2, 1fr); }
|
||||
.dashboard-body { grid-template-columns: 1fr; }
|
||||
.monitor-panel { width: 280px; }
|
||||
}
|
||||
@ -0,0 +1,188 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>智途投送 - 物流保障系统</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- ===== 左侧导航栏 ===== -->
|
||||
<nav class="sidebar">
|
||||
<div class="sidebar-logo">
|
||||
<div class="logo-icon">✈</div>
|
||||
<div class="logo-text">智途投送</div>
|
||||
</div>
|
||||
<ul class="nav-menu">
|
||||
<li class="nav-item active" data-page="dashboard">
|
||||
<span class="nav-icon">☰</span>
|
||||
<span class="nav-label">任务调度</span>
|
||||
</li>
|
||||
<li class="nav-item" data-page="monitor">
|
||||
<span class="nav-icon">📡</span>
|
||||
<span class="nav-label">无人机监控</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="sidebar-footer">
|
||||
<div class="conn-indicator" id="conn-dot">
|
||||
<span class="dot"></span>
|
||||
<span id="conn-text">未连接</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- ===== 主内容区 ===== -->
|
||||
<div class="main-area">
|
||||
|
||||
<!-- ===== 页面A: 任务调度 ===== -->
|
||||
<div class="page-content active" id="page-dashboard">
|
||||
<header class="top-bar">
|
||||
<div class="top-bar-left">
|
||||
<h1 class="page-title">任务调度</h1>
|
||||
</div>
|
||||
<div class="top-bar-right">
|
||||
<span class="status-chip" id="chip-time"></span>
|
||||
</div>
|
||||
</header>
|
||||
<div class="page-body">
|
||||
<div class="stat-cards">
|
||||
<div class="stat-card stat-pending">
|
||||
<div class="stat-value" id="stat-pending">3</div>
|
||||
<div class="stat-label">待处理需求</div>
|
||||
</div>
|
||||
<div class="stat-card stat-active">
|
||||
<div class="stat-value" id="stat-active">2</div>
|
||||
<div class="stat-label">飞行中</div>
|
||||
</div>
|
||||
<div class="stat-card stat-done">
|
||||
<div class="stat-value" id="stat-done">128</div>
|
||||
<div class="stat-label">已完成</div>
|
||||
</div>
|
||||
<div class="stat-card stat-drone">
|
||||
<div class="stat-value" id="stat-drone">3</div>
|
||||
<div class="stat-label">无人机可用</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard-body">
|
||||
<div class="card list-card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">待处理需求</span>
|
||||
<span class="card-badge" id="pending-count">3</span>
|
||||
</div>
|
||||
<div class="task-list" id="pending-list"></div>
|
||||
</div>
|
||||
<div class="card list-card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">飞行中任务</span>
|
||||
<span class="card-badge active" id="active-count">2</span>
|
||||
</div>
|
||||
<div class="task-list" id="active-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===== 页面B: 无人机监控 ===== -->
|
||||
<div class="page-content" id="page-monitor">
|
||||
<header class="top-bar">
|
||||
<div class="top-bar-left">
|
||||
<h1 class="page-title">无人机监控</h1>
|
||||
<span id="monitor-flight-tag" class="tag tag-info">空闲</span>
|
||||
</div>
|
||||
<div class="top-bar-right">
|
||||
<span class="status-item">电量: <strong id="mon-battery">--%</strong></span>
|
||||
<span class="status-item">速度: <strong id="mon-speed">-- m/s</strong></span>
|
||||
<span class="status-item">高度: <strong id="mon-alt">-- m</strong></span>
|
||||
<span class="status-item">GPS: <strong id="mon-gps">--</strong></span>
|
||||
<span class="status-chip" id="chip-time-mon"></span>
|
||||
</div>
|
||||
</header>
|
||||
<div class="monitor-body">
|
||||
<div id="map" class="map-container"></div>
|
||||
<div class="monitor-panel">
|
||||
<div class="card conn-card">
|
||||
<div class="card-header"><span class="card-title">连接设置</span></div>
|
||||
<div class="conn-body">
|
||||
<div class="conn-url-row">
|
||||
<input type="text" id="drone-url" value="ws://192.168.1.14:9090" placeholder="rosbridge WebSocket 地址" />
|
||||
<button id="btn-connect" class="btn btn-primary">连接</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card drone-info-card">
|
||||
<div class="drone-card-header">
|
||||
<div class="drone-name" id="mon-drone-name">无人机-01</div>
|
||||
<span class="tag tag-success" id="monitor-status">空闲</span>
|
||||
</div>
|
||||
<div class="drone-meta">
|
||||
<span>任务: <strong id="monitor-task">--</strong></span>
|
||||
<span>目标士兵: <strong id="monitor-soldier">--</strong></span>
|
||||
</div>
|
||||
<div class="data-grid monitor-data">
|
||||
<div class="data-item"><span class="data-label">纬度</span><span class="data-value" id="mon-lat">--</span></div>
|
||||
<div class="data-item"><span class="data-label">经度</span><span class="data-value" id="mon-lng">--</span></div>
|
||||
<div class="data-item"><span class="data-label">航向</span><span class="data-value" id="mon-heading">--</span></div>
|
||||
<div class="data-item"><span class="data-label">距目标</span><span class="data-value" id="mon-dist">--</span></div>
|
||||
<div class="data-item"><span class="data-label">信号</span><span class="data-value" id="mon-signal">--%</span></div>
|
||||
<div class="data-item"><span class="data-label">预计到达</span><span class="data-value" id="mon-eta">--</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card control-card">
|
||||
<div class="card-header"><span class="card-title">控制面板</span></div>
|
||||
<div class="control-btns">
|
||||
<button class="btn btn-warning wide" id="btn-pause" disabled>暂停任务</button>
|
||||
<button class="btn btn-success wide" id="btn-resume" disabled>继续任务</button>
|
||||
<button class="btn btn-danger wide" id="btn-rth" disabled>紧急返航</button>
|
||||
<button class="btn btn-danger wide" id="btn-mark-destroyed" disabled>标记无人机被摧毁</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card soldier-card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">在线士兵</span>
|
||||
<span class="card-badge" id="soldier-count">0</span>
|
||||
</div>
|
||||
<div id="soldier-list" class="list-scroll-content"></div>
|
||||
</div>
|
||||
<div class="card danger-card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">危险区域</span>
|
||||
<span class="card-badge danger" id="danger-count">0</span>
|
||||
</div>
|
||||
<div id="danger-zone-list" class="list-scroll-content"></div>
|
||||
</div>
|
||||
<div class="card log-card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">操作日志</span>
|
||||
<button class="btn-link" id="btn-clear-log">清除</button>
|
||||
</div>
|
||||
<div id="log-content" class="log-content"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===== 调度弹窗 ===== -->
|
||||
<div class="modal-overlay" id="modal-task" style="display:none">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<span class="modal-title">调度任务</span>
|
||||
<button class="modal-close" id="modal-close">×</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modal-body"></div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" id="modal-reject">拒绝</button>
|
||||
<button class="btn btn-primary" id="modal-dispatch">确认调度</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
<script src="/js/roslib.min.js"></script>
|
||||
<script src="/js/map.js"></script>
|
||||
<script src="/js/websocket.js"></script>
|
||||
<script src="/js/ui.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,134 @@
|
||||
/**
|
||||
* 热成像威胁检测模块
|
||||
* 负责: 接收热成像检测结果、在地图上标注威胁、更新威胁列表UI
|
||||
*/
|
||||
|
||||
const ThermalModule = (() => {
|
||||
let threats = [];
|
||||
let pollTimer = null;
|
||||
const POLL_INTERVAL = 3000; // ms
|
||||
|
||||
function init() {
|
||||
// 自动轮询模式 (如果有后端API)
|
||||
// startPolling('http://localhost:5000/api/threats');
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始轮询后端威胁数据
|
||||
* @param {string} apiUrl - 后端热成像API地址
|
||||
*/
|
||||
function startPolling(apiUrl) {
|
||||
stopPolling();
|
||||
pollTimer = setInterval(() => fetchThreats(apiUrl), POLL_INTERVAL);
|
||||
fetchThreats(apiUrl);
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
if (pollTimer) { clearInterval(pollTimer); pollTimer = null; }
|
||||
}
|
||||
|
||||
/**
|
||||
* 从后端获取最新威胁数据
|
||||
*/
|
||||
async function fetchThreats(apiUrl) {
|
||||
try {
|
||||
const resp = await fetch(apiUrl);
|
||||
if (!resp.ok) return;
|
||||
const data = await resp.json();
|
||||
if (data.threats && Array.isArray(data.threats)) {
|
||||
processThreats(data.threats);
|
||||
}
|
||||
} catch (e) {
|
||||
// 静默忽略网络错误
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接传入威胁数据 (用于手动推送或模拟)
|
||||
* @param {Array} newThreats - 威胁数组 [{lat, lng, level, description, time}]
|
||||
*/
|
||||
function processThreats(newThreats) {
|
||||
// 清除旧威胁标记
|
||||
MapModule.clearThreats();
|
||||
threats = newThreats;
|
||||
|
||||
// 在地图上添加标记
|
||||
newThreats.forEach(t => {
|
||||
MapModule.addThreatMarker(t.lat, t.lng, t.level, t.description);
|
||||
});
|
||||
|
||||
// 更新威胁列表UI
|
||||
renderThreatList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加单个威胁
|
||||
*/
|
||||
function addThreat(threat) {
|
||||
threats.push(threat);
|
||||
MapModule.addThreatMarker(threat.lat, threat.lng, threat.level, threat.description);
|
||||
renderThreatList();
|
||||
|
||||
if (threat.level === 'high') {
|
||||
UIModule.addLog('error', `热成像告警: ${threat.description} (${threat.lat.toFixed(4)}, ${threat.lng.toFixed(4)})`);
|
||||
} else {
|
||||
UIModule.addLog('warning', `威胁检测: ${threat.description}`);
|
||||
}
|
||||
}
|
||||
|
||||
function renderThreatList() {
|
||||
const container = document.getElementById('threat-list');
|
||||
if (!container) return;
|
||||
|
||||
if (threats.length === 0) {
|
||||
container.innerHTML = '<div class="empty-hint">暂无威胁检测</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
container.innerHTML = threats.map(t => `
|
||||
<div class="threat-item level-${t.level}">
|
||||
<span class="threat-dot ${t.level}"></span>
|
||||
<span class="threat-text">${t.description}</span>
|
||||
<span class="threat-time">${t.time || '--'}</span>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function getThreats() {
|
||||
return threats;
|
||||
}
|
||||
|
||||
function clearThreats() {
|
||||
threats = [];
|
||||
MapModule.clearThreats();
|
||||
renderThreatList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟威胁数据 (用于演示)
|
||||
*/
|
||||
function simulateThreats() {
|
||||
const baseLat = 30.0;
|
||||
const baseLng = 120.0;
|
||||
|
||||
const demo = [
|
||||
{ lat: baseLat + 0.0008, lng: baseLng - 0.0005, level: 'high', description: '热源: 人员活动', time: '14:32' },
|
||||
{ lat: baseLat - 0.0012, lng: baseLng + 0.001, level: 'medium', description: '热源: 车辆引擎', time: '14:28' },
|
||||
{ lat: baseLat + 0.0003, lng: baseLng + 0.0018, level: 'low', description: '热源: 动物', time: '14:25' }
|
||||
];
|
||||
|
||||
processThreats(demo);
|
||||
UIModule.addLog('info', '已加载模拟威胁数据 (3个热源)');
|
||||
}
|
||||
|
||||
return {
|
||||
init,
|
||||
startPolling,
|
||||
stopPolling,
|
||||
processThreats,
|
||||
addThreat,
|
||||
getThreats,
|
||||
clearThreats,
|
||||
simulateThreats
|
||||
};
|
||||
})();
|
||||
Loading…
Reference in new issue