update pay function
This commit is contained in:
@@ -18,8 +18,6 @@ import {
|
|||||||
CircularProgress,
|
CircularProgress,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import RiskDisclaimer from '../RiskDisclaimer';
|
import RiskDisclaimer from '../RiskDisclaimer';
|
||||||
import { RelationDescription } from '../StockRelation';
|
|
||||||
import type { RelationDescType } from '../StockRelation';
|
|
||||||
import { useKLineChart, useKLineData, useEventMarker } from './hooks';
|
import { useKLineChart, useKLineData, useEventMarker } from './hooks';
|
||||||
import { Alert, AlertIcon } from '@chakra-ui/react';
|
import { Alert, AlertIcon } from '@chakra-ui/react';
|
||||||
|
|
||||||
@@ -34,7 +32,6 @@ type ChartType = 'timeline' | 'daily';
|
|||||||
interface StockInfo {
|
interface StockInfo {
|
||||||
stock_code: string;
|
stock_code: string;
|
||||||
stock_name?: string;
|
stock_name?: string;
|
||||||
relation_desc?: RelationDescType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,9 +194,6 @@ const StockChartModal: React.FC<StockChartModalProps> = ({
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* 关联描述 */}
|
|
||||||
<RelationDescription relationDesc={stock?.relation_desc} />
|
|
||||||
|
|
||||||
{/* 风险提示 */}
|
{/* 风险提示 */}
|
||||||
<Box px={4} pb={4}>
|
<Box px={4} pb={4}>
|
||||||
<RiskDisclaimer text="" variant="default" sx={{}} />
|
<RiskDisclaimer text="" variant="default" sx={{}} />
|
||||||
|
|||||||
@@ -4,11 +4,15 @@
|
|||||||
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';
|
||||||
@@ -16,6 +20,7 @@ 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';
|
||||||
|
|
||||||
@@ -43,7 +48,10 @@ 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);
|
||||||
|
|
||||||
@@ -64,9 +72,34 @@ 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
|
||||||
@@ -246,6 +279,103 @@ 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