feat: 按发布时间倒序排列AI推荐结果
This commit is contained in:
@@ -224,10 +224,18 @@ const fetchAIRecommendations = async () => {
|
|||||||
title: rec.title,
|
title: rec.title,
|
||||||
url: bid?.url || '',
|
url: bid?.url || '',
|
||||||
source: bid?.source || '',
|
source: bid?.source || '',
|
||||||
confidence: rec.confidence
|
confidence: rec.confidence,
|
||||||
|
publishDate: bid?.publishDate
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 按发布时间倒序排列
|
||||||
|
recommendations.sort((a: AIRecommendation, b: AIRecommendation) => {
|
||||||
|
if (!a.publishDate) return 1
|
||||||
|
if (!b.publishDate) return -1
|
||||||
|
return new Date(b.publishDate).getTime() - new Date(a.publishDate).getTime()
|
||||||
|
})
|
||||||
|
|
||||||
aiRecommendations.value = recommendations
|
aiRecommendations.value = recommendations
|
||||||
|
|
||||||
// 保存推荐结果到数据库
|
// 保存推荐结果到数据库
|
||||||
|
|||||||
@@ -144,6 +144,13 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按发布时间倒序排列
|
||||||
|
result.sort((a, b) => {
|
||||||
|
if (!a.publishDate) return 1;
|
||||||
|
if (!b.publishDate) return -1;
|
||||||
|
return new Date(b.publishDate).getTime() - new Date(a.publishDate).getTime();
|
||||||
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('获取最新 AI 推荐失败:', error);
|
this.logger.error('获取最新 AI 推荐失败:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user