refactor: 收口分类配置模型
This commit is contained in:
@@ -160,11 +160,16 @@ import {
|
||||
buildPublicCategoryGroups,
|
||||
buildPublicGalleryCardKey,
|
||||
dedupePlatformPublicGalleryEntries,
|
||||
DEFAULT_PLATFORM_CATEGORY_KIND_FILTER,
|
||||
DEFAULT_PLATFORM_CATEGORY_SORT_MODE,
|
||||
DEFAULT_PLATFORM_RANKING_TAB,
|
||||
filterPlatformWorkSearchResults,
|
||||
filterTodayPublishedEntries,
|
||||
getAllPlatformPublicEntries,
|
||||
getNextPlatformCategorySortMode,
|
||||
getPlatformCategoryKindFilterOption,
|
||||
getPlatformCategoryPrimaryMetric,
|
||||
getPlatformCategorySortOption,
|
||||
getPlatformPublicEntries,
|
||||
getPlatformRankingMetric,
|
||||
getPlatformRankingTabConfig,
|
||||
@@ -174,6 +179,8 @@ import {
|
||||
getPlatformWorldRemixCount,
|
||||
isExactPublicWorkCodeSearch,
|
||||
matchesPlatformCategoryKindFilter,
|
||||
PLATFORM_CATEGORY_KIND_FILTERS,
|
||||
PLATFORM_CATEGORY_SORT_OPTIONS,
|
||||
PLATFORM_RANKING_TABS,
|
||||
type PlatformCategoryKindFilter,
|
||||
type PlatformCategorySortMode,
|
||||
@@ -374,30 +381,6 @@ const EDUTAINMENT_DISCOVER_CHANNEL = {
|
||||
id: 'edutainment',
|
||||
label: EDUTAINMENT_WORK_TAG,
|
||||
} as const;
|
||||
const PLATFORM_CATEGORY_KIND_FILTERS: Array<{
|
||||
id: PlatformCategoryKindFilter;
|
||||
label: string;
|
||||
}> = [
|
||||
{ id: 'all', label: '全部' },
|
||||
{ id: 'puzzle', label: '拼图' },
|
||||
{ id: 'match3d', label: '抓鹅' },
|
||||
{ id: 'square-hole', label: '方洞' },
|
||||
{ id: 'visual-novel', label: '视觉' },
|
||||
{ id: 'bark-battle', label: '汪汪' },
|
||||
{ id: 'big-fish', label: '大鱼' },
|
||||
{ id: 'jump-hop', label: '跳跃' },
|
||||
{ id: 'wooden-fish', label: '木鱼' },
|
||||
{ id: 'custom-world', label: 'RPG' },
|
||||
];
|
||||
const PLATFORM_CATEGORY_SORT_OPTIONS: Array<{
|
||||
id: PlatformCategorySortMode;
|
||||
label: string;
|
||||
}> = [
|
||||
{ id: 'composite', label: '综合' },
|
||||
{ id: 'latest', label: '最新' },
|
||||
{ id: 'play', label: '游玩' },
|
||||
{ id: 'like', label: '点赞' },
|
||||
];
|
||||
const BABY_LOVE_DRAWING_DEFAULT_CARD = {
|
||||
title: '宝贝爱画',
|
||||
subtitle: '空白画板',
|
||||
@@ -3522,9 +3505,11 @@ export function RpgEntryHomeView({
|
||||
null,
|
||||
);
|
||||
const [categoryKindFilter, setCategoryKindFilter] =
|
||||
useState<PlatformCategoryKindFilter>('all');
|
||||
useState<PlatformCategoryKindFilter>(
|
||||
DEFAULT_PLATFORM_CATEGORY_KIND_FILTER,
|
||||
);
|
||||
const [categorySortMode, setCategorySortMode] =
|
||||
useState<PlatformCategorySortMode>('composite');
|
||||
useState<PlatformCategorySortMode>(DEFAULT_PLATFORM_CATEGORY_SORT_MODE);
|
||||
const [isCategoryFilterPanelOpen, setIsCategoryFilterPanelOpen] =
|
||||
useState(false);
|
||||
const [discoverChannel, setDiscoverChannel] =
|
||||
@@ -3674,15 +3659,12 @@ export function RpgEntryHomeView({
|
||||
}, [activeCategoryGroup, categoryKindFilter, categorySortMode]);
|
||||
const activeCategoryRawCount = activeCategoryGroup?.entries.length ?? 0;
|
||||
const activeCategoryFilterLabel =
|
||||
PLATFORM_CATEGORY_KIND_FILTERS.find(
|
||||
(option) => option.id === categoryKindFilter,
|
||||
)?.label ?? '全部';
|
||||
getPlatformCategoryKindFilterOption(categoryKindFilter).label;
|
||||
const activeCategorySortLabel =
|
||||
PLATFORM_CATEGORY_SORT_OPTIONS.find(
|
||||
(option) => option.id === categorySortMode,
|
||||
)?.label ?? '综合';
|
||||
getPlatformCategorySortOption(categorySortMode).label;
|
||||
const activeCategoryFilterCount = activeCategoryEntries.length;
|
||||
const categoryFilterApplied = categoryKindFilter !== 'all';
|
||||
const categoryFilterApplied =
|
||||
categoryKindFilter !== DEFAULT_PLATFORM_CATEGORY_KIND_FILTER;
|
||||
const visibleTabs = useMemo<PlatformHomeTab[]>(
|
||||
() =>
|
||||
isAuthenticated
|
||||
@@ -4633,16 +4615,7 @@ export function RpgEntryHomeView({
|
||||
submitWorkSearch(mobileSearchKeyword);
|
||||
};
|
||||
const cycleCategorySortMode = () => {
|
||||
const currentIndex = PLATFORM_CATEGORY_SORT_OPTIONS.findIndex(
|
||||
(option) => option.id === categorySortMode,
|
||||
);
|
||||
const nextIndex =
|
||||
currentIndex >= 0
|
||||
? (currentIndex + 1) % PLATFORM_CATEGORY_SORT_OPTIONS.length
|
||||
: 0;
|
||||
setCategorySortMode(
|
||||
PLATFORM_CATEGORY_SORT_OPTIONS[nextIndex]?.id ?? 'composite',
|
||||
);
|
||||
setCategorySortMode(getNextPlatformCategorySortMode(categorySortMode));
|
||||
};
|
||||
const desktopHeroEntry =
|
||||
featuredShelf[0] ?? generalLatestEntries[0] ?? myEntries[0] ?? null;
|
||||
|
||||
Reference in New Issue
Block a user