From 65d0ec53549829a710e4704c725dfac8d1196da7 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Sun, 26 Oct 2025 14:11:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97=E8=AF=B7=E6=B1=82=E4=B8=BA=E5=A4=96=E9=83=A8=E4=BC=A0?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Community/components/PopularKeywords.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/views/Community/components/PopularKeywords.js b/src/views/Community/components/PopularKeywords.js index e01fe846..02b05d80 100644 --- a/src/views/Community/components/PopularKeywords.js +++ b/src/views/Community/components/PopularKeywords.js @@ -13,7 +13,7 @@ const DOMAIN_PREFIX = process.env.NODE_ENV === 'production' ? '' : 'https://valuefrontier.cn'; -const PopularKeywords = ({ onKeywordClick }) => { +const PopularKeywords = ({ onKeywordClick, keywords: propKeywords }) => { const [keywords, setKeywords] = useState([]); const [loading, setLoading] = useState(false); const navigate = useNavigate(); @@ -46,7 +46,7 @@ const PopularKeywords = ({ onKeywordClick }) => { concept_id: item.concept_id })); setKeywords(formattedData); - logger.debug('PopularKeywords', '热门概念加载成功', { + logger.debug('PopularKeywords', '热门概念加载成功(自己请求)', { count: formattedData.length }); } @@ -58,10 +58,19 @@ const PopularKeywords = ({ onKeywordClick }) => { } }; - // 组件挂载时加载数据 + // 处理从父组件传入的数据 useEffect(() => { - loadPopularConcepts(); - }, []); + if (propKeywords && propKeywords.length > 0) { + // 使用父组件传入的数据 + setKeywords(propKeywords); + logger.debug('PopularKeywords', '使用父组件传入的数据', { + count: propKeywords.length + }); + } else { + // 没有 prop 数据,自己加载 + loadPopularConcepts(); + } + }, [propKeywords]); // 根据涨跌幅获取标签颜色 const getTagColor = (changePct) => {