fix: 修复JSON解析错误并恢复API端点

修复RankList组件中JSON.parse可能抛出异常的问题,添加try-catch处理
恢复newsInfo.ts中getTopNews的原始API端点
This commit is contained in:
zzp 2025-09-17 15:33:46 +08:00
parent d1d09f76f9
commit b7f4539e63
2 changed files with 19 additions and 7 deletions

View File

@ -17,8 +17,8 @@ export const getConceptCount = (data: any) => {
// 概念标签贴标 // 概念标签贴标
export const getTopNews = (data: any) => { export const getTopNews = (data: any) => {
// return request.get("/top_news_h5_d", data); return request.get("/top_news_h5_d", data);
return request.get("/top_news_release_h5_all", data); // return request.get("/top_news_release_h5_all", data);
}; };
// 概念标签贴标 // 概念标签贴标
export const getTopNewsAll = (data: any) => { export const getTopNewsAll = (data: any) => {

View File

@ -88,14 +88,20 @@ watch(
(newValue, oldValue) => { (newValue, oldValue) => {
rankListLocal.value = []; rankListLocal.value = [];
props.newsList.forEach((item, index) => { props.newsList.forEach((item, index) => {
console.log("🚀 ~ item:", item);
if (!isExp.value && index > 9) { if (!isExp.value && index > 9) {
return; return;
} }
let concept_label = "";
let industry_label = "";
try {
concept_label = JSON.parse(item.concept_label);
industry_label = JSON.parse(item.industry_label);
} catch (e) {}
rankListLocal.value.push({ rankListLocal.value.push({
...item, ...item,
conceptLabels: JSON.parse(item.concept_label), conceptLabels: concept_label,
industryLabels: JSON.parse(item.industry_label), industryLabels: industry_label,
}); });
}); });
@ -114,11 +120,17 @@ watch(
if (!isExp.value && index > 9) { if (!isExp.value && index > 9) {
return; return;
} }
let concept_label = "";
let industry_label = "";
try {
concept_label = JSON.parse(item.concept_label);
industry_label = JSON.parse(item.industry_label);
} catch (e) {}
rankListLocal.value.push({ rankListLocal.value.push({
...item, ...item,
conceptLabels: JSON.parse(item.concept_label), conceptLabels: concept_label,
industryLabels: JSON.parse(item.industry_label), industryLabels: industry_label,
}); });
}); });
loading.value = false; loading.value = false;