update /api/events/<int:event_id>/stocks resp format

This commit is contained in:
2025-10-23 08:18:13 +08:00
parent 0a28f235d3
commit 0b1591c3dd
22 changed files with 144 additions and 2317 deletions

View File

@@ -180,8 +180,13 @@ const EventList = ({ events, pagination, onPageChange, onEventClick, onViewDetai
importance: 'all',
enabled: true,
onNewEvent: (event) => {
console.log('\n[EventList DEBUG] ========== EventList 收到新事件 ==========');
console.log('[EventList DEBUG] 事件数据:', event);
console.log('[EventList DEBUG] 事件 ID:', event?.id);
console.log('[EventList DEBUG] 事件标题:', event?.title);
logger.info('EventList', '收到新事件推送', event);
console.log('[EventList DEBUG] 准备显示 Toast 通知');
// 显示 Toast 通知
toast({
title: '新事件发布',
@@ -192,18 +197,28 @@ const EventList = ({ events, pagination, onPageChange, onEventClick, onViewDetai
position: 'top-right',
variant: 'left-accent',
});
console.log('[EventList DEBUG] ✓ Toast 通知已显示');
console.log('[EventList DEBUG] 准备更新事件列表');
// 将新事件添加到列表顶部(防止重复)
setLocalEvents((prevEvents) => {
console.log('[EventList DEBUG] 当前事件列表数量:', prevEvents.length);
const exists = prevEvents.some(e => e.id === event.id);
console.log('[EventList DEBUG] 事件是否已存在:', exists);
if (exists) {
logger.debug('EventList', '事件已存在,跳过添加', { eventId: event.id });
console.log('[EventList DEBUG] ⚠️ 事件已存在,跳过添加');
return prevEvents;
}
logger.info('EventList', '新事件添加到列表顶部', { eventId: event.id });
console.log('[EventList DEBUG] ✓ 新事件添加到列表顶部');
// 添加到顶部,最多保留 100 个
return [event, ...prevEvents].slice(0, 100);
const updatedEvents = [event, ...prevEvents].slice(0, 100);
console.log('[EventList DEBUG] 更新后事件列表数量:', updatedEvents.length);
return updatedEvents;
});
console.log('[EventList DEBUG] ✓ 事件列表更新完成');
console.log('[EventList DEBUG] ========== EventList 处理完成 ==========\n');
}
});