事件标记线bug修复
This commit is contained in:
@@ -888,6 +888,10 @@ export function generateMockEvents(params = {}) {
|
||||
const tradingDate = new Date(createdAt);
|
||||
tradingDate.setDate(tradingDate.getDate() + 1);
|
||||
|
||||
// 生成投票数据
|
||||
const bullishCount = Math.floor(Math.random() * 100) + 5;
|
||||
const bearishCount = Math.floor(Math.random() * 50) + 3;
|
||||
|
||||
allEvents.push({
|
||||
id: i + 1,
|
||||
title: generateEventTitle(industry, i),
|
||||
@@ -901,6 +905,10 @@ export function generateMockEvents(params = {}) {
|
||||
trading_date: tradingDate.toISOString().split('T')[0], // YYYY-MM-DD 格式
|
||||
hot_score: hotScore,
|
||||
view_count: Math.floor(Math.random() * 10000),
|
||||
follower_count: Math.floor(Math.random() * 500) + 10,
|
||||
bullish_count: bullishCount,
|
||||
bearish_count: bearishCount,
|
||||
user_vote: null, // 默认未投票
|
||||
related_avg_chg: parseFloat(relatedAvgChg),
|
||||
related_max_chg: parseFloat(relatedMaxChg),
|
||||
related_week_chg: parseFloat(relatedWeekChg),
|
||||
@@ -1374,6 +1382,10 @@ export function generateDynamicNewsEvents(timeRange = null, count = 30) {
|
||||
...generateKeywords(industry, i).slice(0, 2)
|
||||
];
|
||||
|
||||
// 生成投票数据
|
||||
const bullishCount = Math.floor(Math.random() * 80) + 10;
|
||||
const bearishCount = Math.floor(Math.random() * 40) + 5;
|
||||
|
||||
events.push({
|
||||
id: `dynamic_${i + 1}`,
|
||||
title: eventTitle,
|
||||
@@ -1387,6 +1399,9 @@ export function generateDynamicNewsEvents(timeRange = null, count = 30) {
|
||||
hot_score: hotScore,
|
||||
view_count: Math.floor(Math.random() * 5000) + 1000, // 1000-6000 浏览量
|
||||
follower_count: Math.floor(Math.random() * 500) + 50, // 50-550 关注数
|
||||
bullish_count: bullishCount, // 看多数
|
||||
bearish_count: bearishCount, // 看空数
|
||||
user_vote: null, // 默认未投票
|
||||
post_count: Math.floor(Math.random() * 100) + 10, // 10-110 帖子数
|
||||
related_avg_chg: parseFloat(relatedAvgChg),
|
||||
related_max_chg: parseFloat(relatedMaxChg),
|
||||
|
||||
@@ -601,6 +601,56 @@ export const eventHandlers = [
|
||||
}
|
||||
}),
|
||||
|
||||
// 事件情绪投票(看多/看空)
|
||||
http.post('/api/events/:eventId/sentiment-vote', async ({ params, request }) => {
|
||||
await delay(200);
|
||||
|
||||
const { eventId } = params;
|
||||
const numericEventId = parseInt(eventId, 10);
|
||||
|
||||
console.log('[Mock] 事件情绪投票, eventId:', numericEventId);
|
||||
|
||||
try {
|
||||
const body = await request.json();
|
||||
const voteType = body.vote_type; // 'bullish', 'bearish', 或 null
|
||||
|
||||
// 使用内存状态管理投票
|
||||
// 简单模拟:根据 eventId 生成基础数据
|
||||
const baseBullish = (numericEventId * 7) % 50 + 10;
|
||||
const baseBearish = (numericEventId * 3) % 30 + 5;
|
||||
|
||||
// 根据投票类型调整计数
|
||||
let bullishCount = baseBullish;
|
||||
let bearishCount = baseBearish;
|
||||
|
||||
if (voteType === 'bullish') {
|
||||
bullishCount += 1;
|
||||
} else if (voteType === 'bearish') {
|
||||
bearishCount += 1;
|
||||
}
|
||||
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
user_vote: voteType || null,
|
||||
bullish_count: bullishCount,
|
||||
bearish_count: bearishCount,
|
||||
},
|
||||
message: voteType ? '投票成功' : '取消投票成功'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[Mock] 事件情绪投票失败:', error);
|
||||
return HttpResponse.json(
|
||||
{
|
||||
success: false,
|
||||
error: '投票失败',
|
||||
data: null
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}),
|
||||
|
||||
// 获取事件传导链分析数据
|
||||
http.get('/api/events/:eventId/transmission', async ({ params }) => {
|
||||
await delay(500);
|
||||
|
||||
Reference in New Issue
Block a user