refactor: 收口推荐运行态就绪判定

This commit is contained in:
2026-06-04 01:19:23 +08:00
parent 8d3e14020f
commit 7301043afb
6 changed files with 170 additions and 68 deletions

View File

@@ -503,6 +503,7 @@ import {
import {
getPlatformPublicGalleryEntryKey,
getPlatformRecommendRuntimeKind,
isPlatformRecommendRuntimeReadyForEntry,
isSamePlatformPublicGalleryEntry,
mergePlatformPublicGalleryEntries,
type RecommendRuntimeKind,
@@ -600,18 +601,6 @@ type WoodenFishRuntimeReturnStage =
type VisualNovelEntryGenerationPhase = 'generating' | 'ready' | 'failed';
type BabyObjectMatchGenerationPhase = 'generating' | 'ready' | 'failed';
type RecommendRuntimeState = {
activeKind: RecommendRuntimeKind | null;
babyObjectMatchDraft: BabyObjectMatchDraft | null;
bigFishRun: BigFishRuntimeSnapshotResponse | null;
jumpHopRun: JumpHopRunResponse['run'] | null;
match3dRun: Match3DRunSnapshot | null;
puzzleRun: PuzzleRunSnapshot | null;
squareHoleRun: SquareHoleRunSnapshot | null;
visualNovelRun: VisualNovelRunSnapshot | null;
woodenFishRun: WoodenFishRunResponse['run'] | null;
};
type PuzzleSaveArchiveState = {
runtimeKind?: unknown;
entryProfileId?: unknown;
@@ -682,49 +671,6 @@ const PUZZLE_DRAFT_GENERATION_POINT_COST = 2;
const MATCH3D_DRAFT_GENERATION_POINT_COST = 10;
const BARK_BATTLE_DRAFT_GENERATION_POINT_COST = 3;
function isRecommendRuntimeReadyForEntry(
entry: PlatformPublicGalleryCard,
state: RecommendRuntimeState,
) {
const expectedKind = getPlatformRecommendRuntimeKind(entry);
if (state.activeKind !== expectedKind) {
return false;
}
if (expectedKind === 'big-fish') {
return Boolean(state.bigFishRun);
}
if (expectedKind === 'jump-hop') {
return Boolean(state.jumpHopRun);
}
if (expectedKind === 'wooden-fish') {
return Boolean(state.woodenFishRun);
}
if (expectedKind === 'match3d') {
return Boolean(state.match3dRun);
}
if (expectedKind === 'puzzle') {
return (
state.puzzleRun?.entryProfileId === entry.profileId ||
state.puzzleRun?.currentLevel?.profileId === entry.profileId
);
}
if (expectedKind === 'square-hole') {
return Boolean(state.squareHoleRun);
}
if (expectedKind === 'visual-novel') {
return Boolean(state.visualNovelRun);
}
if (expectedKind === 'bark-battle') {
return true;
}
if (expectedKind === 'edutainment') {
return Boolean(state.babyObjectMatchDraft);
}
return true;
}
function mapBarkBattleWorkToPublishedConfig(
work: BarkBattleWorkSummary,
): BarkBattlePublishedConfig {
@@ -13359,16 +13305,18 @@ export function PlatformEntryFlowShellImpl({
: null;
const isActiveRecommendRuntimeReady =
activeRecommendEntry !== null &&
isRecommendRuntimeReadyForEntry(activeRecommendEntry, {
isPlatformRecommendRuntimeReadyForEntry(activeRecommendEntry, {
activeKind: activeRecommendRuntimeKind,
babyObjectMatchDraft,
bigFishRun,
jumpHopRun,
match3dRun,
puzzleRun,
squareHoleRun,
visualNovelRun,
woodenFishRun,
hasBabyObjectMatchDraft: Boolean(babyObjectMatchDraft),
hasBigFishRun: Boolean(bigFishRun),
hasJumpHopRun: Boolean(jumpHopRun),
hasMatch3DRun: Boolean(match3dRun),
hasSquareHoleRun: Boolean(squareHoleRun),
hasVisualNovelRun: Boolean(visualNovelRun),
hasWoodenFishRun: Boolean(woodenFishRun),
puzzleRunEntryProfileId: puzzleRun?.entryProfileId ?? null,
puzzleRunCurrentLevelProfileId:
puzzleRun?.currentLevel?.profileId ?? null,
});
if (
(activeRecommendEntry !== null && isActiveRecommendRuntimeReady) ||