feat: 重构 TradingSimulation 和 Dashboard 组件

This commit is contained in:
zdl
2025-10-18 09:03:10 +08:00
parent ea627f867e
commit 32121c416e
8 changed files with 119 additions and 60 deletions

View File

@@ -1,5 +1,6 @@
// src/views/TradingSimulation/components/TradingPanel.js - 交易面板组件(现代化版本)
import React, { useState, useRef, useEffect } from 'react';
import { logger } from '../../../utils/logger';
import {
Box,
Card,
@@ -97,7 +98,7 @@ export default function TradingPanel({ account, onBuyStock, onSellStock, searchS
setFilteredStocks(formattedResults);
setShowStockList(true);
} catch (error) {
console.error('搜索股票失败:', error);
logger.error('TradingPanel', 'handleStockSearch', error, { searchTerm });
setFilteredStocks([]);
setShowStockList(false);
}
@@ -189,6 +190,14 @@ export default function TradingPanel({ account, onBuyStock, onSellStock, searchS
}
if (result.success) {
logger.info('TradingPanel', `${activeTab === 0 ? '买入' : '卖出'}成功`, {
orderId: result.orderId,
stockCode: selectedStock.code,
quantity,
orderType
});
// ✅ 保留交易成功toast关键用户操作反馈
toast({
title: activeTab === 0 ? '买入成功' : '卖出成功',
description: `订单号: ${result.orderId}`,
@@ -202,6 +211,13 @@ export default function TradingPanel({ account, onBuyStock, onSellStock, searchS
clearSelection();
}
} catch (error) {
logger.error('TradingPanel', `${activeTab === 0 ? '买入' : '卖出'}失败`, error, {
stockCode: selectedStock?.code,
quantity,
orderType
});
// ✅ 保留交易失败toast关键用户操作错误反馈
toast({
title: activeTab === 0 ? '买入失败' : '卖出失败',
description: error.message,