diff --git a/src/views/Community/components/StockDetailPanel/components/StockTable.js b/src/views/Community/components/StockDetailPanel/components/StockTable.js index 8bf3b1f0..b2a9daf4 100644 --- a/src/views/Community/components/StockDetailPanel/components/StockTable.js +++ b/src/views/Community/components/StockDetailPanel/components/StockTable.js @@ -7,6 +7,18 @@ import MiniTimelineChart from './MiniTimelineChart'; import { fetchBatchKlineData, klineDataCache, getCacheKey } from '../utils/klineDataCache'; import { logger } from '../../../../../utils/logger'; +/** + * 标准化股票代码为6位格式 + * @param {string} code - 股票代码 + * @returns {string} 6位标准化代码 + */ +const normalizeStockCode = (code) => { + if (!code) return ''; + const s = String(code).trim(); + const m = s.match(/(\d{6})/); + return m ? m[1] : s; +}; + /** * 股票列表表格组件 * 显示事件相关股票列表,包括分时图、涨跌幅、自选股操作等 @@ -260,7 +272,9 @@ const StockTable = ({ width: 150, fixed: 'right', render: (_, record) => { - const isInWatchlist = watchlistSet.has(record.stock_code); + // 标准化代码后再比较,确保 600000.SH 和 600000 能匹配 + const normalizedCode = normalizeStockCode(record.stock_code); + const isInWatchlist = watchlistSet.has(normalizedCode); return (