refactor: Community 目录结构重组 + 修复导入路径 + 添加 Mock 数据

## 目录重构
- DynamicNewsCard/ → DynamicNews/(含 layouts/, hooks/ 子目录)
- EventCard 原子组件 → EventCard/atoms/
- EventDetailModal 独立目录化
- HotEvents 独立目录化(含 CSS)
- SearchFilters 独立目录化(CompactSearchBox, TradingTimeFilter)

## 导入路径修复
- EventCard/*.js: 统一使用 @constants/, @utils/, @components/ 别名
- atoms/*.js: 修复移动后的相对路径问题
- DynamicNewsCard.js: 更新 contexts, store, constants 导入
- EventHeaderInfo.js, CompactMetaBar.js: 修复 EventFollowButton 导入

## Mock Handler 添加
- /api/events/:eventId/expectation-score - 事件超预期得分
- /api/index/:indexCode/realtime - 指数实时行情

## 警告修复
- CitationMark.js: overlayInnerStyle → styles (Antd 5.x)
- CitedContent.js: 移除不支持的 jsx 属性

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-09 13:16:43 +08:00
parent c704b12bce
commit 15f5c445c5
47 changed files with 409 additions and 76 deletions

View File

@@ -297,6 +297,45 @@ export const eventHandlers = [
}
}),
// 获取事件超预期得分
http.get('/api/events/:eventId/expectation-score', async ({ params }) => {
await delay(200);
const { eventId } = params;
console.log('[Mock] 获取事件超预期得分, eventId:', eventId);
try {
// 生成模拟的超预期得分数据
const score = parseFloat((Math.random() * 100).toFixed(1));
const avgChange = parseFloat((Math.random() * 10 - 2).toFixed(2));
const maxChange = parseFloat((Math.random() * 15).toFixed(2));
return HttpResponse.json({
success: true,
data: {
event_id: parseInt(eventId),
expectation_score: score,
avg_change: avgChange,
max_change: maxChange,
stock_count: Math.floor(Math.random() * 20) + 5,
updated_at: new Date().toISOString(),
},
message: '获取成功'
});
} catch (error) {
console.error('[Mock] 获取事件超预期得分失败:', error);
return HttpResponse.json(
{
success: false,
error: '获取事件超预期得分失败',
data: null
},
{ status: 500 }
);
}
}),
// 获取事件相关股票
http.get('/api/events/:eventId/stocks', async ({ params }) => {
await delay(300);

View File

@@ -8,6 +8,53 @@ import { generateMarketData } from '../data/market';
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
export const marketHandlers = [
// 0. 指数实时行情数据
http.get('/api/index/:indexCode/realtime', async ({ params }) => {
await delay(100);
const { indexCode } = params;
console.log('[Mock] 获取指数实时行情, indexCode:', indexCode);
// 指数基础数据
const indexData = {
'000001': { name: '上证指数', basePrice: 3200, baseVolume: 3500 },
'399001': { name: '深证成指', basePrice: 10500, baseVolume: 4200 },
'399006': { name: '创业板指', basePrice: 2100, baseVolume: 1800 },
'000300': { name: '沪深300', basePrice: 3800, baseVolume: 2800 },
'000016': { name: '上证50', basePrice: 2600, baseVolume: 1200 },
'000905': { name: '中证500', basePrice: 5800, baseVolume: 1500 },
};
const baseData = indexData[indexCode] || { name: `指数${indexCode}`, basePrice: 3000, baseVolume: 2000 };
// 生成随机波动
const changePercent = parseFloat((Math.random() * 4 - 2).toFixed(2)); // -2% ~ +2%
const price = parseFloat((baseData.basePrice * (1 + changePercent / 100)).toFixed(2));
const change = parseFloat((price - baseData.basePrice).toFixed(2));
const volume = parseFloat((baseData.baseVolume * (0.8 + Math.random() * 0.4)).toFixed(2)); // 80%-120% of base
const amount = parseFloat((volume * price / 10000).toFixed(2)); // 亿元
return HttpResponse.json({
success: true,
data: {
index_code: indexCode,
index_name: baseData.name,
current_price: price,
change: change,
change_percent: changePercent,
open_price: parseFloat((baseData.basePrice * (1 + (Math.random() * 0.01 - 0.005))).toFixed(2)),
high_price: parseFloat((price * (1 + Math.random() * 0.01)).toFixed(2)),
low_price: parseFloat((price * (1 - Math.random() * 0.01)).toFixed(2)),
prev_close: baseData.basePrice,
volume: volume, // 亿手
amount: amount, // 亿元
update_time: new Date().toISOString(),
market_status: 'trading', // trading, closed, pre-market, after-hours
},
message: '获取成功'
});
}),
// 1. 成交数据
http.get('/api/market/trade/:stockCode', async ({ params, request }) => {
await delay(200);