天气 动图 接入

This commit is contained in:
mmc
2026-05-12 14:13:54 +08:00
parent 5c15215a99
commit 78ee2d5c09
10 changed files with 2588 additions and 18 deletions

View File

@@ -8,7 +8,8 @@ import {
DashboardOutlined
} from '@ant-design/icons';
import { Line, Bar, Pie } from '@ant-design/charts';
import { getWeatherData } from '../lib/utils';
import { getWeatherData, getWeatherType } from '../lib/utils';
import WeatherDisplay from '../components/Weather';
@@ -29,6 +30,7 @@ export default function StationDashboard() {
humidity: 53,
report_time: "2026-03-27 12:35:08"
});
const weatherType = getWeatherType(weatherdata.weather);
// 请求天气接口
useEffect(() => {
@@ -638,27 +640,48 @@ export default function StationDashboard() {
style={{
borderRadius: 8,
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
padding: '4px 8px'
padding: '8px',
}}
bodyStyle={{ padding: 4 }}
bodyStyle={{ padding: 8 }}
>
<div style={{ display: 'flex', alignItems: 'center', position: 'relative', }}>
{/* 右侧文字 */}
<div style={{ display: 'flex', flexDirection: 'row', gap: 24, alignItems: 'center', width: "100%" }}>
<div>
<div style={{ fontSize: 24, fontWeight: 800, color: '#1890ff' }}>{weatherdata.temperature}℃</div>
<div style={{ fontSize: 14, color: '#666' }}>{weatherdata.weather}</div>
</div>
<div>
<div style={{ fontSize: 11, color: '#999' }}>湿度 {weatherdata.humidity}%</div>
<div style={{ fontSize: 11, color: '#999' }}>{weatherdata.wind_direction} {weatherdata.wind_power}</div>
<div style={{ fontSize: 11, color: '#999' }}>{weatherdata.city} | {weatherdata.district}</div>
</div>
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 24,
height: '100%'
}}
>
{/* 左侧:动态天气图标 */}
<div
style={{
width: 60,
height: 60,
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
>
<WeatherDisplay type={weatherType} />
</div>
{/* 右侧:天气信息 */}
<div style={{ flex: 1, flexDirection: "row" }}>
<div style={{ fontSize: 28, fontWeight: 800, color: '#1890ff' }}>
{weatherdata.temperature}℃
</div>
<div>
<div style={{ fontSize: 14, color: '#333', marginBottom: 6 }}>
{weatherdata.weather}
</div>
<div style={{ fontSize: 12, color: '#666', lineHeight: 1.6 }}>
<div>湿度 {weatherdata.humidity}%</div>
<div>{weatherdata.wind_direction} {weatherdata.wind_power}</div>
<div>{weatherdata.city} · {weatherdata.district}</div>
</div>
</div>
</div>
</div>
</Card>
{/* 清洗建议 */}