diff --git a/src/components/StockChart/StockChartModal.js b/src/components/StockChart/StockChartModal.js index e637edef..c6e7e9ae 100644 --- a/src/components/StockChart/StockChartModal.js +++ b/src/components/StockChart/StockChartModal.js @@ -14,11 +14,12 @@ const StockChartModal = ({ stock, eventTime, isChakraUI = true, // 是否使用Chakra UI,默认true;如果false则使用Antd - size = "6xl" + size = "6xl", + initialChartType = 'timeline' // 初始图表类型(timeline/daily) }) => { const chartRef = useRef(null); const chartInstanceRef = useRef(null); - const [chartType, setChartType] = useState('timeline'); + const [chartType, setChartType] = useState(initialChartType); const [loading, setLoading] = useState(false); const [chartData, setChartData] = useState(null); const [preloadedData, setPreloadedData] = useState({}); diff --git a/src/views/Community/components/DynamicNewsDetail/StockListItem.js b/src/views/Community/components/DynamicNewsDetail/StockListItem.js index f5a361e4..e91de2e6 100644 --- a/src/views/Community/components/DynamicNewsDetail/StockListItem.js +++ b/src/views/Community/components/DynamicNewsDetail/StockListItem.js @@ -52,6 +52,7 @@ const StockListItem = ({ const [isDescExpanded, setIsDescExpanded] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false); + const [modalChartType, setModalChartType] = useState('timeline'); // 跟踪用户点击的图表类型 const handleViewDetail = () => { const stockCode = stock.stock_code.split('.')[0]; @@ -203,6 +204,7 @@ const StockListItem = ({ bg="rgba(59, 130, 246, 0.1)" onClick={(e) => { e.stopPropagation(); + setModalChartType('timeline'); // 设置为分时图 setIsModalOpen(true); }} cursor="pointer" @@ -245,6 +247,7 @@ const StockListItem = ({ bg="rgba(168, 85, 247, 0.1)" onClick={(e) => { e.stopPropagation(); + setModalChartType('daily'); // 设置为日K线 setIsModalOpen(true); }} cursor="pointer" @@ -385,6 +388,7 @@ const StockListItem = ({ stock={stock} eventTime={eventTime} size="6xl" + initialChartType={modalChartType} // 传递用户点击的图表类型 /> )}