From a8cf4266b4782fd3aa087c52883e06ec8284aa97 Mon Sep 17 00:00:00 2001 From: zzlgreat Date: Wed, 7 Jan 2026 13:26:48 +0800 Subject: [PATCH] =?UTF-8?q?community=E5=A2=9E=E5=8A=A0=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Community/components/HeroPanel.js | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/views/Community/components/HeroPanel.js b/src/views/Community/components/HeroPanel.js index e200c2a5..0c939572 100644 --- a/src/views/Community/components/HeroPanel.js +++ b/src/views/Community/components/HeroPanel.js @@ -456,6 +456,20 @@ const DetailModal = ({ isOpen, onClose, selectedDate, ztDetail, events, loading return ztDetail.word_freq_data.slice(0, 12); }, [ztDetail]); + // 获取六位股票代码(去掉后缀)- 纯函数,不是hook + const getSixDigitCode = (code) => { + if (!code) return code; + return code.split('.')[0]; + }; + + // 检查股票是否已在自选中 - 必须在条件返回之前 + const isStockInWatchlist = useCallback((stockCode) => { + const sixDigitCode = getSixDigitCode(stockCode); + return reduxWatchlist?.some(item => + getSixDigitCode(item.stock_code) === sixDigitCode + ); + }, [reduxWatchlist]); + // 条件返回必须在所有hooks之后 if (!selectedDate) return null; @@ -485,12 +499,6 @@ const DetailModal = ({ isOpen, onClose, selectedDate, ztDetail, events, loading setDetailDrawerVisible(true); }; - // 获取六位股票代码(去掉后缀) - const getSixDigitCode = (code) => { - if (!code) return code; - return code.split('.')[0]; - }; - // 加载股票行情 const loadStockQuotes = async (stocks) => { if (!stocks || stocks.length === 0) return; @@ -571,14 +579,6 @@ const DetailModal = ({ isOpen, onClose, selectedDate, ztDetail, events, loading return sixDigitCode; }; - // 检查股票是否已在自选中 - const isStockInWatchlist = useCallback((stockCode) => { - const sixDigitCode = getSixDigitCode(stockCode); - return reduxWatchlist?.some(item => - getSixDigitCode(item.stock_code) === sixDigitCode - ); - }, [reduxWatchlist]); - // 显示K线图 const showKline = (stock) => { const code = stock.code;