事件中心UI优化
This commit is contained in:
@@ -6,15 +6,12 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Flex,
|
Flex,
|
||||||
VStack,
|
VStack,
|
||||||
|
HStack,
|
||||||
Text,
|
Text,
|
||||||
Button,
|
Button,
|
||||||
IconButton,
|
IconButton,
|
||||||
Collapse,
|
Collapse,
|
||||||
Stat,
|
Tooltip,
|
||||||
StatLabel,
|
|
||||||
StatNumber,
|
|
||||||
StatHelpText,
|
|
||||||
StatArrow,
|
|
||||||
useColorModeValue,
|
useColorModeValue,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { StarIcon } from '@chakra-ui/icons';
|
import { StarIcon } from '@chakra-ui/icons';
|
||||||
@@ -104,12 +101,23 @@ const StockListItem = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Tooltip
|
||||||
|
label="点击查看股票详情"
|
||||||
|
placement="top"
|
||||||
|
hasArrow
|
||||||
|
bg="blue.600"
|
||||||
|
color="white"
|
||||||
|
fontSize="sm"
|
||||||
|
px={3}
|
||||||
|
py={2}
|
||||||
|
borderRadius="md"
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
bg={cardBg}
|
bg={cardBg}
|
||||||
borderWidth="2px"
|
borderWidth="2px"
|
||||||
borderColor={borderColor}
|
borderColor={borderColor}
|
||||||
borderRadius="xl"
|
borderRadius="xl"
|
||||||
p={5}
|
p={4}
|
||||||
onClick={handleViewDetail}
|
onClick={handleViewDetail}
|
||||||
cursor="pointer"
|
cursor="pointer"
|
||||||
position="relative"
|
position="relative"
|
||||||
@@ -130,17 +138,14 @@ const StockListItem = ({
|
|||||||
}}
|
}}
|
||||||
transition="all 0.3s ease-in-out"
|
transition="all 0.3s ease-in-out"
|
||||||
>
|
>
|
||||||
{/* 横向布局:左侧基础信息 + 中间图表 + 右侧操作按钮 */}
|
{/* 单行布局:股票代码 + 名称 + 涨跌幅 + 分时图 + K线图 */}
|
||||||
<Flex direction={{ base: 'column', lg: 'row' }} gap={4} align="stretch">
|
<HStack spacing={4} align="center">
|
||||||
{/* 左侧:基础信息区(股票代码、名称、涨跌幅) */}
|
{/* 左侧:股票代码 + 名称 + 自选按钮 */}
|
||||||
<Flex direction="column" minW={{ base: 'auto', lg: '200px' }} maxW={{ base: 'auto', lg: '240px' }} gap={2}>
|
<HStack spacing={3} minW="200px" maxW="240px">
|
||||||
{/* 股票代码和名称 */}
|
|
||||||
<VStack align="stretch" spacing={2}>
|
|
||||||
<Flex align="center" gap={2}>
|
|
||||||
<Box
|
<Box
|
||||||
bgGradient="linear(to-r, blue.400, blue.600)"
|
bgGradient="linear(to-r, blue.400, blue.600)"
|
||||||
px={3}
|
px={3}
|
||||||
py={1}
|
py={1.5}
|
||||||
borderRadius="md"
|
borderRadius="md"
|
||||||
boxShadow="sm"
|
boxShadow="sm"
|
||||||
>
|
>
|
||||||
@@ -148,14 +153,19 @@ const StockListItem = ({
|
|||||||
fontSize="md"
|
fontSize="md"
|
||||||
fontWeight="bold"
|
fontWeight="bold"
|
||||||
color="white"
|
color="white"
|
||||||
cursor="pointer"
|
|
||||||
onClick={handleViewDetail}
|
|
||||||
_hover={{ opacity: 0.8 }}
|
|
||||||
transition="opacity 0.2s"
|
|
||||||
>
|
>
|
||||||
{stock.stock_code}
|
{stock.stock_code}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Text
|
||||||
|
fontSize="md"
|
||||||
|
fontWeight="semibold"
|
||||||
|
color={nameColor}
|
||||||
|
noOfLines={1}
|
||||||
|
flex={1}
|
||||||
|
>
|
||||||
|
{stock.stock_name}
|
||||||
|
</Text>
|
||||||
{onWatchlistToggle && (
|
{onWatchlistToggle && (
|
||||||
<IconButton
|
<IconButton
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -166,48 +176,33 @@ const StockListItem = ({
|
|||||||
aria-label={isInWatchlist ? '已关注' : '加自选'}
|
aria-label={isInWatchlist ? '已关注' : '加自选'}
|
||||||
title={isInWatchlist ? '已关注' : '加自选'}
|
title={isInWatchlist ? '已关注' : '加自选'}
|
||||||
borderRadius="full"
|
borderRadius="full"
|
||||||
|
flexShrink={0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</HStack>
|
||||||
<Text
|
|
||||||
fontSize="md"
|
|
||||||
fontWeight="semibold"
|
|
||||||
color={nameColor}
|
|
||||||
noOfLines={1}
|
|
||||||
>
|
|
||||||
{stock.stock_name}
|
|
||||||
</Text>
|
|
||||||
</VStack>
|
|
||||||
|
|
||||||
{/* 涨跌幅 - 使用 Stat 组件 */}
|
{/* 涨跌幅 */}
|
||||||
<Stat
|
<Box
|
||||||
bg={useColorModeValue('gray.50', 'gray.700')}
|
bg={useColorModeValue('gray.50', 'gray.700')}
|
||||||
px={3}
|
px={4}
|
||||||
py={2}
|
py={2}
|
||||||
borderRadius="lg"
|
borderRadius="lg"
|
||||||
boxShadow="sm"
|
boxShadow="sm"
|
||||||
|
minW="120px"
|
||||||
|
textAlign="center"
|
||||||
>
|
>
|
||||||
<StatLabel fontSize="xs" color={descColor}>
|
<Text fontSize="xs" color={descColor} mb={1}>
|
||||||
涨跌幅
|
涨跌幅
|
||||||
</StatLabel>
|
</Text>
|
||||||
<StatNumber
|
<Text
|
||||||
fontSize="2xl"
|
fontSize="2xl"
|
||||||
fontWeight="bold"
|
fontWeight="bold"
|
||||||
color={getChangeColor(change)}
|
color={getChangeColor(change)}
|
||||||
>
|
>
|
||||||
{formatChange(change)}
|
{formatChange(change)}
|
||||||
</StatNumber>
|
</Text>
|
||||||
{change !== null && change !== undefined && !isNaN(change) && (
|
</Box>
|
||||||
<StatHelpText mb={0}>
|
|
||||||
<StatArrow type={change >= 0 ? 'increase' : 'decrease'} />
|
|
||||||
{Math.abs(change).toFixed(2)}%
|
|
||||||
</StatHelpText>
|
|
||||||
)}
|
|
||||||
</Stat>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
{/* 中间:图表区(分时图 + K线图) */}
|
|
||||||
<Flex flex={1} gap={3} onClick={(e) => e.stopPropagation()} minW={0}>
|
|
||||||
{/* 分时图 */}
|
{/* 分时图 */}
|
||||||
<Box
|
<Box
|
||||||
flex={1}
|
flex={1}
|
||||||
@@ -215,9 +210,10 @@ const StockListItem = ({
|
|||||||
borderWidth="1px"
|
borderWidth="1px"
|
||||||
borderColor={useColorModeValue('blue.100', 'blue.700')}
|
borderColor={useColorModeValue('blue.100', 'blue.700')}
|
||||||
borderRadius="lg"
|
borderRadius="lg"
|
||||||
p={3}
|
p={2}
|
||||||
bg={useColorModeValue('blue.50', 'blue.900')}
|
bg={useColorModeValue('blue.50', 'blue.900')}
|
||||||
transition="all 0.2s"
|
transition="all 0.2s"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
_hover={{
|
_hover={{
|
||||||
borderColor: useColorModeValue('blue.300', 'blue.500'),
|
borderColor: useColorModeValue('blue.300', 'blue.500'),
|
||||||
boxShadow: 'md'
|
boxShadow: 'md'
|
||||||
@@ -226,7 +222,7 @@ const StockListItem = ({
|
|||||||
<Text
|
<Text
|
||||||
fontSize="xs"
|
fontSize="xs"
|
||||||
color={useColorModeValue('blue.700', 'blue.200')}
|
color={useColorModeValue('blue.700', 'blue.200')}
|
||||||
mb={2}
|
mb={1}
|
||||||
fontWeight="bold"
|
fontWeight="bold"
|
||||||
textTransform="uppercase"
|
textTransform="uppercase"
|
||||||
letterSpacing="wide"
|
letterSpacing="wide"
|
||||||
@@ -247,9 +243,10 @@ const StockListItem = ({
|
|||||||
borderWidth="1px"
|
borderWidth="1px"
|
||||||
borderColor={useColorModeValue('purple.100', 'purple.700')}
|
borderColor={useColorModeValue('purple.100', 'purple.700')}
|
||||||
borderRadius="lg"
|
borderRadius="lg"
|
||||||
p={3}
|
p={2}
|
||||||
bg={useColorModeValue('purple.50', 'purple.900')}
|
bg={useColorModeValue('purple.50', 'purple.900')}
|
||||||
transition="all 0.2s"
|
transition="all 0.2s"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
_hover={{
|
_hover={{
|
||||||
borderColor: useColorModeValue('purple.300', 'purple.500'),
|
borderColor: useColorModeValue('purple.300', 'purple.500'),
|
||||||
boxShadow: 'md'
|
boxShadow: 'md'
|
||||||
@@ -258,7 +255,7 @@ const StockListItem = ({
|
|||||||
<Text
|
<Text
|
||||||
fontSize="xs"
|
fontSize="xs"
|
||||||
color={useColorModeValue('purple.700', 'purple.200')}
|
color={useColorModeValue('purple.700', 'purple.200')}
|
||||||
mb={2}
|
mb={1}
|
||||||
fontWeight="bold"
|
fontWeight="bold"
|
||||||
textTransform="uppercase"
|
textTransform="uppercase"
|
||||||
letterSpacing="wide"
|
letterSpacing="wide"
|
||||||
@@ -271,34 +268,7 @@ const StockListItem = ({
|
|||||||
onClick={() => setIsModalOpen(true)}
|
onClick={() => setIsModalOpen(true)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</HStack>
|
||||||
|
|
||||||
{/* 右侧:操作按钮 */}
|
|
||||||
<Flex direction="column" gap={2} minW={{ base: 'auto', lg: '120px' }} justify="center">
|
|
||||||
<Button
|
|
||||||
size="md"
|
|
||||||
bgGradient="linear(to-r, blue.400, blue.600)"
|
|
||||||
color="white"
|
|
||||||
_hover={{
|
|
||||||
bgGradient: "linear(to-r, blue.500, blue.700)",
|
|
||||||
transform: "scale(1.05)",
|
|
||||||
}}
|
|
||||||
_active={{
|
|
||||||
bgGradient: "linear(to-r, blue.600, blue.800)",
|
|
||||||
}}
|
|
||||||
boxShadow="md"
|
|
||||||
borderRadius="lg"
|
|
||||||
fontWeight="bold"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
handleViewDetail();
|
|
||||||
}}
|
|
||||||
transition="all 0.2s"
|
|
||||||
>
|
|
||||||
查看详情 →
|
|
||||||
</Button>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
{/* 关联描述(折叠区域) */}
|
{/* 关联描述(折叠区域) */}
|
||||||
{relationText && relationText !== '--' && (
|
{relationText && relationText !== '--' && (
|
||||||
@@ -343,6 +313,7 @@ const StockListItem = ({
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
{/* 股票详情弹窗 - 未打开时不渲染 */}
|
{/* 股票详情弹窗 - 未打开时不渲染 */}
|
||||||
{isModalOpen && (
|
{isModalOpen && (
|
||||||
|
|||||||
Reference in New Issue
Block a user