From ab9f722f7844f82b9eafa68b802e05c90eac98d7 Mon Sep 17 00:00:00 2001 From: Lxy Date: Tue, 17 Feb 2026 23:39:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=A1=E7=89=87=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=BE=AE=E8=B0=83=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 13 +++- src/pages/dashboard/Dashboard.jsx | 123 +++++++++++++++++++++++++++--- src/pages/detail/Detail.jsx | 14 +++- 3 files changed, 134 insertions(+), 16 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 1c37eae..82894f6 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -8,20 +8,27 @@ 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 ; + return ; case 'detail': - return ; + return ; case 'risk-control': return ; case 'config': return ; default: - return ; + return ; } }; diff --git a/src/pages/dashboard/Dashboard.jsx b/src/pages/dashboard/Dashboard.jsx index 1bc7f0b..d45dd59 100644 --- a/src/pages/dashboard/Dashboard.jsx +++ b/src/pages/dashboard/Dashboard.jsx @@ -9,13 +9,14 @@ const { Search } = Input; const { Option } = Select; const { Column } = Table; -const Dashboard = () => { +const Dashboard = ({ onViewDetail }) => { const [futuresData, setFuturesData] = useState(allFuturesData); const [filteredData, setFilteredData] = useState(allFuturesData); const [loading, setLoading] = useState(false); const [viewMode, setViewMode] = useState('card'); // card or list const [filterType, setFilterType] = useState(''); const [filterKeyword, setFilterKeyword] = useState(''); + const [sortRule, setSortRule] = useState('original'); // original, hot, bullish, bearish, neutral // 模拟数据刷新 const handleRefresh = () => { @@ -32,10 +33,11 @@ const Dashboard = () => { }, 1000); }; - // 过滤数据 + // 过滤和排序数据 useEffect(() => { let result = futuresData; + // 过滤 if (filterKeyword) { const keyword = filterKeyword.toLowerCase(); result = result.filter(item => @@ -48,8 +50,47 @@ const Dashboard = () => { result = result.filter(item => item.type === filterType); } + // 排序 + switch (sortRule) { + case 'hot': + // 按涨跌幅绝对值排序(热点) + result.sort((a, b) => Math.abs(b.changePercent) - Math.abs(a.changePercent)); + break; + case 'bullish': + // 按看多趋势排序 + result.sort((a, b) => { + // 计算看多周期数量 + const aBullishCount = Object.values(a.trends).filter(trend => trend.direction === '看多').length; + const bBullishCount = Object.values(b.trends).filter(trend => trend.direction === '看多').length; + return bBullishCount - aBullishCount; + }); + break; + case 'bearish': + // 按看空趋势排序 + result.sort((a, b) => { + // 计算看空周期数量 + const aBearishCount = Object.values(a.trends).filter(trend => trend.direction === '看空').length; + const bBearishCount = Object.values(b.trends).filter(trend => trend.direction === '看空').length; + return bBearishCount - aBearishCount; + }); + break; + case 'neutral': + // 按观望趋势排序 + result.sort((a, b) => { + // 计算横盘震荡周期数量 + const aNeutralCount = Object.values(a.trends).filter(trend => trend.status.includes('震荡')).length; + const bNeutralCount = Object.values(b.trends).filter(trend => trend.status.includes('震荡')).length; + return bNeutralCount - aNeutralCount; + }); + break; + case 'original': + default: + // 保持原始序列 + break; + } + setFilteredData(result); - }, [futuresData, filterKeyword, filterType]); + }, [futuresData, filterKeyword, filterType, sortRule]); // 品种类型选项 const typeOptions = Array.from(new Set(allFuturesData.map(item => item.type))).map(type => ( @@ -152,10 +193,18 @@ const Dashboard = () => { {/* AI分析 */}
AI分析:
-
+
MACD: {item.aiAnalysis.macd}
{item.aiAnalysis.rsi}
+ @@ -194,7 +243,7 @@ const Dashboard = () => { style={{ width: '100%' }} /> - +