diff --git a/src/components/Citation/CitationMark.js b/src/components/Citation/CitationMark.js index aa15e0a4..4d15eaee 100644 --- a/src/components/Citation/CitationMark.js +++ b/src/components/Citation/CitationMark.js @@ -27,52 +27,65 @@ const CitationMark = ({ citationId, citation }) => { // 引用卡片内容 const citationContent = ( -
- {/* 作者 */} - - -
- 作者 -
- {citation.author} -
-
+
+ {/* 报告标题 - 顶部突出显示 */} +
+ + {citation.report_title} + +
- + {/* 作者和日期 - 左右分布 */} +
+ {/* 左侧:作者 */} + + + + {citation.author} + + - {/* 报告标题 */} - - -
- 报告标题 -
- {citation.report_title} -
-
- - - - {/* 发布日期 */} - - -
- 发布日期 -
- {citation.declare_date} -
-
- - + {/* 右侧:发布日期(重点标注) */} + + + + {citation.declare_date} + + +
{/* 摘要片段 */}
- + 摘要片段 { title={`引用来源 [${citationId}]`} trigger={triggerType} placement="top" - overlayInnerStyle={{ maxWidth: 380 }} + overlayInnerStyle={{ maxWidth: 340, padding: '8px' }} open={popoverVisible} onOpenChange={setPopoverVisible} > diff --git a/src/components/StockChart/StockChartAntdModal.js b/src/components/StockChart/StockChartAntdModal.js index fd92c925..a5daf849 100644 --- a/src/components/StockChart/StockChartAntdModal.js +++ b/src/components/StockChart/StockChartAntdModal.js @@ -528,7 +528,7 @@ const StockChartAntdModal = ({ {stock?.relation_desc?.data ? ( // 使用引用组件(带研报来源) { // 处理每个引用数据项 rawData.data.forEach((item, index) => { - // 验证必需字段 - if (!item.sentences) { - console.warn(`citationUtils: Missing 'sentences' field in item ${index}`); + // 验证必需字段(至少需要 query_part 或 sentences 之一) + if (!item.query_part && !item.sentences) { + console.warn(`citationUtils: Missing both 'query_part' and 'sentences' fields in item ${index}`); return; } @@ -65,7 +65,7 @@ export const processCitationData = (rawData) => { // 构建文本片段 segments.push({ - text: item.sentences, + text: item.query_part || item.sentences, // 优先使用 query_part,降级到 sentences citationId: citationId }); @@ -126,6 +126,6 @@ export const isValidCitationData = (data) => { if (!data.data || !Array.isArray(data.data)) return false; if (data.data.length === 0) return false; - // 检查至少有一个有效的 sentences 字段 - return data.data.some(item => item && item.sentences); + // 检查至少有一个有效的 query_part 或 sentences 字段 + return data.data.some(item => item && (item.query_part || item.sentences)); }; diff --git a/src/views/Community/components/StockDetailPanel.js b/src/views/Community/components/StockDetailPanel.js index 2468d912..4e69381e 100644 --- a/src/views/Community/components/StockDetailPanel.js +++ b/src/views/Community/components/StockDetailPanel.js @@ -452,6 +452,7 @@ function StockDetailPanel({ visible, event, onClose }) { // 初始化数据加载 useEffect(() => { + console.log('[StockDetailPanel] useEffect 触发, visible:', visible, 'event:', event?.id); if (visible && event) { setActiveTab('stocks'); loadAllData(); @@ -460,8 +461,9 @@ function StockDetailPanel({ visible, event, onClose }) { // 加载所有数据的函数 const loadAllData = useCallback(() => { + console.log('[StockDetailPanel] loadAllData 被调用, event:', event?.id); if (!event) return; - + // 加载自选股列表 loadWatchlist(); @@ -590,17 +592,38 @@ function StockDetailPanel({ visible, event, onClose }) { dataIndex: 'relation_desc', key: 'relation_desc', width: 300, - render: (text, record) => { - console.log('[表格渲染] 股票:', record.stock_code, 'relation_desc:', text); - if (!text) return '--'; - + render: (relationDesc, record) => { + console.log('[表格渲染] 股票:', record.stock_code, 'relation_desc:', relationDesc); + + // 处理 relation_desc 的两种格式 + let text = ''; + + if (!relationDesc) { + return '--'; + } else if (typeof relationDesc === 'string') { + // 旧格式:直接是字符串 + text = relationDesc; + } else if (typeof relationDesc === 'object' && relationDesc.data && Array.isArray(relationDesc.data)) { + // 新格式:{data: [{query_part: "...", sentences: "..."}]} + // 提取所有 query_part,用逗号连接 + text = relationDesc.data + .map(item => item.query_part || item.sentences || '') + .filter(s => s) + .join(';') || '--'; + } else { + console.warn('[表格渲染] 未知的 relation_desc 格式:', relationDesc); + return '--'; + } + + if (!text || text === '--') return '--'; + const isExpanded = expandedRows.has(record.stock_code); const maxLength = 30; // 收缩时显示的最大字符数 const needTruncate = text.length > maxLength; - + return (
-
{ // 加载事件列表 const loadEvents = useCallback(async (page = 1) => { + console.log('[Community] loadEvents 被调用,页码:', page); + console.log('[Community] 调用栈:', new Error().stack); setLoading(true); try { const filters = getFiltersFromUrl(); @@ -254,12 +256,17 @@ const Community = () => { }); // 初始化加载 + // 注意: 只监听 searchParams 变化,不监听 loadEvents 等函数 + // 这是为了避免 StockDetailPanel 打开时触发不必要的重新加载 + // 如果未来 loadEvents 添加了新的状态依赖,需要在此处同步更新 useEffect(() => { + console.log('[Community] useEffect 触发,searchParams 变化:', searchParams.toString()); const page = parseInt(searchParams.get('page') || '1', 10); loadEvents(page); loadPopularKeywords(); loadHotEvents(); - }, [searchParams, loadEvents, loadPopularKeywords, loadHotEvents]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [searchParams]); // 只监听 URL 参数变化