refactor: 收口公开作品详情映射
This commit is contained in:
@@ -374,7 +374,6 @@ import {
|
||||
mapBarkBattleWorkToPlatformGalleryCard,
|
||||
mapBigFishWorkToPlatformGalleryCard,
|
||||
mapJumpHopWorkToPlatformGalleryCard,
|
||||
mapMatch3DWorkToPlatformGalleryCard,
|
||||
mapPuzzleWorkToPlatformGalleryCard,
|
||||
mapSquareHoleWorkToPlatformGalleryCard,
|
||||
mapVisualNovelWorkToPlatformGalleryCard,
|
||||
@@ -500,6 +499,7 @@ import {
|
||||
hasMatch3DRuntimeAsset,
|
||||
hasMatch3DRuntimeBackgroundAsset,
|
||||
mapMatch3DWorksForRuntimeUi,
|
||||
mapMatch3DWorkToPublicWorkDetail,
|
||||
mapPublicWorkDetailToMatch3DWork,
|
||||
normalizeMatch3DWorkForRuntimeUi,
|
||||
promoteMatch3DGeneratedBackgroundAsset,
|
||||
@@ -516,6 +516,18 @@ import {
|
||||
type RecommendRuntimeKind,
|
||||
} from './platformPublicGalleryFlow';
|
||||
import {
|
||||
mapBarkBattlePublicDetailToWorkSummary,
|
||||
mapBarkBattleWorkToPublicWorkDetail,
|
||||
mapBigFishWorkToPublicWorkDetail,
|
||||
mapJumpHopWorkToPublicWorkDetail,
|
||||
mapPublicWorkDetailToBigFishWork,
|
||||
mapPublicWorkDetailToPuzzleWork,
|
||||
mapPublicWorkDetailToSquareHoleWork,
|
||||
mapPuzzleWorkToPublicWorkDetail,
|
||||
mapRpgGalleryCardToPublicWorkDetail,
|
||||
mapSquareHoleWorkToPublicWorkDetail,
|
||||
mapVisualNovelWorkToPublicWorkDetail,
|
||||
mapWoodenFishWorkToPublicWorkDetail,
|
||||
resolveActivePlatformPublicWorkAuthorEntry,
|
||||
resolvePlatformPublicWorkActionMode,
|
||||
resolvePlatformPublicWorkDetailOpenDecision,
|
||||
@@ -719,18 +731,6 @@ function isRecommendRuntimeReadyForEntry(
|
||||
return true;
|
||||
}
|
||||
|
||||
function mapRpgGalleryCardToPublicWorkDetail(
|
||||
entry: CustomWorldGalleryCard,
|
||||
): PlatformPublicGalleryCard {
|
||||
return entry;
|
||||
}
|
||||
|
||||
function mapPuzzleWorkToPublicWorkDetail(
|
||||
item: PuzzleWorkSummary,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapPuzzleWorkToPlatformGalleryCard(item);
|
||||
}
|
||||
|
||||
function resolveVisiblePuzzleDetailCoverCount(
|
||||
entry: PlatformPublicGalleryCard | null,
|
||||
run: PuzzleRunSnapshot | null,
|
||||
@@ -747,44 +747,6 @@ function resolveVisiblePuzzleDetailCoverCount(
|
||||
return Math.max(1, run.clearedLevelCount + 1);
|
||||
}
|
||||
|
||||
function mapMatch3DWorkToPublicWorkDetail(
|
||||
item: Match3DWorkSummary,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapMatch3DWorkToPlatformGalleryCard(
|
||||
normalizeMatch3DWorkForRuntimeUi(item),
|
||||
);
|
||||
}
|
||||
|
||||
function mapSquareHoleWorkToPublicWorkDetail(
|
||||
item: SquareHoleWorkSummary,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapSquareHoleWorkToPlatformGalleryCard(item);
|
||||
}
|
||||
|
||||
function mapBigFishWorkToPublicWorkDetail(
|
||||
item: BigFishWorkSummary,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapBigFishWorkToPlatformGalleryCard(item);
|
||||
}
|
||||
|
||||
function mapVisualNovelWorkToPublicWorkDetail(
|
||||
item: VisualNovelWorkSummary,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapVisualNovelWorkToPlatformGalleryCard(item);
|
||||
}
|
||||
|
||||
function mapJumpHopWorkToPublicWorkDetail(
|
||||
item: JumpHopGalleryCardResponse | JumpHopWorkProfileResponse,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapJumpHopWorkToPlatformGalleryCard(item);
|
||||
}
|
||||
|
||||
function mapBarkBattleWorkToPublicWorkDetail(
|
||||
item: BarkBattleWorkSummary,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapBarkBattleWorkToPlatformGalleryCard(item);
|
||||
}
|
||||
|
||||
function mapBarkBattleWorkToPublishedConfig(
|
||||
work: BarkBattleWorkSummary,
|
||||
): BarkBattlePublishedConfig {
|
||||
@@ -809,44 +771,6 @@ function mapBarkBattleWorkToPublishedConfig(
|
||||
};
|
||||
}
|
||||
|
||||
function mapBarkBattlePublicDetailToWorkSummary(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
): BarkBattleWorkSummary | null {
|
||||
if (!isBarkBattleGalleryEntry(entry)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
workId: entry.workId,
|
||||
draftId: entry.sourceSessionId ?? null,
|
||||
ownerUserId: entry.ownerUserId,
|
||||
authorDisplayName: entry.authorDisplayName,
|
||||
title: entry.worldName,
|
||||
summary: entry.summaryText,
|
||||
themeDescription: entry.themeTags[0] ?? entry.summaryText,
|
||||
playerImageDescription: entry.themeTags[1] ?? entry.summaryText,
|
||||
opponentImageDescription: entry.themeTags[2] ?? entry.summaryText,
|
||||
onomatopoeia: undefined,
|
||||
playerCharacterImageSrc: entry.coverCharacterImageSrcs[0] ?? null,
|
||||
opponentCharacterImageSrc: entry.coverCharacterImageSrcs[1] ?? null,
|
||||
uiBackgroundImageSrc: entry.coverImageSrc,
|
||||
difficultyPreset: 'normal',
|
||||
status: 'published',
|
||||
generationStatus: 'ready',
|
||||
publishReady: true,
|
||||
playCount: entry.playCount ?? 0,
|
||||
recentPlayCount7d: entry.recentPlayCount7d ?? 0,
|
||||
updatedAt: entry.updatedAt,
|
||||
publishedAt: entry.publishedAt,
|
||||
};
|
||||
}
|
||||
|
||||
function mapWoodenFishWorkToPublicWorkDetail(
|
||||
item: WoodenFishGalleryCardResponse | WoodenFishWorkProfileResponse,
|
||||
): PlatformPublicGalleryCard {
|
||||
return mapWoodenFishWorkToPlatformGalleryCard(item);
|
||||
}
|
||||
|
||||
function mapVisualNovelWorkDetailToSession(
|
||||
work: VisualNovelWorkDetail,
|
||||
): VisualNovelAgentSessionSnapshot {
|
||||
@@ -892,122 +816,6 @@ function resolveMatch3DGenerationStateFromAssets(
|
||||
};
|
||||
}
|
||||
|
||||
function mapPublicWorkDetailToPuzzleWork(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
): PuzzleWorkSummary | null {
|
||||
if (!isPuzzleGalleryEntry(entry)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
workId: entry.workId,
|
||||
profileId: entry.profileId,
|
||||
ownerUserId: entry.ownerUserId,
|
||||
sourceSessionId:
|
||||
'sourceSessionId' in entry && typeof entry.sourceSessionId === 'string'
|
||||
? entry.sourceSessionId
|
||||
: null,
|
||||
authorDisplayName: entry.authorDisplayName,
|
||||
levelName: entry.worldName,
|
||||
summary: entry.summaryText,
|
||||
themeTags: entry.themeTags,
|
||||
coverImageSrc: entry.coverImageSrc,
|
||||
publicationStatus: 'published',
|
||||
updatedAt: entry.updatedAt,
|
||||
publishedAt: entry.publishedAt,
|
||||
playCount: entry.playCount ?? 0,
|
||||
remixCount: entry.remixCount ?? 0,
|
||||
likeCount: entry.likeCount ?? 0,
|
||||
pointIncentiveTotalHalfPoints: 0,
|
||||
pointIncentiveClaimedPoints: 0,
|
||||
pointIncentiveTotalPoints: 0,
|
||||
pointIncentiveClaimablePoints: 0,
|
||||
publishReady: true,
|
||||
levels:
|
||||
entry.coverSlides?.map((slide, index) => ({
|
||||
levelId: slide.id || `puzzle-level-${index + 1}`,
|
||||
levelName: slide.label,
|
||||
pictureDescription: entry.summaryText,
|
||||
candidates: [],
|
||||
selectedCandidateId: null,
|
||||
coverImageSrc: slide.imageSrc,
|
||||
coverAssetId: null,
|
||||
generationStatus: 'ready' as const,
|
||||
})) ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
function mapPublicWorkDetailToBigFishWork(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
): BigFishWorkSummary | null {
|
||||
if (!isBigFishGalleryEntry(entry)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const levelCount = Number.parseInt(
|
||||
entry.themeTags.find((tag) => /^\d+级$/u.test(tag))?.replace('级', '') ??
|
||||
'0',
|
||||
10,
|
||||
);
|
||||
|
||||
return {
|
||||
workId: entry.workId,
|
||||
sourceSessionId: entry.profileId,
|
||||
ownerUserId: entry.ownerUserId,
|
||||
authorDisplayName: entry.authorDisplayName,
|
||||
title: entry.worldName,
|
||||
subtitle: entry.subtitle,
|
||||
summary: entry.summaryText,
|
||||
coverImageSrc: entry.coverImageSrc,
|
||||
status: 'published',
|
||||
updatedAt: entry.updatedAt,
|
||||
publishedAt: entry.publishedAt,
|
||||
publishReady: true,
|
||||
levelCount: Number.isNaN(levelCount) ? 0 : levelCount,
|
||||
levelMainImageReadyCount: 0,
|
||||
levelMotionReadyCount: 0,
|
||||
backgroundReady: Boolean(entry.coverImageSrc),
|
||||
playCount: entry.playCount ?? 0,
|
||||
remixCount: entry.remixCount ?? 0,
|
||||
likeCount: entry.likeCount ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
function mapPublicWorkDetailToSquareHoleWork(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
): SquareHoleWorkSummary | null {
|
||||
if (!isSquareHoleGalleryEntry(entry)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
workId: entry.workId,
|
||||
profileId: entry.profileId,
|
||||
ownerUserId: entry.ownerUserId,
|
||||
sourceSessionId:
|
||||
'sourceSessionId' in entry && typeof entry.sourceSessionId === 'string'
|
||||
? entry.sourceSessionId
|
||||
: null,
|
||||
gameName: entry.worldName,
|
||||
themeText: entry.themeTags[0] ?? '方洞挑战',
|
||||
twistRule: entry.subtitle,
|
||||
summary: entry.summaryText,
|
||||
tags: entry.themeTags,
|
||||
coverImageSrc: entry.coverImageSrc,
|
||||
backgroundPrompt: entry.backgroundPrompt ?? '方洞挑战运行背景',
|
||||
backgroundImageSrc: entry.backgroundImageSrc ?? null,
|
||||
shapeOptions: entry.shapeOptions ?? [],
|
||||
holeOptions: entry.holeOptions ?? [],
|
||||
shapeCount: entry.shapeCount ?? 8,
|
||||
difficulty: entry.difficulty ?? 4,
|
||||
publicationStatus: 'published',
|
||||
playCount: entry.playCount ?? 0,
|
||||
updatedAt: entry.updatedAt,
|
||||
publishedAt: entry.publishedAt,
|
||||
publishReady: true,
|
||||
};
|
||||
}
|
||||
|
||||
function buildSquareHoleProfileFromSession(
|
||||
session: SquareHoleSessionSnapshot | null,
|
||||
): SquareHoleWorkProfile | null {
|
||||
|
||||
Reference in New Issue
Block a user