feat: solar KPIs, version display, feature flags (v1.4.0)

New dashboard KPI cards:
- Performance Ratio (PR) with color thresholds
- Equivalent Utilization Hours
- Daily Revenue (¥)
- Self-Consumption Rate

Version display for field engineers:
- Login page footer: "v1.4.0 | Core: v1.4.0"
- Sidebar footer: version when expanded
- System Settings: full version breakdown

Backend (core sync):
- GET /api/v1/version (no auth) — reads VERSIONS.json
- GET /api/v1/kpi/solar — PR, revenue, equiv hours calculations
- Dashboard energy_today fallback from raw energy_data
- PV device filter includes sungrow_inverter type

Feature flags:
- Sidebar hides disabled features (charging, bigscreen_3d)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Du Wenbo
2026-04-06 22:37:09 +08:00
parent 1274e77cb4
commit 93af4bc16b
11 changed files with 275 additions and 13 deletions

View File

@@ -1,8 +1,8 @@
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { Form, Input, Button, Card, message, Typography } from 'antd';
import { UserOutlined, LockOutlined, ThunderboltOutlined } from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
import { login } from '../../services/api';
import { login, getVersion } from '../../services/api';
import { setToken, setUser } from '../../utils/auth';
const { Title, Text } = Typography;
@@ -10,8 +10,13 @@ const { Title, Text } = Typography;
export default function LoginPage() {
const [loading, setLoading] = useState(false);
const [guestLoading, setGuestLoading] = useState(false);
const [versionInfo, setVersionInfo] = useState<any>(null);
const navigate = useNavigate();
useEffect(() => {
getVersion().then(setVersionInfo).catch(() => {});
}, []);
const doLogin = async (username: string, password: string) => {
const res: any = await login(username, password);
setToken(res.access_token);
@@ -82,6 +87,11 @@ export default function LoginPage() {
</Text>
</div>
</Form>
{versionInfo && (
<div style={{ textAlign: 'center', marginTop: 16, opacity: 0.4, fontSize: 11 }}>
v{versionInfo.project_version} | Core: v{versionInfo.core_version || '—'}
</div>
)}
</Card>
</div>
);