feat: 增加收藏、下载种子数据功能

This commit is contained in:
R524809
2026-05-11 12:38:10 +08:00
parent debecd67c6
commit 39b8e01c23
11 changed files with 521 additions and 21 deletions
@@ -35,6 +35,13 @@ function difficultyLabel(difficulty) {
return DIFFICULTY_LABELS[difficulty] || '基础';
}
function mergeSeedStats(items) {
for (const item of items) {
item.likes = (item.likes || 0) + (item.likes_seed || 0);
item.downloads = (item.downloads || 0) + (item.downloads_seed || 0);
}
}
function toRecommendedItem(ws) {
return {
worksheetId: ws._id,
@@ -118,6 +125,7 @@ exports.main = async (event) => {
const band = AGE_BANDS[ageKey];
const db = cloud.database();
const activeWorksheets = await queryActiveWorksheets(db);
mergeSeedStats(activeWorksheets);
const matchedWorksheets = activeWorksheets.filter((ws) =>
coversAgeBand(ws, band),
);