更新Company页面的UI为FUI风格

This commit is contained in:
2025-12-22 17:19:52 +08:00
parent 3ef1e6ea29
commit 0b95953db9

View File

@@ -72,14 +72,15 @@ const formatEventTime = (dateStr) => {
* 单个事件项组件 - 带时间轴 * 单个事件项组件 - 带时间轴
*/ */
const TimelineEventItem = React.memo(({ event, isSelected, onEventClick, isHot }) => { 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 hasChange = changePct != null;
const isPositive = hasChange && changePct >= 0; const isPositive = hasChange && changePct >= 0;
return ( return (
<HStack <HStack
spacing={0} spacing={0}
align="stretch" align="flex-start"
w="100%" w="100%"
cursor="pointer" cursor="pointer"
onClick={() => onEventClick?.(event)} onClick={() => onEventClick?.(event)}
@@ -87,64 +88,33 @@ const TimelineEventItem = React.memo(({ event, isSelected, onEventClick, isHot }
borderRadius="md" borderRadius="md"
transition="all 0.15s" transition="all 0.15s"
bg={isSelected ? "rgba(66, 153, 225, 0.15)" : "transparent"} bg={isSelected ? "rgba(66, 153, 225, 0.15)" : "transparent"}
py={1}
>
{/* 左侧时间 */}
<Text
fontSize="xs"
color={COLORS.secondaryTextColor}
fontWeight="500"
w="52px"
flexShrink={0}
textAlign="right"
pr={2}
> >
{/* 左侧时间轴 */}
<VStack spacing={0} align="center" w="50px" flexShrink={0} position="relative">
{/* 时间显示 */}
<Text fontSize="xs" color={COLORS.secondaryTextColor} fontWeight="500">
{formatEventTime(event.created_at || event.event_time)} {formatEventTime(event.created_at || event.event_time)}
</Text> </Text>
{/* 时间轴线 */}
<Box
w="2px"
flex={1}
bg="rgba(255, 255, 255, 0.1)"
mt={1}
minH="20px"
/>
{/* 时间轴圆点 */}
<Box
position="absolute"
top="18px"
w="6px"
h="6px"
borderRadius="full"
bg={isHot ? "#f56565" : `${COLORS.secondaryTextColor}`}
border="2px solid"
borderColor={COLORS.cardBg}
/>
</VStack>
{/* 右侧内容 */} {/* 右侧内容 */}
<Box flex={1} py={1} pr={2} minW={0}> <Box flex={1} minW={0} pr={1}>
<HStack spacing={1} align="start">
{/* HOT 标签 */}
{isHot && (
<Badge
bg="linear-gradient(135deg, #f56565 0%, #ed8936 100%)"
color="white"
fontSize="10px"
px={1}
py={0}
borderRadius="sm"
flexShrink={0}
display="flex"
alignItems="center"
gap="2px"
>
<FireOutlined style={{ fontSize: 10 }} />
HOT
</Badge>
)}
<Text <Text
fontSize="xs" fontSize="xs"
color={COLORS.textColor} color={COLORS.textColor}
noOfLines={2} noOfLines={2}
flex={1} lineHeight="1.5"
lineHeight="1.4"
> >
{event.title} {event.title}
</Text> </Text>
</Box>
{/* 涨跌幅 */} {/* 涨跌幅 */}
{hasChange && ( {hasChange && (
<Text <Text
@@ -152,14 +122,14 @@ const TimelineEventItem = React.memo(({ event, isSelected, onEventClick, isHot }
fontWeight="bold" fontWeight="bold"
color={isPositive ? "#fc8181" : "#68d391"} color={isPositive ? "#fc8181" : "#68d391"}
flexShrink={0} flexShrink={0}
minW="45px"
textAlign="right"
> >
{isPositive ? "+" : ""} {isPositive ? "+" : ""}
{changePct.toFixed(1)}% {changePct.toFixed(1)}%
</Text> </Text>
)} )}
</HStack> </HStack>
</Box>
</HStack>
); );
}); });
@@ -194,13 +164,15 @@ const MainlineCard = React.memo(
let maxChange = -Infinity; let maxChange = -Infinity;
let hot = null; let hot = null;
mainline.events.forEach((event) => { 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) { if (change > maxChange) {
maxChange = change; maxChange = change;
hot = event; hot = event;
} }
}); });
return hot; // 只有当有正涨幅时才显示 HOT
return maxChange > 0 ? hot : null;
}, [mainline.events]); }, [mainline.events]);
const hotEventId = hotEvent?.id; const hotEventId = hotEvent?.id;
@@ -359,14 +331,14 @@ const MainlineCard = React.memo(
{hotEvent.title} {hotEvent.title}
</Text> </Text>
{/* HOT 事件涨幅 */} {/* HOT 事件涨幅 */}
{(hotEvent.max_change_pct ?? hotEvent.change_pct) != null && ( {(hotEvent.related_max_chg ?? hotEvent.related_avg_chg) != null && (
<Text <Text
fontSize="xs" fontSize="xs"
fontWeight="bold" fontWeight="bold"
color="#fc8181" color="#fc8181"
flexShrink={0} flexShrink={0}
> >
+{(hotEvent.max_change_pct ?? hotEvent.change_pct).toFixed(1)}% +{(hotEvent.related_max_chg ?? hotEvent.related_avg_chg).toFixed(1)}%
</Text> </Text>
)} )}
</HStack> </HStack>