refactor: 收口排行配置模型
This commit is contained in:
@@ -15,6 +15,16 @@ import {
|
||||
} from './rpgEntryWorldPresentation';
|
||||
|
||||
export type PlatformRankingTab = 'hot' | 'remix' | 'new' | 'like';
|
||||
export type PlatformRankingTabConfig = {
|
||||
emptyText: string;
|
||||
id: PlatformRankingTab;
|
||||
label: string;
|
||||
metricLabel: string;
|
||||
};
|
||||
export type PlatformRankingMetric = {
|
||||
label: string;
|
||||
value: number;
|
||||
};
|
||||
export type PlatformCategoryKindFilter =
|
||||
| 'all'
|
||||
| 'puzzle'
|
||||
@@ -33,6 +43,40 @@ export type PlatformPublicCategoryGroup = {
|
||||
entries: PlatformPublicGalleryCard[];
|
||||
};
|
||||
|
||||
export const DEFAULT_PLATFORM_RANKING_TAB: PlatformRankingTab = 'hot';
|
||||
|
||||
export const PLATFORM_RANKING_TABS: PlatformRankingTabConfig[] = [
|
||||
{
|
||||
id: 'hot',
|
||||
label: '热门榜',
|
||||
metricLabel: '游玩',
|
||||
emptyText: '公开广场暂时还没有热门作品。',
|
||||
},
|
||||
{
|
||||
id: 'remix',
|
||||
label: '改造榜',
|
||||
metricLabel: '改造',
|
||||
emptyText: '公开广场暂时还没有改造作品。',
|
||||
},
|
||||
{
|
||||
id: 'new',
|
||||
label: '新品榜',
|
||||
metricLabel: '近7日',
|
||||
emptyText: '近 7 日暂时还没有新品。',
|
||||
},
|
||||
{
|
||||
id: 'like',
|
||||
label: '点赞榜',
|
||||
metricLabel: '点赞',
|
||||
emptyText: '公开广场暂时还没有点赞作品。',
|
||||
},
|
||||
];
|
||||
|
||||
const DEFAULT_PLATFORM_RANKING_CONFIG =
|
||||
PLATFORM_RANKING_TABS.find(
|
||||
(config) => config.id === DEFAULT_PLATFORM_RANKING_TAB,
|
||||
) ?? PLATFORM_RANKING_TABS[0]!;
|
||||
|
||||
export type PlatformRecommendFeedWindow = {
|
||||
activeEntry: PlatformPublicGalleryCard | null;
|
||||
activeEntryKey: string | null;
|
||||
@@ -372,6 +416,15 @@ export function buildPlatformRankingEntries(
|
||||
return sortEntriesByMetric(entries, getPlatformWorldRecentPlayCount);
|
||||
}
|
||||
|
||||
export function getPlatformRankingTabConfig(
|
||||
tab: PlatformRankingTab,
|
||||
): PlatformRankingTabConfig {
|
||||
return (
|
||||
PLATFORM_RANKING_TABS.find((config) => config.id === tab) ??
|
||||
DEFAULT_PLATFORM_RANKING_CONFIG
|
||||
);
|
||||
}
|
||||
|
||||
export function getPlatformRankingMetricValue(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
tab: PlatformRankingTab,
|
||||
@@ -391,6 +444,16 @@ export function getPlatformRankingMetricValue(
|
||||
return getPlatformWorldPlayCount(entry);
|
||||
}
|
||||
|
||||
export function getPlatformRankingMetric(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
tab: PlatformRankingTab,
|
||||
): PlatformRankingMetric {
|
||||
return {
|
||||
label: getPlatformRankingTabConfig(tab).metricLabel,
|
||||
value: getPlatformRankingMetricValue(entry, tab),
|
||||
};
|
||||
}
|
||||
|
||||
function getPlatformCategoryCompositeScore(entry: PlatformPublicGalleryCard) {
|
||||
// 分类频道只使用公开读模型已经返回的指标做前端排序,不在 UI 层伪造评分数据。
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user