feat: 重构 TradingSimulation 和 Dashboard 组件
This commit is contained in:
@@ -34,6 +34,7 @@ import {
|
||||
Link,
|
||||
} from '@chakra-ui/react';
|
||||
import { useAuth } from '../../contexts/AuthContext';
|
||||
import { logger } from '../../utils/logger';
|
||||
|
||||
// 导入子组件
|
||||
import AccountOverview from './components/AccountOverview';
|
||||
@@ -86,9 +87,11 @@ export default function TradingSimulation() {
|
||||
|
||||
// 调试:观察认证状态变化
|
||||
useEffect(() => {
|
||||
try {
|
||||
console.log('🔍 TradingSimulation mounted. isAuthenticated=', isAuthenticated, 'user=', user);
|
||||
} catch {}
|
||||
logger.debug('TradingSimulation', '组件挂载,认证状态检查', {
|
||||
isAuthenticated,
|
||||
userId: user?.id,
|
||||
userName: user?.name
|
||||
});
|
||||
}, [isAuthenticated, user]);
|
||||
|
||||
// 获取资产历史数据的 useEffect
|
||||
@@ -96,8 +99,15 @@ export default function TradingSimulation() {
|
||||
if (account) {
|
||||
getAssetHistory(30).then(data => {
|
||||
setAssetHistory(data || []);
|
||||
logger.debug('TradingSimulation', '资产历史数据加载成功', {
|
||||
accountId: account.id,
|
||||
dataPoints: data?.length || 0
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('获取资产历史失败:', err);
|
||||
logger.error('TradingSimulation', 'getAssetHistory', err, {
|
||||
accountId: account?.id,
|
||||
days: 30
|
||||
});
|
||||
setAssetHistory([]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user