feat: 首页、分类页加载数据逻辑重构
This commit is contained in:
@@ -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 : '生成分类页数据失败',
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user