refactor: 收口推荐 runtime 自动启动

This commit is contained in:
2026-06-04 04:44:22 +08:00
parent 4e23995347
commit 05713e1d3b
7 changed files with 209 additions and 36 deletions

View File

@@ -553,9 +553,9 @@ import {
buildPlatformPublicGalleryFeeds,
getPlatformPublicGalleryEntryKey,
getPlatformRecommendRuntimeKind,
isPlatformRecommendRuntimeReadyForEntry,
isSamePlatformPublicGalleryEntry,
type RecommendRuntimeKind,
resolvePlatformRecommendRuntimeAutoStartDecision,
resolvePlatformRecommendRuntimeStartIntent,
} from './platformPublicGalleryFlow';
import {
@@ -12309,31 +12309,15 @@ export function PlatformEntryFlowShellImpl({
]);
useEffect(() => {
if (
isDesktopLayout ||
selectionStage !== 'platform' ||
platformBootstrap.platformTab !== 'home' ||
platformBootstrap.isLoadingPlatform
) {
return;
}
if (recommendRuntimeEntries.length === 0) {
setActiveRecommendEntryKey(null);
setActiveRecommendRuntimeKind(null);
setActiveRecommendRuntimeError(null);
return;
}
const activeRecommendEntry = activeRecommendEntryKey
? (recommendRuntimeEntries.find(
(entry) =>
getPlatformPublicGalleryEntryKey(entry) === activeRecommendEntryKey,
) ?? null)
: null;
const isActiveRecommendRuntimeReady =
activeRecommendEntry !== null &&
isPlatformRecommendRuntimeReadyForEntry(activeRecommendEntry, {
const decision = resolvePlatformRecommendRuntimeAutoStartDecision({
isDesktopLayout,
selectionStage,
platformTab: platformBootstrap.platformTab,
isLoadingPlatform: platformBootstrap.isLoadingPlatform,
entries: recommendRuntimeEntries,
activeEntryKey: activeRecommendEntryKey,
isStarting: isStartingRecommendEntry,
readyState: {
activeKind: activeRecommendRuntimeKind,
hasBabyObjectMatchDraft: Boolean(babyObjectMatchDraft),
hasBigFishRun: Boolean(bigFishRun),
@@ -12345,19 +12329,21 @@ export function PlatformEntryFlowShellImpl({
puzzleRunEntryProfileId: puzzleRun?.entryProfileId ?? null,
puzzleRunCurrentLevelProfileId:
puzzleRun?.currentLevel?.profileId ?? null,
});
if (
(activeRecommendEntry !== null && isActiveRecommendRuntimeReady) ||
isStartingRecommendEntry
) {
},
});
if (decision.type === 'noop') {
return;
}
const nextRecommendEntry =
activeRecommendEntry ?? recommendRuntimeEntries[0];
if (nextRecommendEntry) {
void selectRecommendRuntimeEntry(nextRecommendEntry);
if (decision.type === 'clear') {
setActiveRecommendEntryKey(null);
setActiveRecommendRuntimeKind(null);
setActiveRecommendRuntimeError(null);
return;
}
void selectRecommendRuntimeEntry(decision.entry);
}, [
activeRecommendEntryKey,
activeRecommendRuntimeKind,