feat:添加mock接口
1. ✅ Profile 和 Settings 页面(2个文件) 2. ✅ EventDetail 页面(1个文件) 3. ✅ 身份验证组件(WechatRegister.js) 4. ✅ Company 页面(CompanyOverview, index, FinancialPanorama, MarketDataView) 5. ✅ Concept 页面(ConceptTimelineModal, ConceptStatsPanel, index)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { logger } from '../../../utils/logger';
|
||||
import {
|
||||
Box,
|
||||
SimpleGrid,
|
||||
@@ -96,7 +97,7 @@ const ConceptStatsPanel = ({ apiBaseUrl, onConceptClick }) => {
|
||||
throw new Error(`Concept API错误: ${response.status}`);
|
||||
}
|
||||
} catch (conceptApiError) {
|
||||
console.warn('concept-api路由失败,尝试直接访问:', conceptApiError.message);
|
||||
logger.warn('ConceptStatsPanel', 'concept-api路由失败,尝试直接访问', { error: conceptApiError.message, days, startDate, endDate });
|
||||
|
||||
// 备用方案:直接访问concept_api服务(开发环境回退)
|
||||
try {
|
||||
@@ -105,6 +106,7 @@ const ConceptStatsPanel = ({ apiBaseUrl, onConceptClick }) => {
|
||||
result = await response.json();
|
||||
if (result.success && result.data) {
|
||||
setStatsData(result.data);
|
||||
logger.info('ConceptStatsPanel', '统计数据加载成功(备用API)', { dataKeys: Object.keys(result.data) });
|
||||
return;
|
||||
} else {
|
||||
throw new Error(result.note || '直接API返回错误');
|
||||
@@ -113,20 +115,16 @@ const ConceptStatsPanel = ({ apiBaseUrl, onConceptClick }) => {
|
||||
throw new Error(`直接API错误: ${response.status}`);
|
||||
}
|
||||
} catch (directError) {
|
||||
console.error('所有API都失败:', directError);
|
||||
logger.error('ConceptStatsPanel', '所有API都失败', directError, { days, startDate, endDate });
|
||||
throw new Error('无法访问概念统计API');
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取统计数据失败:', error);
|
||||
toast({
|
||||
title: '获取统计数据失败',
|
||||
description: '正在使用默认数据,请稍后刷新重试',
|
||||
status: 'warning',
|
||||
duration: 3000,
|
||||
isClosable: true,
|
||||
});
|
||||
logger.error('ConceptStatsPanel', 'fetchStatsData', error, { days, startDate, endDate });
|
||||
|
||||
// ❌ 移除获取统计数据失败toast
|
||||
// toast({ title: '获取统计数据失败', description: '正在使用默认数据,请稍后刷新重试', status: 'warning', duration: 3000, isClosable: true });
|
||||
|
||||
// 使用简化的默认数据作为最后的fallback
|
||||
setStatsData({
|
||||
|
||||
Reference in New Issue
Block a user