feat: 调整关键字请求为外部传入
This commit is contained in:
@@ -13,7 +13,7 @@ const DOMAIN_PREFIX = process.env.NODE_ENV === 'production'
|
|||||||
? ''
|
? ''
|
||||||
: 'https://valuefrontier.cn';
|
: 'https://valuefrontier.cn';
|
||||||
|
|
||||||
const PopularKeywords = ({ onKeywordClick }) => {
|
const PopularKeywords = ({ onKeywordClick, keywords: propKeywords }) => {
|
||||||
const [keywords, setKeywords] = useState([]);
|
const [keywords, setKeywords] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -46,7 +46,7 @@ const PopularKeywords = ({ onKeywordClick }) => {
|
|||||||
concept_id: item.concept_id
|
concept_id: item.concept_id
|
||||||
}));
|
}));
|
||||||
setKeywords(formattedData);
|
setKeywords(formattedData);
|
||||||
logger.debug('PopularKeywords', '热门概念加载成功', {
|
logger.debug('PopularKeywords', '热门概念加载成功(自己请求)', {
|
||||||
count: formattedData.length
|
count: formattedData.length
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -58,10 +58,19 @@ const PopularKeywords = ({ onKeywordClick }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 组件挂载时加载数据
|
// 处理从父组件传入的数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadPopularConcepts();
|
if (propKeywords && propKeywords.length > 0) {
|
||||||
}, []);
|
// 使用父组件传入的数据
|
||||||
|
setKeywords(propKeywords);
|
||||||
|
logger.debug('PopularKeywords', '使用父组件传入的数据', {
|
||||||
|
count: propKeywords.length
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 没有 prop 数据,自己加载
|
||||||
|
loadPopularConcepts();
|
||||||
|
}
|
||||||
|
}, [propKeywords]);
|
||||||
|
|
||||||
// 根据涨跌幅获取标签颜色
|
// 根据涨跌幅获取标签颜色
|
||||||
const getTagColor = (changePct) => {
|
const getTagColor = (changePct) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user