update pay function
This commit is contained in:
@@ -131,13 +131,18 @@ const KLineChartModal: React.FC<KLineChartModalProps> = ({
|
|||||||
chartInstance.current?.resize();
|
chartInstance.current?.resize();
|
||||||
};
|
};
|
||||||
window.addEventListener('resize', handleResize);
|
window.addEventListener('resize', handleResize);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', handleResize);
|
||||||
|
};
|
||||||
}, 100); // 延迟100ms等待Modal完全打开
|
}, 100); // 延迟100ms等待Modal完全打开
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
window.removeEventListener('resize', () => {});
|
if (chartInstance.current) {
|
||||||
chartInstance.current?.dispose();
|
chartInstance.current.dispose();
|
||||||
chartInstance.current = null;
|
chartInstance.current = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
|
|||||||
@@ -130,13 +130,18 @@ const TimelineChartModal: React.FC<TimelineChartModalProps> = ({
|
|||||||
chartInstance.current?.resize();
|
chartInstance.current?.resize();
|
||||||
};
|
};
|
||||||
window.addEventListener('resize', handleResize);
|
window.addEventListener('resize', handleResize);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', handleResize);
|
||||||
|
};
|
||||||
}, 100); // 延迟100ms等待Modal完全打开
|
}, 100); // 延迟100ms等待Modal完全打开
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
window.removeEventListener('resize', () => {});
|
if (chartInstance.current) {
|
||||||
chartInstance.current?.dispose();
|
chartInstance.current.dispose();
|
||||||
chartInstance.current = null;
|
chartInstance.current = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,11 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Flex,
|
|
||||||
VStack,
|
VStack,
|
||||||
HStack,
|
HStack,
|
||||||
Text,
|
Text,
|
||||||
Button,
|
|
||||||
IconButton,
|
IconButton,
|
||||||
Collapse,
|
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Badge,
|
|
||||||
useColorModeValue,
|
useColorModeValue,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { StarIcon } from '@chakra-ui/icons';
|
import { StarIcon } from '@chakra-ui/icons';
|
||||||
@@ -20,7 +16,6 @@ import MiniTimelineChart from '../StockDetailPanel/components/MiniTimelineChart'
|
|||||||
import MiniKLineChart from './MiniKLineChart';
|
import MiniKLineChart from './MiniKLineChart';
|
||||||
import TimelineChartModal from '../../../../components/StockChart/TimelineChartModal';
|
import TimelineChartModal from '../../../../components/StockChart/TimelineChartModal';
|
||||||
import KLineChartModal from '../../../../components/StockChart/KLineChartModal';
|
import KLineChartModal from '../../../../components/StockChart/KLineChartModal';
|
||||||
import CitedContent from '../../../../components/Citation/CitedContent';
|
|
||||||
import { getChangeColor } from '../../../../utils/colorUtils';
|
import { getChangeColor } from '../../../../utils/colorUtils';
|
||||||
import { PROFESSIONAL_COLORS } from '../../../../constants/professionalTheme';
|
import { PROFESSIONAL_COLORS } from '../../../../constants/professionalTheme';
|
||||||
|
|
||||||
@@ -48,10 +43,7 @@ const StockListItem = ({
|
|||||||
const borderColor = PROFESSIONAL_COLORS.border.default;
|
const borderColor = PROFESSIONAL_COLORS.border.default;
|
||||||
const codeColor = '#3B82F6';
|
const codeColor = '#3B82F6';
|
||||||
const nameColor = PROFESSIONAL_COLORS.text.primary;
|
const nameColor = PROFESSIONAL_COLORS.text.primary;
|
||||||
const descColor = PROFESSIONAL_COLORS.text.secondary;
|
|
||||||
const dividerColor = PROFESSIONAL_COLORS.border.default;
|
|
||||||
|
|
||||||
const [isDescExpanded, setIsDescExpanded] = useState(false);
|
|
||||||
const [isTimelineModalOpen, setIsTimelineModalOpen] = useState(false);
|
const [isTimelineModalOpen, setIsTimelineModalOpen] = useState(false);
|
||||||
const [isKLineModalOpen, setIsKLineModalOpen] = useState(false);
|
const [isKLineModalOpen, setIsKLineModalOpen] = useState(false);
|
||||||
|
|
||||||
@@ -72,34 +64,9 @@ const StockListItem = ({
|
|||||||
return `${prefix}${parseFloat(value).toFixed(2)}%`;
|
return `${prefix}${parseFloat(value).toFixed(2)}%`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 使用工具函数获取涨跌幅颜色(已从 colorUtils 导入)
|
|
||||||
|
|
||||||
// 获取涨跌幅数据(优先使用 quote,fallback 到 stock)
|
// 获取涨跌幅数据(优先使用 quote,fallback 到 stock)
|
||||||
const change = quote?.change ?? stock.daily_change ?? null;
|
const change = quote?.change ?? stock.daily_change ?? null;
|
||||||
|
|
||||||
// 处理关联描述
|
|
||||||
const getRelationDesc = () => {
|
|
||||||
const relationDesc = stock.relation_desc;
|
|
||||||
|
|
||||||
if (!relationDesc) return '--';
|
|
||||||
|
|
||||||
if (typeof relationDesc === 'string') {
|
|
||||||
return relationDesc;
|
|
||||||
} else if (typeof relationDesc === 'object' && relationDesc.data && Array.isArray(relationDesc.data)) {
|
|
||||||
// 新格式:{data: [{query_part: "...", sentences: "..."}]}
|
|
||||||
return relationDesc.data
|
|
||||||
.map(item => item.query_part || item.sentences || '')
|
|
||||||
.filter(s => s)
|
|
||||||
.join(';') || '--';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '--';
|
|
||||||
};
|
|
||||||
|
|
||||||
const relationText = getRelationDesc();
|
|
||||||
const maxLength = 50; // 收缩时显示的最大字符数
|
|
||||||
const needTruncate = relationText && relationText !== '--' && relationText.length > maxLength;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
@@ -279,103 +246,6 @@ const StockListItem = ({
|
|||||||
</VStack>
|
</VStack>
|
||||||
</HStack>
|
</HStack>
|
||||||
|
|
||||||
{/* 关联描述 - 升级和降级处理 */}
|
|
||||||
{stock.relation_desc && (
|
|
||||||
<Box flex={1} minW={0}>
|
|
||||||
{stock.relation_desc?.data ? (
|
|
||||||
// 升级:带引用来源的版本 - 添加折叠功能
|
|
||||||
<Tooltip
|
|
||||||
label={isDescExpanded ? "点击收起" : "点击展开完整描述"}
|
|
||||||
placement="top"
|
|
||||||
hasArrow
|
|
||||||
bg="rgba(20, 20, 20, 0.95)"
|
|
||||||
color={PROFESSIONAL_COLORS.gold[500]}
|
|
||||||
fontSize="xs"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
setIsDescExpanded(!isDescExpanded);
|
|
||||||
}}
|
|
||||||
cursor="pointer"
|
|
||||||
px={3}
|
|
||||||
py={2}
|
|
||||||
bg={PROFESSIONAL_COLORS.background.secondary}
|
|
||||||
borderRadius="md"
|
|
||||||
_hover={{
|
|
||||||
bg: PROFESSIONAL_COLORS.background.cardHover,
|
|
||||||
}}
|
|
||||||
transition="background 0.2s"
|
|
||||||
position="relative"
|
|
||||||
>
|
|
||||||
<Collapse in={isDescExpanded} startingHeight={40}>
|
|
||||||
<CitedContent
|
|
||||||
data={stock.relation_desc}
|
|
||||||
title=""
|
|
||||||
showAIBadge={true}
|
|
||||||
textColor={PROFESSIONAL_COLORS.text.primary}
|
|
||||||
containerStyle={{
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
borderRadius: '0',
|
|
||||||
padding: '0',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Collapse>
|
|
||||||
</Box>
|
|
||||||
</Tooltip>
|
|
||||||
) : (
|
|
||||||
// 降级:纯文本版本(保留展开/收起功能)
|
|
||||||
<Tooltip
|
|
||||||
label={isDescExpanded ? "点击收起" : "点击展开完整描述"}
|
|
||||||
placement="top"
|
|
||||||
hasArrow
|
|
||||||
bg="rgba(20, 20, 20, 0.95)"
|
|
||||||
color={PROFESSIONAL_COLORS.gold[500]}
|
|
||||||
fontSize="xs"
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
setIsDescExpanded(!isDescExpanded);
|
|
||||||
}}
|
|
||||||
cursor="pointer"
|
|
||||||
px={3}
|
|
||||||
py={2}
|
|
||||||
bg={PROFESSIONAL_COLORS.background.secondary}
|
|
||||||
borderRadius="md"
|
|
||||||
_hover={{
|
|
||||||
bg: PROFESSIONAL_COLORS.background.cardHover,
|
|
||||||
}}
|
|
||||||
transition="background 0.2s"
|
|
||||||
position="relative"
|
|
||||||
>
|
|
||||||
{/* 去掉"关联描述"标题 */}
|
|
||||||
<Collapse in={isDescExpanded} startingHeight={36}>
|
|
||||||
<Text
|
|
||||||
fontSize="xs"
|
|
||||||
color={nameColor}
|
|
||||||
lineHeight="1.5"
|
|
||||||
>
|
|
||||||
{relationText}
|
|
||||||
</Text>
|
|
||||||
</Collapse>
|
|
||||||
|
|
||||||
{/* 提示信息 */}
|
|
||||||
{isDescExpanded && (
|
|
||||||
<Text
|
|
||||||
fontSize="xs"
|
|
||||||
color="gray.500"
|
|
||||||
mt={2}
|
|
||||||
fontStyle="italic"
|
|
||||||
>
|
|
||||||
⚠️ AI生成,仅供参考
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</HStack>
|
</HStack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user