<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>高空发电项目</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #e7acef;
margin: 0;
}
h1 {
background-color: #007bff;
color: white;
padding: 20px;
margin: 0;
border-radius: 5px 5px 0 0;
}
#control-panel {
margin: 20px 0;
}
button {
padding: 15px 30px;
margin: 10px;
font-size: 18px;
color: white;
background-color: #007bff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #ff761f;
}
#weather-info {
margin: 20px auto;
padding: 20px;
background-color: white;
border-radius: 5px;
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
max-width: 400px;
}
#weather-info h2 {
margin: 0 0 15px;
color: #34340;
}
p {
font-size: 16px;
color: #495f57;
}
.weather-item {
margin: 5px 0;
}
#power-info {
margin: 20px auto;
padding: 20px;
background-color: white;
border-radius: 5px;
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
max-width: 400px;
}
#power-info h2 {
margin: 0 0 15px;
color: #34340;
}
.power-item {
margin: 5px 0;
}
</style>
</head>
<body>
<h1>高空发电缆绳控制</h1>
<div id="control-panel">
<button onclick="controlCable('up')">缆绳上升</button>
<button onclick="controlCable('down')">缆绳下降</button>
</div>
<div id="weather-info">
<h2>天气信息</h2>
<p class="weather-item">温度: <span id="temperature">--</span> °C</p>
<p class="weather-item">湿度: <span id="humidity">--</span> %</p>
<p class="weather-item">风力: <span id="wind-speed">--</span> m/s</p>
<p class="weather-item">风向: <span id="wind-direction">--</span></p>
<p class="weather-item">雨雪: <span id="precipitation">--</span></p>
</div>
<div id="power-info">
<h2>电力信息</h2>
<p class="power-item">电压: <span id="voltage">--</span> V</p>
<p class="power-item">电流: <span id="current">--</span> A</p>
</div>
<script>
function controlCable(direction) {
if (direction === 'up') {
alert('缆绳正在上升...');
} else if (direction === 'down') {
alert('缆绳正在下降...');
}
}
// 模拟天气数据更新
function updateWeatherInfo() {
document.getElementById('temperature').innerText = (Math.random() * 30).toFixed(1);
document.getElementById('humidity').innerText = (Math.random() * 100).toFixed(1);
document.getElementById('wind-speed').innerText = (Math.random() * 20).toFixed(1);
document.getElementById('wind-direction').innerText = ['北', '东', '南', '西'][Math.floor(Math.random() * 4)];
document.getElementById('precipitation').innerText = Math.random() > 0.5 ? '有雨' : '无雨';
}
// 模拟电力数据更新
function updatePowerInfo() {
document.getElementById('voltage').innerText = (Math.random() * 220).toFixed(1); // 模拟电压在 0 到 220V 之间
document.getElementById('current').innerText = (Math.random() * 10).toFixed(1); // 模拟电流在 0 到 10A 之间
}
// 每5秒更新一次天气信息
setInterval(updateWeatherInfo, 5000);
updateWeatherInfo(); // 页面加载时即更新一次
// 每5秒更新一次电力信息
setInterval(updatePowerInfo, 5000);
updatePowerInfo(); // 页面加载时即更新一次
</script>
</body>
</html>