|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import MainLayout from './components/layout/MainLayout';
|
|
|
|
|
import Dashboard from './pages/dashboard/Dashboard';
|
|
|
|
|
import Detail from './pages/detail/Detail';
|
|
|
|
|
import RiskControl from './pages/risk-control/RiskControl';
|
|
|
|
|
import Config from './pages/config/Config';
|
|
|
|
|
import './App.css';
|
|
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
|
const [currentMenu, setCurrentMenu] = useState('dashboard');
|
|
|
|
|
const [selectedFuture, setSelectedFuture] = useState({ code: 'MA', name: '甲醇' });
|
|
|
|
|
|
|
|
|
|
// 查看详细分析
|
|
|
|
|
const handleViewDetail = (code, name) => {
|
|
|
|
|
setSelectedFuture({ code, name });
|
|
|
|
|
setCurrentMenu('detail');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 渲染当前页面
|
|
|
|
|
const renderCurrentPage = () => {
|
|
|
|
|
switch (currentMenu) {
|
|
|
|
|
case 'dashboard':
|
|
|
|
|
return <Dashboard onViewDetail={handleViewDetail} />;
|
|
|
|
|
case 'detail':
|
|
|
|
|
return <Detail selectedFuture={selectedFuture} />;
|
|
|
|
|
case 'risk-control':
|
|
|
|
|
return <RiskControl />;
|
|
|
|
|
case 'config':
|
|
|
|
|
return <Config />;
|
|
|
|
|
default:
|
|
|
|
|
return <Dashboard onViewDetail={handleViewDetail} />;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<MainLayout currentMenu={currentMenu} onMenuSelect={setCurrentMenu}>
|
|
|
|
|
{renderCurrentPage()}
|
|
|
|
|
</MainLayout>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|