242 lines
6.5 KiB
HTML
242 lines
6.5 KiB
HTML
<!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: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: #f5f7fa;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.header {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 20px;
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 24px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.user-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 15px;
|
|
}
|
|
|
|
.logout-btn {
|
|
background: rgba(255, 255, 255, 0.2);
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
color: white;
|
|
padding: 8px 15px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.logout-btn:hover {
|
|
background: rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 30px auto;
|
|
padding: 0 20px;
|
|
}
|
|
|
|
.dashboard-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.card {
|
|
background: white;
|
|
border-radius: 15px;
|
|
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
|
|
padding: 25px;
|
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
}
|
|
|
|
.card:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
|
|
}
|
|
|
|
.card h3 {
|
|
color: #333;
|
|
margin-bottom: 15px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.card p {
|
|
color: #666;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.device-control {
|
|
background: white;
|
|
border-radius: 15px;
|
|
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
|
|
padding: 25px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.control-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 20px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.control-item {
|
|
background: #f8f9fa;
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
.control-item h4 {
|
|
margin-bottom: 15px;
|
|
color: #333;
|
|
}
|
|
|
|
.control-buttons {
|
|
display: flex;
|
|
gap: 10px;
|
|
justify-content: center;
|
|
}
|
|
|
|
.control-btn {
|
|
padding: 8px 15px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.on-btn {
|
|
background: #28a745;
|
|
color: white;
|
|
}
|
|
|
|
.off-btn {
|
|
background: #dc3545;
|
|
color: white;
|
|
}
|
|
|
|
.control-btn:hover {
|
|
opacity: 0.9;
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.dashboard-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.header {
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
text-align: center;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>🐷 猪场管理系统</h1>
|
|
<div class="user-info">
|
|
<span id="username">用户</span>
|
|
<button class="logout-btn" id="logoutBtn">退出登录</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 移除了导航栏 -->
|
|
|
|
<div class="container">
|
|
<div class="dashboard-grid">
|
|
<div class="card">
|
|
<h3>📊 系统状态</h3>
|
|
<p>当前系统运行正常</p>
|
|
<p>连接设备: <span id="deviceCount">0</span> 台</p>
|
|
<p>今日操作: <span id="operationCount">0</span> 次</p>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🌡️ 环境监控</h3>
|
|
<p>温度: <span id="temperature">25.6</span>°C</p>
|
|
<p>湿度: <span id="humidity">65</span>%</p>
|
|
<p>空气质量: 良好</p>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>📡 设备连接</h3>
|
|
<p>中继设备: <span class="status-indicator status-online"></span>在线</p>
|
|
<p>风扇设备: <span class="status-indicator status-online"></span>在线</p>
|
|
<p>水帘设备: <span class="status-indicator status-offline"></span>离线</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="device-control">
|
|
<h2>⚙️ 设备控制</h2>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 检查用户是否已登录
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const token = localStorage.getItem('authToken');
|
|
const username = localStorage.getItem('username');
|
|
|
|
if (!token) {
|
|
// 未登录,跳转到登录页面
|
|
window.location.href = '/';
|
|
return;
|
|
}
|
|
|
|
// 显示用户名
|
|
if (username) {
|
|
document.getElementById('username').textContent = username;
|
|
}
|
|
});
|
|
|
|
// 退出登录
|
|
function logout() {
|
|
// 清除本地存储的认证信息
|
|
localStorage.removeItem('authToken');
|
|
localStorage.removeItem('userId');
|
|
localStorage.removeItem('username');
|
|
|
|
// 跳转到登录页面
|
|
window.location.href = '/';
|
|
}
|
|
|
|
// 控制设备
|
|
function controlDevice(deviceType, action) {
|
|
alert(`正在${action === 'on' ? '开启' : '关闭'}${deviceType === 'fan' ? '风机' : '水帘'}`);
|
|
// 这里应该调用实际的设备控制API
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |