feat: customer frontend, Sungrow collector fixes, real data (v1.2.0)
- Add frontend/ at root (no Three.js, no Charging, green #52c41a theme) - Fix Sungrow collector: add curPage/size params, unit conversion - Fix station-level dedup to prevent double-counting - Add shared token cache for API rate limit protection - Add .githooks/pre-commit, CLAUDE.md, .gitignore - Update docker-compose.override.yml frontend -> ./frontend - Pin bcrypt in requirements.txt - Add BUYOFF_RESULTS_2026-04-05.md (39/43 pass) - Data accuracy: 0.0% diff vs iSolarCloud Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
84
frontend/src/App.tsx
Normal file
84
frontend/src/App.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { ConfigProvider, theme } from 'antd';
|
||||
import zhCN from 'antd/locale/zh_CN';
|
||||
import enUS from 'antd/locale/en_US';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ThemeProvider, useTheme } from './contexts/ThemeContext';
|
||||
import './i18n';
|
||||
import MainLayout from './layouts/MainLayout';
|
||||
import LoginPage from './pages/Login';
|
||||
import Dashboard from './pages/Dashboard';
|
||||
import Monitoring from './pages/Monitoring';
|
||||
import Analysis from './pages/Analysis';
|
||||
import Alarms from './pages/Alarms';
|
||||
import Carbon from './pages/Carbon';
|
||||
import Reports from './pages/Reports';
|
||||
import Devices from './pages/Devices';
|
||||
import DeviceDetail from './pages/DeviceDetail';
|
||||
import SystemManagement from './pages/System';
|
||||
import Quota from './pages/Quota';
|
||||
|
||||
import Maintenance from './pages/Maintenance';
|
||||
import DataQuery from './pages/DataQuery';
|
||||
import Management from './pages/Management';
|
||||
import Prediction from './pages/Prediction';
|
||||
import EnergyStrategy from './pages/EnergyStrategy';
|
||||
import AIOperations from './pages/AIOperations';
|
||||
import BigScreen from './pages/BigScreen';
|
||||
|
||||
import { isLoggedIn } from './utils/auth';
|
||||
|
||||
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
||||
if (!isLoggedIn()) return <Navigate to="/login" replace />;
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
function AppContent() {
|
||||
const { darkMode } = useTheme();
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
return (
|
||||
<ConfigProvider
|
||||
locale={i18n.language === 'en' ? enUS : zhCN}
|
||||
theme={{
|
||||
algorithm: darkMode ? theme.darkAlgorithm : theme.defaultAlgorithm,
|
||||
token: { colorPrimary: '#52c41a', borderRadius: 6 },
|
||||
}}
|
||||
>
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
<Route path="/bigscreen" element={<BigScreen />} />
|
||||
|
||||
<Route path="/" element={<ProtectedRoute><MainLayout /></ProtectedRoute>}>
|
||||
<Route index element={<Dashboard />} />
|
||||
<Route path="monitoring" element={<Monitoring />} />
|
||||
<Route path="devices" element={<Devices />} />
|
||||
<Route path="devices/:id" element={<DeviceDetail />} />
|
||||
<Route path="analysis" element={<Analysis />} />
|
||||
<Route path="alarms" element={<Alarms />} />
|
||||
<Route path="carbon" element={<Carbon />} />
|
||||
<Route path="reports" element={<Reports />} />
|
||||
<Route path="quota" element={<Quota />} />
|
||||
|
||||
<Route path="maintenance" element={<Maintenance />} />
|
||||
<Route path="data-query" element={<DataQuery />} />
|
||||
<Route path="management" element={<Management />} />
|
||||
<Route path="prediction" element={<Prediction />} />
|
||||
<Route path="energy-strategy" element={<EnergyStrategy />} />
|
||||
<Route path="ai-operations" element={<AIOperations />} />
|
||||
<Route path="system/*" element={<SystemManagement />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</ConfigProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<AppContent />
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user