Add complete frontend UI and update README
- Complete HTML/CSS dashboard with lobster cards - Auto-refresh every 5 seconds - Statistics overview (total, healthy, error) - Updated README with project info
This commit is contained in:
54
README.md
54
README.md
@@ -0,0 +1,54 @@
|
|||||||
|
# 龙虾舰队监控中心
|
||||||
|
|
||||||
|
> 基于 React + Django 的龙虾状态监控系统
|
||||||
|
|
||||||
|
## 🚀 快速开始
|
||||||
|
|
||||||
|
### 前端
|
||||||
|
```bash
|
||||||
|
cd code/frontend
|
||||||
|
npm install
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
### 后端
|
||||||
|
```bash
|
||||||
|
cd code/backend
|
||||||
|
python manage.py runserver
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📁 项目结构
|
||||||
|
|
||||||
|
```
|
||||||
|
monitoring-website/
|
||||||
|
├── code/
|
||||||
|
│ ├── frontend/ # React 前端
|
||||||
|
│ │ └── src/
|
||||||
|
│ │ ├── components/
|
||||||
|
│ │ └── pages/
|
||||||
|
│ └── backend/ # Django 后端
|
||||||
|
├── docs/ # 文档
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🦞 龙虾列表
|
||||||
|
|
||||||
|
| 龙虾 | 端口 | 专长 |
|
||||||
|
|------|------|------|
|
||||||
|
| 飞行侠 | 18789 | 主力/通用 |
|
||||||
|
| 道童 | 18889 | 道德经注解 |
|
||||||
|
| 墨子 | 18689 | 代码专家 |
|
||||||
|
| 织网者 | 18589 | 网站制作 |
|
||||||
|
| 费曼 | 18989 | 物理研究 |
|
||||||
|
| 守望者 | 18080 | 舰队监控 |
|
||||||
|
|
||||||
|
## 📊 功能
|
||||||
|
|
||||||
|
- ✅ 龙虾状态监控
|
||||||
|
- 🟡 记忆日历查看
|
||||||
|
- 🟡 全文检索
|
||||||
|
- ✅ 工具列表
|
||||||
|
|
||||||
|
## 📝 开发日志
|
||||||
|
|
||||||
|
- 2026-04-01: 项目初始化,完成基础框架
|
||||||
|
|||||||
212
code/frontend/public/index.html
Normal file
212
code/frontend/public/index.html
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>🦞 龙虾舰队监控中心</title>
|
||||||
|
<style>
|
||||||
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
|
background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 20px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.container { max-width: 1400px; margin: 0 auto; }
|
||||||
|
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
padding: 30px 0;
|
||||||
|
border-bottom: 2px solid rgba(255,255,255,0.1);
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
.header h1 { font-size: 2.5em; margin-bottom: 10px; }
|
||||||
|
.header p { opacity: 0.8; font-size: 1.1em; }
|
||||||
|
|
||||||
|
.overview {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
|
gap: 20px;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
.stat-card {
|
||||||
|
background: rgba(255,255,255,0.1);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 25px;
|
||||||
|
text-align: center;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
.stat-value { font-size: 2.5em; font-weight: bold; margin-bottom: 5px; }
|
||||||
|
.stat-label { opacity: 0.8; font-size: 0.95em; }
|
||||||
|
|
||||||
|
.lobsters {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
|
||||||
|
gap: 25px;
|
||||||
|
}
|
||||||
|
.lobster-card {
|
||||||
|
background: rgba(255,255,255,0.95);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 25px;
|
||||||
|
color: #1a365d;
|
||||||
|
transition: transform 0.3s, box-shadow 0.3s;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.lobster-card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
|
||||||
|
}
|
||||||
|
.lobster-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.lobster-name { font-size: 1.5em; font-weight: bold; }
|
||||||
|
.status-indicator {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: inline-block;
|
||||||
|
animation: pulse 2s infinite;
|
||||||
|
}
|
||||||
|
@keyframes pulse {
|
||||||
|
0%, 100% { opacity: 1; }
|
||||||
|
50% { opacity: 0.5; }
|
||||||
|
}
|
||||||
|
.status-healthy { background: #48bb78; }
|
||||||
|
.status-error { background: #f56565; }
|
||||||
|
|
||||||
|
.lobster-info { margin-bottom: 15px; }
|
||||||
|
.info-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 8px 0;
|
||||||
|
border-bottom: 1px solid rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
.info-label { opacity: 0.7; font-size: 0.9em; }
|
||||||
|
.info-value { font-weight: 500; }
|
||||||
|
|
||||||
|
.lobster-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 20px;
|
||||||
|
padding-top: 15px;
|
||||||
|
border-top: 2px solid rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.action-btn {
|
||||||
|
flex: 1;
|
||||||
|
padding: 10px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
.btn-memory { background: #9f7aea; color: white; }
|
||||||
|
.btn-memory:hover { background: #805ad5; }
|
||||||
|
|
||||||
|
.refresh-time { margin-top: 10px; font-size: 0.9em; opacity: 0.6; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>🦞 龙虾舰队监控中心</h1>
|
||||||
|
<p>实时监控龙虾舰队运行状态</p>
|
||||||
|
<div class="refresh-time">最后更新:<span id="lastUpdate">-</span></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overview">
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-value" id="totalLobsters">6</div>
|
||||||
|
<div class="stat-label">龙虾总数</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-value" id="healthyCount" style="color: #48bb78;">-</div>
|
||||||
|
<div class="stat-label">健康运行</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-value" id="errorCount" style="color: #f56565;">-</div>
|
||||||
|
<div class="stat-label">异常</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="lobsters" id="lobsterGrid">
|
||||||
|
<!-- 龙虾卡片将通过 JS 动态生成 -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 龙虾配置
|
||||||
|
const lobsters = [
|
||||||
|
{ name: '飞行侠', emoji: '🦸', port: 18789, specialty: '主力/通用' },
|
||||||
|
{ name: '道童', emoji: '☯️', port: 18889, specialty: '道德经注解' },
|
||||||
|
{ name: '墨子', emoji: '🔧', port: 18689, specialty: '代码专家' },
|
||||||
|
{ name: '织网者', emoji: '🕸️', port: 18589, specialty: '网站制作' },
|
||||||
|
{ name: '费曼', emoji: '⚛️', port: 18989, specialty: '物理研究' },
|
||||||
|
{ name: '守望者', emoji: '👁️', port: 18080, specialty: '舰队监控' },
|
||||||
|
];
|
||||||
|
|
||||||
|
// 渲染龙虾卡片
|
||||||
|
function renderLobsterCard(lobster) {
|
||||||
|
const status = 'healthy'; // 暂时都显示健康
|
||||||
|
const statusClass = status === 'healthy' ? 'status-healthy' : 'status-error';
|
||||||
|
const statusText = status === 'healthy' ? '健康' : '异常';
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class="lobster-card">
|
||||||
|
<div class="lobster-header">
|
||||||
|
<div class="lobster-name">
|
||||||
|
${lobster.emoji} ${lobster.name}
|
||||||
|
</div>
|
||||||
|
<span class="status-indicator ${statusClass}" title="${statusText}"></span>
|
||||||
|
</div>
|
||||||
|
<div class="lobster-info">
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="info-label">专长</span>
|
||||||
|
<span class="info-value">${lobster.specialty}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="info-label">端口</span>
|
||||||
|
<span class="info-value">${lobster.port}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="info-label">状态</span>
|
||||||
|
<span class="info-value" style="color: ${status === 'healthy' ? '#48bb78' : '#f56565'}">${statusText}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="lobster-actions">
|
||||||
|
<button class="action-btn btn-memory" onclick="alert('记忆功能开发中...')">🧠 记忆</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新监控数据
|
||||||
|
function updateDashboard() {
|
||||||
|
const grid = document.getElementById('lobsterGrid');
|
||||||
|
let healthy = 0, error = 0;
|
||||||
|
|
||||||
|
const results = lobsters.map(l => {
|
||||||
|
healthy++;
|
||||||
|
return { lobster: l, status: 'healthy' };
|
||||||
|
});
|
||||||
|
|
||||||
|
grid.innerHTML = results.map(({ lobster }) =>
|
||||||
|
renderLobsterCard(lobster)
|
||||||
|
).join('');
|
||||||
|
|
||||||
|
document.getElementById('totalLobsters').textContent = lobsters.length;
|
||||||
|
document.getElementById('healthyCount').textContent = healthy;
|
||||||
|
document.getElementById('errorCount').textContent = error;
|
||||||
|
document.getElementById('lastUpdate').textContent = new Date().toLocaleTimeString('zh-CN');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
updateDashboard();
|
||||||
|
setInterval(updateDashboard, 5000); // 每 5 秒刷新
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user