feat: 首页增加每日练习模块

This commit is contained in:
R524809
2026-05-22 11:29:08 +08:00
parent bcece55238
commit 143395dbfd
12 changed files with 866 additions and 983 deletions
+20 -7
View File
@@ -4,7 +4,8 @@ import {
stashPendingCategoryTabId,
} from '../../utils/index';
import {
HOME_CURRENT_CAPABILITY_DATA,
HOME_DAILY_CHECKIN_ITEMS,
createEmptyHomeDataset,
type HomeDisplayItem,
type HomeDisplaySection,
type HomeDisplayDataset,
@@ -133,11 +134,22 @@ let _homeData: HomeDisplayDataset | null = null;
function applyHomeData(data: HomeDisplayDataset) {
_homeData = data;
const tabs: HomeTab[] = data.categoryTabs.map((item) => ({
id: item.id,
name: item.name,
}));
const sections = sortSectionsByTabs(tabs, data.sections);
const sectionsWithItems = data.sections.filter(
(section) => section.items.length > 0,
);
const sectionIdsWithItems = new Set(
sectionsWithItems.map((section) => section.id),
);
const tabs: HomeTab[] = data.categoryTabs
.filter((tab) => tab.id === 'all' || sectionIdsWithItems.has(tab.id))
.map((tab) => ({
id: tab.id,
name: tab.name,
}));
const sections = sortSectionsByTabs(tabs, sectionsWithItems);
const ageBands: HomeAgeBandView[] = data.ageBands.map((item, idx) => ({
...item,
icon: AGE_BAND_ICONS[idx] || '🌟',
@@ -156,6 +168,7 @@ Page({
heroSwiperCurrent: 0,
featuredItems: SKELETON_FEATURED,
hotRecommends: SKELETON_HOT,
dailyCheckinItems: HOME_DAILY_CHECKIN_ITEMS.map(toItemView),
sections: [] as HomeDisplaySectionView[],
loading: true,
},
@@ -185,7 +198,7 @@ Page({
sections: (raw.sections || []) as HomeDisplaySection[],
};
} else {
homeData = HOME_CURRENT_CAPABILITY_DATA;
homeData = createEmptyHomeDataset();
}
const { tabs, sections, ageBands } = applyHomeData(homeData);