feat: 按发布时间倒序排列AI推荐结果

This commit is contained in:
dmy
2026-01-12 22:56:35 +08:00
parent 996289c671
commit 5f186bfb2a
2 changed files with 16 additions and 1 deletions

View File

@@ -224,10 +224,18 @@ const fetchAIRecommendations = async () => {
title: rec.title,
url: bid?.url || '',
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
// 保存推荐结果到数据库

View File

@@ -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;
} catch (error) {
this.logger.error('获取最新 AI 推荐失败:', error);