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>
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import os
|
|
import json
|
|
from fastapi import APIRouter
|
|
|
|
router = APIRouter(prefix="/version", tags=["版本信息"])
|
|
|
|
|
|
@router.get("")
|
|
async def get_version():
|
|
"""Return platform version information for display on login/dashboard"""
|
|
# Read VERSIONS.json from project root (2 levels up from backend/)
|
|
backend_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
# Try multiple paths for VERSIONS.json
|
|
for path in [
|
|
os.path.join(backend_dir, "VERSIONS.json"), # standalone
|
|
os.path.join(backend_dir, "..", "VERSIONS.json"), # inside core/ subtree
|
|
os.path.join(backend_dir, "..", "..", "VERSIONS.json"), # customer project root
|
|
]:
|
|
if os.path.exists(path):
|
|
with open(path, 'r', encoding='utf-8') as f:
|
|
versions = json.load(f)
|
|
return versions
|
|
|
|
# Fallback: read VERSION file
|
|
version_file = os.path.join(backend_dir, "VERSION")
|
|
version = "unknown"
|
|
if os.path.exists(version_file):
|
|
with open(version_file, 'r') as f:
|
|
version = f.read().strip()
|
|
|
|
return {"project_version": version, "project": "ems-core"}
|