diff --git a/src/views/Community/components/DynamicNews/layouts/MainlineTimelineView.js b/src/views/Community/components/DynamicNews/layouts/MainlineTimelineView.js index cf6a7ef6..383d0be7 100644 --- a/src/views/Community/components/DynamicNews/layouts/MainlineTimelineView.js +++ b/src/views/Community/components/DynamicNews/layouts/MainlineTimelineView.js @@ -72,14 +72,15 @@ const formatEventTime = (dateStr) => { * 单个事件项组件 - 带时间轴 */ const TimelineEventItem = React.memo(({ event, isSelected, onEventClick, isHot }) => { - const changePct = event.max_change_pct ?? event.change_pct; + // 使用后端返回的字段:related_max_chg(最大涨幅)或 related_avg_chg(平均涨幅) + const changePct = event.related_max_chg ?? event.related_avg_chg ?? event.max_change_pct ?? event.change_pct; const hasChange = changePct != null; const isPositive = hasChange && changePct >= 0; return ( onEventClick?.(event)} @@ -87,78 +88,47 @@ const TimelineEventItem = React.memo(({ event, isSelected, onEventClick, isHot } borderRadius="md" transition="all 0.15s" bg={isSelected ? "rgba(66, 153, 225, 0.15)" : "transparent"} + py={1} > - {/* 左侧时间轴 */} - - {/* 时间显示 */} - - {formatEventTime(event.created_at || event.event_time)} - - {/* 时间轴线 */} - - {/* 时间轴圆点 */} - - + {/* 左侧时间 */} + + {formatEventTime(event.created_at || event.event_time)} + {/* 右侧内容 */} - - - {/* HOT 标签 */} - {isHot && ( - - - HOT - - )} - - {event.title} - - {/* 涨跌幅 */} - {hasChange && ( - - {isPositive ? "+" : ""} - {changePct.toFixed(1)}% - - )} - + + + {event.title} + + + {/* 涨跌幅 */} + {hasChange && ( + + {isPositive ? "+" : ""} + {changePct.toFixed(1)}% + + )} ); }); @@ -194,13 +164,15 @@ const MainlineCard = React.memo( let maxChange = -Infinity; let hot = null; mainline.events.forEach((event) => { - const change = event.max_change_pct ?? event.change_pct ?? -Infinity; + // 使用后端返回的字段:related_max_chg(最大涨幅) + const change = event.related_max_chg ?? event.related_avg_chg ?? event.max_change_pct ?? event.change_pct ?? -Infinity; if (change > maxChange) { maxChange = change; hot = event; } }); - return hot; + // 只有当有正涨幅时才显示 HOT + return maxChange > 0 ? hot : null; }, [mainline.events]); const hotEventId = hotEvent?.id; @@ -359,14 +331,14 @@ const MainlineCard = React.memo( {hotEvent.title} {/* HOT 事件涨幅 */} - {(hotEvent.max_change_pct ?? hotEvent.change_pct) != null && ( + {(hotEvent.related_max_chg ?? hotEvent.related_avg_chg) != null && ( - +{(hotEvent.max_change_pct ?? hotEvent.change_pct).toFixed(1)}% + +{(hotEvent.related_max_chg ?? hotEvent.related_avg_chg).toFixed(1)}% )}