update ui

This commit is contained in:
2025-11-13 17:51:47 +08:00
parent 8dc4ddac66
commit dfa2635b2e

View File

@@ -74,7 +74,7 @@ const fetchPopularConcepts = async () => {
}, },
body: JSON.stringify({ body: JSON.stringify({
query: '', query: '',
size: 80, // 获取前80个概念 size: 60, // 获取前60个概念
page: 1, page: 1,
sort_by: 'change_pct' sort_by: 'change_pct'
}) })
@@ -455,8 +455,8 @@ const ConceptFlowAnimation = () => {
); );
} }
// 将 80 个概念均匀分成 5 行(每行 16 个) // 将 60 个概念均匀分成 3 行(每行 20 个)
const rowCount = 5; const rowCount = 3;
const conceptsPerRow = Math.ceil(concepts.length / rowCount); const conceptsPerRow = Math.ceil(concepts.length / rowCount);
const rows = []; const rows = [];
@@ -466,18 +466,28 @@ const ConceptFlowAnimation = () => {
rows.push(concepts.slice(start, end)); rows.push(concepts.slice(start, end));
} }
// 根据涨跌幅计算字体大小(涨跌幅越大,字体越大)
const getFontSize = (changePct) => {
const absChange = Math.abs(changePct);
if (absChange >= 10) return 'md'; // 超大涨跌
if (absChange >= 7) return 'sm'; // 大涨跌
if (absChange >= 5) return 'sm'; // 中涨跌
if (absChange >= 3) return 'xs'; // 小涨跌
return 'xs'; // 微涨跌
};
return ( return (
<VStack spacing={1} h="200px" justify="center" overflow="hidden" position="relative" w="100%"> <VStack spacing={3} h="200px" justify="center" overflow="hidden" position="relative" w="100%">
{rows.map((row, rowIndex) => { {rows.map((row, rowIndex) => {
// 每行不同的速度第一行30秒行35秒,依次递增 // 每行不同的速度:第一行25秒第二行30秒行35秒
const duration = 30 + rowIndex * 5; const duration = 25 + rowIndex * 5;
return ( return (
<Box <Box
key={rowIndex} key={rowIndex}
position="relative" position="relative"
width="100%" width="100%"
height="38px" height="58px"
overflow="hidden" overflow="hidden"
> >
<HStack <HStack
@@ -503,23 +513,26 @@ const ConceptFlowAnimation = () => {
const icon = changePct > 0 ? '📈' : '📉'; const icon = changePct > 0 ? '📈' : '📉';
const isHovered = hoveredConcept === `${rowIndex}-${idx}`; const isHovered = hoveredConcept === `${rowIndex}-${idx}`;
const fontSize = getFontSize(changePct);
const borderWidth = fontSize === 'md' ? '3px' : '2px';
return ( return (
<Box <Box
key={`${rowIndex}-${idx}`} key={`${rowIndex}-${idx}`}
px={3} px={4}
py={1} py={2}
borderRadius="full" borderRadius="full"
bg="whiteAlpha.200" bg="whiteAlpha.200"
borderWidth="2px" borderWidth={borderWidth}
borderColor={color} borderColor={color}
color="white" color="white"
fontWeight="bold" fontWeight={fontSize === 'md' ? 'extrabold' : 'bold'}
fontSize="xs" fontSize={fontSize}
whiteSpace="nowrap" whiteSpace="nowrap"
cursor="pointer" cursor="pointer"
position="relative" position="relative"
transition="all 0.3s ease" transition="all 0.3s ease"
boxShadow={`0 0 10px ${color}40`} boxShadow={`0 0 ${fontSize === 'md' ? '15px' : '10px'} ${color}${fontSize === 'md' ? '60' : '40'}`}
onMouseEnter={() => { onMouseEnter={() => {
setIsPaused(true); setIsPaused(true);
setHoveredConcept(`${rowIndex}-${idx}`); setHoveredConcept(`${rowIndex}-${idx}`);
@@ -530,9 +543,9 @@ const ConceptFlowAnimation = () => {
}} }}
onClick={() => handleConceptClick(concept.name)} onClick={() => handleConceptClick(concept.name)}
_hover={{ _hover={{
transform: 'scale(1.1)', transform: 'scale(1.15)',
bg: 'whiteAlpha.300', bg: 'whiteAlpha.300',
boxShadow: `0 0 20px ${color}80`, boxShadow: `0 0 25px ${color}80`,
zIndex: 100 zIndex: 100
}} }}
> >