feat: 首页、分类页加载数据逻辑重构

This commit is contained in:
R524809
2026-04-30 16:44:45 +08:00
parent c112c70bab
commit 7126d3a941
63 changed files with 805 additions and 433 deletions
+5 -5
View File
@@ -45,7 +45,7 @@ function toHomeDisplayItem(ws) {
ageBand: ageBand(ws.ageMin || 0, ws.ageMax || 0),
difficulty: DIFFICULTY_LABELS[ws.difficulty] || '基础',
icon: '',
img: ws.previewImg || '',
previewImg: ws.previewImg || '',
badge: ws.isNew ? 'NEW' : ws.isHot ? 'HOT' : '',
path: ws.path || '',
available: true,
@@ -141,7 +141,9 @@ async function buildCategoryData(db) {
}
async function buildHomeData(db, event) {
const featuredIds = Array.isArray(event.featuredIds) ? event.featuredIds : [];
const featuredIds = Array.isArray(event.featuredIds)
? event.featuredIds
: [];
const hotIds = Array.isArray(event.hotIds) ? event.hotIds : [];
const sectionConfigs = Array.isArray(event.sections) ? event.sections : [];
@@ -264,9 +266,7 @@ exports.main = async (event) => {
return {
success: false,
message:
error instanceof Error
? error.message
: '生成分类页数据失败',
error instanceof Error ? error.message : '生成分类页数据失败',
};
}
};