feat: 调整关键字请求为外部传入

This commit is contained in:
zdl
2025-10-26 14:11:54 +08:00
parent 05307d6501
commit 65d0ec5354

View File

@@ -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(() => {
if (propKeywords && propKeywords.length > 0) {
// 使用父组件传入的数据
setKeywords(propKeywords);
logger.debug('PopularKeywords', '使用父组件传入的数据', {
count: propKeywords.length
});
} else {
// 没有 prop 数据,自己加载
loadPopularConcepts();
}, []);
}
}, [propKeywords]);
// 根据涨跌幅获取标签颜色
const getTagColor = (changePct) => {