feat: 重构文件数: 3 个主要页面文件

- 替换 console 调用: 约 18 个
  - 移除非关键 toast: 6 个
  - 保留关键 toast: 2 个(搜索相关的用户操作反馈)
  - 添加 logger 日志: 约 15 处
This commit is contained in:
zdl
2025-10-18 09:17:40 +08:00
parent 32121c416e
commit c1bea7a75d
3 changed files with 67 additions and 60 deletions

View File

@@ -48,6 +48,7 @@ import { AdvancedSearch, SearchResultsModal } from './components/SearchComponent
// 导入高位股统计组件
import HighPositionStocks from './components/HighPositionStocks';
import { logger } from '../../utils/logger';
// 主组件
export default function LimitAnalyse() {
@@ -109,9 +110,12 @@ export default function LimitAnalyse() {
const data = await response.json();
if (data.success) {
setAvailableDates(data.events);
logger.debug('LimitAnalyse', '可用日期加载成功', {
count: data.events?.length || 0
});
}
} catch (error) {
console.error('Failed to fetch available dates:', error);
logger.error('LimitAnalyse', 'fetchAvailableDates', error);
}
};
@@ -126,22 +130,15 @@ export default function LimitAnalyse() {
// 获取词云数据
fetchWordCloudData(date);
toast({
title: '数据加载成功',
description: `${date} 的数据已加载`,
status: 'success',
duration: 2000,
isClosable: true,
logger.debug('LimitAnalyse', '每日分析数据加载成功', {
date,
totalStocks: data.data?.total_stocks || 0
});
// ❌ 移除数据加载成功 toast非关键操作
}
} catch (error) {
console.error('Failed to fetch daily analysis:', error);
toast({
title: '网络错误',
description: '无法加载数据,请稍后重试',
status: 'error',
duration: 3000,
});
logger.error('LimitAnalyse', 'fetchDailyAnalysis', error, { date });
// ❌ 移除数据加载失败 toast非关键操作
} finally {
setLoading(false);
}
@@ -153,9 +150,13 @@ export default function LimitAnalyse() {
const data = await response.json();
if (data.success) {
setWordCloudData(data.data);
logger.debug('LimitAnalyse', '词云数据加载成功', {
date,
count: data.data?.length || 0
});
}
} catch (error) {
console.error('Failed to fetch wordcloud data:', error);
logger.error('LimitAnalyse', 'fetchWordCloudData', error, { date });
}
};
@@ -188,6 +189,10 @@ export default function LimitAnalyse() {
if (data.success) {
setSearchResults(data.data);
setIsSearchOpen(true);
logger.info('LimitAnalyse', '搜索完成', {
resultCount: data.data?.total || 0,
searchParams
});
toast({
title: '搜索完成',
description: `找到 ${data.data.total} 只相关股票`,
@@ -196,7 +201,7 @@ export default function LimitAnalyse() {
});
}
} catch (error) {
console.error('Search failed:', error);
logger.error('LimitAnalyse', 'handleSearch', error, { searchParams });
toast({
title: '搜索失败',
description: '请稍后重试',