refactor: 收口公开详情启动意图

This commit is contained in:
2026-06-04 00:46:58 +08:00
parent 37a35daddb
commit e1134cc9ec
6 changed files with 645 additions and 188 deletions
@@ -534,6 +534,7 @@ import {
resolvePlatformPublicWorkDetailOpenStrategy,
resolvePlatformPublicWorkLikeIntent,
resolvePlatformPublicWorkRemixIntent,
resolvePlatformPublicWorkStartIntent,
resolveVisiblePuzzleDetailCoverCount,
} from './platformPublicWorkDetailFlow';
import {
@@ -12611,134 +12612,93 @@ export function PlatformEntryFlowShellImpl({
}
runProtectedAction(() => {
if (isBigFishGalleryEntry(selectedPublicWorkDetail)) {
const work = mapPublicWorkDetailToBigFishWork(selectedPublicWorkDetail);
if (!work) {
setPublicWorkDetailError('当前作品缺少会话信息,暂时无法进入玩法。');
return;
}
startBigFishRunFromWork(work);
return;
}
const intent = resolvePlatformPublicWorkStartIntent(
selectedPublicWorkDetail,
{
selectedPuzzleDetail,
selectedRpgDetailEntry: selectedDetailEntry,
barkBattleGalleryEntries,
barkBattleWorks,
mapMatch3DWork: mapPublicWorkDetailToMatch3DWork,
},
);
if (isPuzzleGalleryEntry(selectedPublicWorkDetail)) {
const work =
selectedPuzzleDetail?.profileId === selectedPublicWorkDetail.profileId
? selectedPuzzleDetail
: mapPublicWorkDetailToPuzzleWork(selectedPublicWorkDetail);
if (!work) {
setPublicWorkDetailError(
'当前拼图作品信息不完整,暂时无法进入玩法。',
switch (intent.type) {
case 'blocked':
setPublicWorkDetailError(intent.errorMessage);
return;
case 'start-big-fish':
startBigFishRunFromWork(intent.work, intent.returnStage);
return;
case 'start-puzzle':
setPublicWorkDetailError(null);
void startPuzzleRunFromProfile(
intent.work.profileId,
intent.returnStage,
intent.work,
true,
null,
{ authMode: intent.authMode },
);
return;
}
setPublicWorkDetailError(null);
void startPuzzleRunFromProfile(
work.profileId,
'work-detail',
work,
true,
null,
{ authMode: 'isolated' },
);
return;
}
if (isJumpHopGalleryEntry(selectedPublicWorkDetail)) {
setPublicWorkDetailError(null);
void startJumpHopRunFromProfile(selectedPublicWorkDetail.profileId, {
returnStage: 'work-detail',
});
return;
}
if (isWoodenFishGalleryEntry(selectedPublicWorkDetail)) {
setPublicWorkDetailError(null);
void startWoodenFishRunFromProfile(selectedPublicWorkDetail.profileId, {
returnStage: 'work-detail',
});
return;
}
if (isMatch3DGalleryEntry(selectedPublicWorkDetail)) {
const work = mapPublicWorkDetailToMatch3DWork(selectedPublicWorkDetail);
if (!work) {
setPublicWorkDetailError(
'当前抓大鹅作品信息不完整,暂时无法进入玩法。',
case 'start-jump-hop':
setPublicWorkDetailError(null);
void startJumpHopRunFromProfile(intent.profileId, {
returnStage: intent.returnStage,
});
return;
case 'start-wooden-fish':
setPublicWorkDetailError(null);
void startWoodenFishRunFromProfile(intent.profileId, {
returnStage: intent.returnStage,
});
return;
case 'start-match3d':
setPublicWorkDetailError(null);
void startMatch3DRunFromProfile(
intent.work,
intent.returnStage,
true,
);
return;
}
setPublicWorkDetailError(null);
void startMatch3DRunFromProfile(work, 'work-detail', true);
return;
}
if (isSquareHoleGalleryEntry(selectedPublicWorkDetail)) {
const work = mapPublicWorkDetailToSquareHoleWork(
selectedPublicWorkDetail,
);
if (!work) {
setPublicWorkDetailError(
'当前方洞挑战作品信息不完整,暂时无法进入玩法。',
case 'start-square-hole':
setPublicWorkDetailError(null);
void startSquareHoleRunFromProfile(
intent.work,
intent.returnStage,
true,
);
return;
}
setPublicWorkDetailError(null);
void startSquareHoleRunFromProfile(work, 'work-detail', true);
return;
}
if (isVisualNovelGalleryEntry(selectedPublicWorkDetail)) {
setPublicWorkDetailError(null);
void startVisualNovelRunFromProfile(
selectedPublicWorkDetail.profileId,
'work-detail',
);
return;
}
if (isBarkBattleGalleryEntry(selectedPublicWorkDetail)) {
const work =
barkBattleGalleryEntries.find(
(item) => item.workId === selectedPublicWorkDetail.workId,
) ??
barkBattleWorks.find(
(item) => item.workId === selectedPublicWorkDetail.workId,
) ??
mapBarkBattlePublicDetailToWorkSummary(selectedPublicWorkDetail);
if (!work) {
setPublicWorkDetailError(
'当前汪汪声浪作品信息不完整,暂时无法进入玩法。',
case 'start-visual-novel':
setPublicWorkDetailError(null);
void startVisualNovelRunFromProfile(
intent.profileId,
intent.returnStage,
);
return;
case 'start-bark-battle':
setPublicWorkDetailError(null);
startBarkBattleRunFromWork(intent.work, intent.returnStage);
return;
case 'start-edutainment':
setPublicWorkDetailError(null);
void startBabyObjectMatchRuntimeFromEntry(
intent.entry,
intent.returnStage,
);
return;
case 'record-rpg-gallery-play':
break;
default: {
const exhaustive: never = intent;
return exhaustive;
}
setPublicWorkDetailError(null);
startBarkBattleRunFromWork(work, 'work-detail');
return;
}
if (isEdutainmentGalleryEntry(selectedPublicWorkDetail)) {
setPublicWorkDetailError(null);
void startBabyObjectMatchRuntimeFromEntry(
selectedPublicWorkDetail,
'work-detail',
);
return;
}
const launchEntry =
selectedDetailEntry?.profileId === selectedPublicWorkDetail.profileId
? selectedDetailEntry
: null;
if (!launchEntry) {
setPublicWorkDetailError('作品详情尚未读取完成。');
return;
}
setIsPublicWorkDetailBusy(true);
void recordRpgEntryWorldGalleryPlay(
launchEntry.ownerUserId,
launchEntry.profileId,
intent.entry.ownerUserId,
intent.entry.profileId,
)
.then((updatedEntry) => {
setSelectedDetailEntry(updatedEntry);
File diff suppressed because it is too large Load Diff
@@ -4,6 +4,7 @@ import type {
JumpHopGalleryCardResponse,
JumpHopWorkProfileResponse,
} from '../../../packages/shared/src/contracts/jumpHop';
import type { Match3DWorkSummary } from '../../../packages/shared/src/contracts/match3dWorks';
import type { PuzzleRunSnapshot } from '../../../packages/shared/src/contracts/puzzleRuntimeSession';
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
import type { CustomWorldGalleryCard } from '../../../packages/shared/src/contracts/runtime';
@@ -121,6 +122,72 @@ export type PlatformPublicWorkRemixIntent =
errorMessage: string;
};
export type PlatformPublicWorkStartIntent =
| {
type: 'blocked';
errorMessage: string;
}
| {
type: 'start-big-fish';
work: BigFishWorkSummary;
returnStage: 'work-detail';
}
| {
type: 'start-puzzle';
work: PuzzleWorkSummary;
returnStage: 'work-detail';
authMode: 'isolated';
}
| {
type: 'start-jump-hop';
profileId: string;
returnStage: 'work-detail';
}
| {
type: 'start-wooden-fish';
profileId: string;
returnStage: 'work-detail';
}
| {
type: 'start-match3d';
work: Match3DWorkSummary;
returnStage: 'work-detail';
}
| {
type: 'start-square-hole';
work: SquareHoleWorkSummary;
returnStage: 'work-detail';
}
| {
type: 'start-visual-novel';
profileId: string;
returnStage: 'work-detail';
}
| {
type: 'start-bark-battle';
work: BarkBattleWorkSummary;
returnStage: 'work-detail';
}
| {
type: 'start-edutainment';
entry: PlatformPublicGalleryCard;
returnStage: 'work-detail';
}
| {
type: 'record-rpg-gallery-play';
entry: CustomWorldGalleryCard;
};
export type PlatformPublicWorkStartIntentDeps = {
selectedPuzzleDetail?: PuzzleWorkSummary | null;
selectedRpgDetailEntry?: CustomWorldGalleryCard | null;
barkBattleGalleryEntries?: readonly BarkBattleWorkSummary[];
barkBattleWorks?: readonly BarkBattleWorkSummary[];
mapMatch3DWork: (
entry: PlatformPublicGalleryCard,
) => Match3DWorkSummary | null;
};
export type PlatformPublicWorkDetailOpenDecision =
| {
type: 'blocked';
@@ -622,6 +689,149 @@ export function resolvePlatformPublicWorkRemixIntent(
};
}
export function resolvePlatformPublicWorkStartIntent(
entry: PlatformPublicGalleryCard,
deps: PlatformPublicWorkStartIntentDeps,
): PlatformPublicWorkStartIntent {
if (isBigFishGalleryEntry(entry)) {
const work = mapPublicWorkDetailToBigFishWork(entry);
if (!work) {
return {
type: 'blocked',
errorMessage: '当前作品缺少会话信息,暂时无法进入玩法。',
};
}
return {
type: 'start-big-fish',
work,
returnStage: 'work-detail',
};
}
if (isPuzzleGalleryEntry(entry)) {
const work =
deps.selectedPuzzleDetail?.profileId === entry.profileId
? deps.selectedPuzzleDetail
: mapPublicWorkDetailToPuzzleWork(entry);
if (!work) {
return {
type: 'blocked',
errorMessage: '当前拼图作品信息不完整,暂时无法进入玩法。',
};
}
return {
type: 'start-puzzle',
work,
returnStage: 'work-detail',
authMode: 'isolated',
};
}
if (isJumpHopGalleryEntry(entry)) {
return {
type: 'start-jump-hop',
profileId: entry.profileId,
returnStage: 'work-detail',
};
}
if (isWoodenFishGalleryEntry(entry)) {
return {
type: 'start-wooden-fish',
profileId: entry.profileId,
returnStage: 'work-detail',
};
}
if (isMatch3DGalleryEntry(entry)) {
// 中文注释:抓大鹅运行态素材归一仍归 Match3D Module,公开详情 Flow 只接其 Adapter。
const work = deps.mapMatch3DWork(entry);
if (!work) {
return {
type: 'blocked',
errorMessage: '当前抓大鹅作品信息不完整,暂时无法进入玩法。',
};
}
return {
type: 'start-match3d',
work,
returnStage: 'work-detail',
};
}
if (isSquareHoleGalleryEntry(entry)) {
const work = mapPublicWorkDetailToSquareHoleWork(entry);
if (!work) {
return {
type: 'blocked',
errorMessage: '当前方洞挑战作品信息不完整,暂时无法进入玩法。',
};
}
return {
type: 'start-square-hole',
work,
returnStage: 'work-detail',
};
}
if (isVisualNovelGalleryEntry(entry)) {
return {
type: 'start-visual-novel',
profileId: entry.profileId,
returnStage: 'work-detail',
};
}
if (isBarkBattleGalleryEntry(entry)) {
const work =
deps.barkBattleGalleryEntries?.find(
(item) => item.workId === entry.workId,
) ??
deps.barkBattleWorks?.find((item) => item.workId === entry.workId) ??
mapBarkBattlePublicDetailToWorkSummary(entry);
if (!work) {
return {
type: 'blocked',
errorMessage: '当前汪汪声浪作品信息不完整,暂时无法进入玩法。',
};
}
return {
type: 'start-bark-battle',
work,
returnStage: 'work-detail',
};
}
if (isEdutainmentGalleryEntry(entry)) {
return {
type: 'start-edutainment',
entry,
returnStage: 'work-detail',
};
}
const launchEntry =
deps.selectedRpgDetailEntry?.profileId === entry.profileId
? deps.selectedRpgDetailEntry
: null;
if (!launchEntry) {
return {
type: 'blocked',
errorMessage: '作品详情尚未读取完成。',
};
}
return {
type: 'record-rpg-gallery-play',
entry: launchEntry,
};
}
export function resolvePlatformPublicWorkDetailOpenDecision(
entry: PlatformPublicGalleryCard,
deps: PlatformPublicWorkDetailOpenDecisionDeps = {},