diff --git a/src/components/StockChart/StockChartAntdModal.js b/src/components/StockChart/StockChartAntdModal.js index a10a6e70..fd92c925 100644 --- a/src/components/StockChart/StockChartAntdModal.js +++ b/src/components/StockChart/StockChartAntdModal.js @@ -5,6 +5,7 @@ import ReactECharts from 'echarts-for-react'; import * as echarts from 'echarts'; import moment from 'moment'; import { stockService } from '../../services/eventService'; +import CitedContent from '../Citation/CitedContent'; const { Text } = Typography; @@ -524,12 +525,21 @@ const StockChartAntdModal = ({ {/* 关联描述 */} - {stock?.relation_desc && ( + {stock?.relation_desc?.data ? ( + // 使用引用组件(带研报来源) + + ) : stock?.relation_desc ? ( + // 降级显示(无引用数据)
关联描述: {stock.relation_desc}(AI合成)
- )} + ) : null} {/* 调试信息 */} {process.env.NODE_ENV === 'development' && chartData && ( diff --git a/src/views/Community/components/InvestmentCalendar.js b/src/views/Community/components/InvestmentCalendar.js index 61a0e30d..3913c141 100644 --- a/src/views/Community/components/InvestmentCalendar.js +++ b/src/views/Community/components/InvestmentCalendar.js @@ -6,7 +6,7 @@ import { } from 'antd'; import { StarFilled, StarOutlined, CalendarOutlined, LinkOutlined, StockOutlined, - TagsOutlined, ClockCircleOutlined, InfoCircleOutlined, LockOutlined + TagsOutlined, ClockCircleOutlined, InfoCircleOutlined, LockOutlined, RobotOutlined } from '@ant-design/icons'; import moment from 'moment'; import ReactMarkdown from 'react-markdown'; @@ -14,6 +14,8 @@ import { eventService, stockService } from '../../../services/eventService'; import StockChartAntdModal from '../../../components/StockChart/StockChartAntdModal'; import { useSubscription } from '../../../hooks/useSubscription'; import SubscriptionUpgradeModal from '../../../components/SubscriptionUpgradeModal'; +import CitationMark from '../../../components/Citation/CitationMark'; +import { processCitationData } from '../../../utils/citationUtils'; import './InvestmentCalendar.css'; const { TabPane } = Tabs; @@ -474,26 +476,95 @@ const InvestmentCalendar = () => { const stockCode = record[0]; const isExpanded = expandedReasons[stockCode] || false; const shouldTruncate = reason && reason.length > 100; - + const toggleExpanded = () => { setExpandedReasons(prev => ({ ...prev, [stockCode]: !prev[stockCode] })); }; - + + // 检查是否有引用数据(可能在 record.reason_citation 或 record[4]) + const citationData = record.reason; + const hasCitation = citationData && citationData.data && Array.isArray(citationData.data); + + if (hasCitation) { + // 使用引用组件,支持展开/收起 + const processed = processCitationData(citationData); + + if (processed) { + // 计算所有段落的总长度 + const totalLength = processed.segments.reduce((sum, seg) => sum + seg.text.length, 0); + const shouldTruncate = totalLength > 100; + + // 确定要显示的段落 + let displaySegments = processed.segments; + if (shouldTruncate && !isExpanded) { + // 需要截断:计算应该显示到哪个段落 + let charCount = 0; + displaySegments = []; + for (const seg of processed.segments) { + if (charCount + seg.text.length <= 100) { + // 完整显示这个段落 + displaySegments.push(seg); + charCount += seg.text.length; + } else { + // 截断这个段落 + const remainingChars = 100 - charCount; + if (remainingChars > 0) { + const truncatedText = seg.text.substring(0, remainingChars) + '...'; + displaySegments.push({ ...seg, text: truncatedText }); + } + break; + } + } + } + + return ( +
+
+ {displaySegments.map((segment, index) => ( + + {segment.text} + + {index < displaySegments.length - 1 && } + + ))} +
+ {shouldTruncate && ( + + )} +
+ (AI合成) +
+
+ ); + } + } + + // 降级显示:纯文本 + 展开/收起 return (
- {isExpanded || !shouldTruncate - ? reason + {isExpanded || !shouldTruncate + ? reason : `${reason?.slice(0, 100)}...` } {shouldTruncate && ( -