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,5 +1,6 @@
|
||||
// src/views/Company/FinancialPanorama.jsx
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { logger } from '../../utils/logger';
|
||||
import {
|
||||
Box,
|
||||
Container,
|
||||
@@ -112,6 +113,7 @@ const FinancialPanorama = ({ stockCode: propStockCode }) => {
|
||||
// 加载所有财务数据
|
||||
const loadFinancialData = async () => {
|
||||
if (!stockCode || stockCode.length !== 6) {
|
||||
logger.warn('FinancialPanorama', 'loadFinancialData', '无效的股票代码', { stockCode });
|
||||
toast({
|
||||
title: '请输入有效的6位股票代码',
|
||||
status: 'warning',
|
||||
@@ -120,9 +122,10 @@ const FinancialPanorama = ({ stockCode: propStockCode }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug('FinancialPanorama', '开始加载财务数据', { stockCode, selectedPeriods });
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
|
||||
try {
|
||||
// 并行加载所有数据
|
||||
const [
|
||||
@@ -158,19 +161,14 @@ const FinancialPanorama = ({ stockCode: propStockCode }) => {
|
||||
if (rankRes.success) setIndustryRank(rankRes.data);
|
||||
if (comparisonRes.success) setComparison(comparisonRes.data);
|
||||
|
||||
toast({
|
||||
title: '财务数据加载成功',
|
||||
status: 'success',
|
||||
duration: 2000,
|
||||
});
|
||||
// ❌ 移除数据加载成功toast
|
||||
logger.info('FinancialPanorama', '财务数据加载成功', { stockCode });
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
toast({
|
||||
title: '数据加载失败',
|
||||
description: err.message,
|
||||
status: 'error',
|
||||
duration: 5000,
|
||||
});
|
||||
logger.error('FinancialPanorama', 'loadFinancialData', err, { stockCode, selectedPeriods });
|
||||
|
||||
// ❌ 移除数据加载失败toast
|
||||
// toast({ title: '数据加载失败', description: err.message, status: 'error', duration: 5000 });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -1501,6 +1499,7 @@ const FinancialPanorama = ({ stockCode: propStockCode }) => {
|
||||
|
||||
const loadCompareData = async () => {
|
||||
if (!compareStock || compareStock.length !== 6) {
|
||||
logger.warn('FinancialPanorama', 'loadCompareData', '无效的对比股票代码', { compareStock });
|
||||
toast({
|
||||
title: '请输入有效的6位股票代码',
|
||||
status: 'warning',
|
||||
@@ -1508,7 +1507,8 @@ const FinancialPanorama = ({ stockCode: propStockCode }) => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
logger.debug('FinancialPanorama', '开始加载对比数据', { currentStock, compareStock });
|
||||
setCompareLoading(true);
|
||||
try {
|
||||
const [stockInfoRes, metricsRes, comparisonRes] = await Promise.all([
|
||||
@@ -1516,25 +1516,20 @@ const FinancialPanorama = ({ stockCode: propStockCode }) => {
|
||||
financialService.getFinancialMetrics(compareStock, 4),
|
||||
financialService.getPeriodComparison(compareStock, 4)
|
||||
]);
|
||||
|
||||
|
||||
setCompareData({
|
||||
stockInfo: stockInfoRes.data,
|
||||
metrics: metricsRes.data,
|
||||
comparison: comparisonRes.data
|
||||
});
|
||||
|
||||
toast({
|
||||
title: '对比数据加载成功',
|
||||
status: 'success',
|
||||
duration: 2000,
|
||||
});
|
||||
|
||||
// ❌ 移除对比数据加载成功toast
|
||||
logger.info('FinancialPanorama', '对比数据加载成功', { currentStock, compareStock });
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: '加载对比数据失败',
|
||||
description: error.message,
|
||||
status: 'error',
|
||||
duration: 3000,
|
||||
});
|
||||
logger.error('FinancialPanorama', 'loadCompareData', error, { currentStock, compareStock });
|
||||
|
||||
// ❌ 移除对比数据加载失败toast
|
||||
// toast({ title: '加载对比数据失败', description: error.message, status: 'error', duration: 3000 });
|
||||
} finally {
|
||||
setCompareLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user