fix: stabilize match3d demo discovery
This commit is contained in:
@@ -107,6 +107,12 @@ import type {
|
||||
VisualNovelWorkSummary,
|
||||
} from '../../../packages/shared/src/contracts/visualNovel';
|
||||
import { buildCustomWorldPlayableCharacters } from '../../data/characterPresets';
|
||||
import {
|
||||
MATCH3D_DEMO_GALLERY_CARD,
|
||||
MATCH3D_DEMO_PROFILE_ID,
|
||||
MATCH3D_DEMO_WORK_PROFILE,
|
||||
isMatch3DDemoProfileId,
|
||||
} from '../../data/match3dDemoGalleryCard';
|
||||
import {
|
||||
buildPublicWorkStagePath,
|
||||
pushAppHistoryPath,
|
||||
@@ -181,7 +187,10 @@ import {
|
||||
type JumpHopWorkspaceCreateRequest,
|
||||
} from '../../services/jump-hop/jumpHopClient';
|
||||
import { match3dCreationClient } from '../../services/match3d-creation';
|
||||
import { createServerMatch3DRuntimeAdapter } from '../../services/match3d-runtime';
|
||||
import {
|
||||
createLocalMatch3DRuntimeAdapter,
|
||||
createServerMatch3DRuntimeAdapter,
|
||||
} from '../../services/match3d-runtime';
|
||||
import {
|
||||
deleteMatch3DWork,
|
||||
getMatch3DWorkDetail,
|
||||
@@ -3096,6 +3105,13 @@ export function PlatformEntryFlowShellImpl({
|
||||
setSelectedDetailEntry,
|
||||
});
|
||||
const { setPlatformTab } = platformBootstrap;
|
||||
const returnPlatformHomeAfterMissingWork = useCallback(() => {
|
||||
setPlatformTab('home');
|
||||
setSelectionStage('platform');
|
||||
if (!maybeAlertWorkNotFoundAndReturnHome()) {
|
||||
pushAppHistoryPath('/');
|
||||
}
|
||||
}, [setPlatformTab, setSelectionStage]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectionStage === 'profile-feedback') {
|
||||
@@ -3711,6 +3727,8 @@ export function PlatformEntryFlowShellImpl({
|
||||
}
|
||||
return '服务端预览';
|
||||
}, [agentResultPreview]);
|
||||
const match3dDemoProfile = MATCH3D_DEMO_WORK_PROFILE;
|
||||
const match3dDemoGalleryCard = MATCH3D_DEMO_GALLERY_CARD;
|
||||
|
||||
const featuredGalleryEntries = useMemo(() => {
|
||||
const bigFishPublicEntries = isBigFishCreationVisible
|
||||
@@ -3750,6 +3768,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
[
|
||||
...bigFishPublicEntries,
|
||||
...match3dPublicEntries,
|
||||
match3dDemoGalleryCard,
|
||||
...puzzlePublicEntries,
|
||||
...barkBattlePublicEntries,
|
||||
...squareHolePublicEntries,
|
||||
@@ -3774,6 +3793,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
squareHoleGalleryEntries,
|
||||
visualNovelGalleryEntries,
|
||||
woodenFishGalleryEntries,
|
||||
match3dDemoGalleryCard,
|
||||
]);
|
||||
const latestGalleryEntries = useMemo(
|
||||
() =>
|
||||
@@ -3784,6 +3804,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
? bigFishGalleryEntries.map(mapBigFishWorkToPlatformGalleryCard)
|
||||
: []),
|
||||
...match3dGalleryEntries.map(mapMatch3DWorkToPublicWorkDetail),
|
||||
match3dDemoGalleryCard,
|
||||
...puzzleGalleryEntries.map(mapPuzzleWorkToPlatformGalleryCard),
|
||||
...barkBattleGalleryEntries.map(mapBarkBattleWorkToPlatformGalleryCard),
|
||||
...jumpHopGalleryEntries.map(mapJumpHopWorkToPlatformGalleryCard),
|
||||
@@ -3825,6 +3846,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
barkBattleGalleryEntries,
|
||||
barkBattleWorks,
|
||||
woodenFishGalleryEntries,
|
||||
match3dDemoGalleryCard,
|
||||
],
|
||||
);
|
||||
const recommendRuntimeEntries = useMemo(() => {
|
||||
@@ -3832,9 +3854,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
filterGeneralPublicWorks([
|
||||
...featuredGalleryEntries,
|
||||
...latestGalleryEntries,
|
||||
]).forEach((entry) => {
|
||||
entryMap.set(getPlatformPublicGalleryEntryKey(entry), entry);
|
||||
});
|
||||
])
|
||||
.filter((entry) => !isMatch3DDemoProfileId(entry.profileId))
|
||||
.forEach((entry) => {
|
||||
entryMap.set(getPlatformPublicGalleryEntryKey(entry), entry);
|
||||
});
|
||||
return Array.from(entryMap.values());
|
||||
}, [featuredGalleryEntries, latestGalleryEntries]);
|
||||
|
||||
@@ -4344,6 +4368,21 @@ export function PlatformEntryFlowShellImpl({
|
||||
() => createServerMatch3DRuntimeAdapter(),
|
||||
[],
|
||||
);
|
||||
const match3dDemoRuntimeAdapter = useMemo(
|
||||
() =>
|
||||
createLocalMatch3DRuntimeAdapter({
|
||||
clearCount: 21,
|
||||
profileId: MATCH3D_DEMO_PROFILE_ID,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
const resolveMatch3DRuntimeAdapter = useCallback(
|
||||
(profileId: string | null | undefined) =>
|
||||
isMatch3DDemoProfileId(profileId)
|
||||
? match3dDemoRuntimeAdapter
|
||||
: match3dRuntimeAdapter,
|
||||
[match3dDemoRuntimeAdapter, match3dRuntimeAdapter],
|
||||
);
|
||||
const match3dFlow = usePlatformCreationAgentFlowController<
|
||||
Match3DAgentSessionSnapshot,
|
||||
CreateMatch3DSessionRequest,
|
||||
@@ -8287,13 +8326,12 @@ export function PlatformEntryFlowShellImpl({
|
||||
setPuzzleDetailReturnTarget(null);
|
||||
setPuzzleRun(null);
|
||||
setPuzzleRuntimeAuthMode('default');
|
||||
setPuzzleGalleryEntries((current) =>
|
||||
current.filter((entry) => entry.profileId !== profileId),
|
||||
);
|
||||
setPuzzleError(null);
|
||||
setPublicWorkDetailError(null);
|
||||
setPlatformTab('home');
|
||||
setSelectionStage('platform');
|
||||
if (!maybeAlertWorkNotFoundAndReturnHome()) {
|
||||
pushAppHistoryPath('/');
|
||||
}
|
||||
returnPlatformHomeAfterMissingWork();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8310,9 +8348,9 @@ export function PlatformEntryFlowShellImpl({
|
||||
[
|
||||
isPuzzleBusy,
|
||||
resolvePuzzleErrorMessage,
|
||||
returnPlatformHomeAfterMissingWork,
|
||||
setIsPuzzleBusy,
|
||||
setPuzzleError,
|
||||
setPlatformTab,
|
||||
setSelectionStage,
|
||||
],
|
||||
);
|
||||
@@ -8332,10 +8370,13 @@ export function PlatformEntryFlowShellImpl({
|
||||
setMatch3DError(null);
|
||||
|
||||
try {
|
||||
let runtimeProfile = profile;
|
||||
const isDemoProfile = isMatch3DDemoProfileId(profile.profileId);
|
||||
let runtimeProfile: Match3DWorkProfile | Match3DWorkSummary =
|
||||
isDemoProfile ? match3dDemoProfile : profile;
|
||||
if (
|
||||
!hasMatch3DRuntimeAsset(profile.generatedItemAssets) ||
|
||||
!hasMatch3DRuntimeBackgroundAsset(profile)
|
||||
!isDemoProfile &&
|
||||
(!hasMatch3DRuntimeAsset(profile.generatedItemAssets) ||
|
||||
!hasMatch3DRuntimeBackgroundAsset(profile))
|
||||
) {
|
||||
try {
|
||||
const { item } = await getMatch3DWorkDetail(profile.profileId);
|
||||
@@ -8369,7 +8410,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
? { itemTypeCountOverride: options.itemTypeCountOverride }
|
||||
: {}),
|
||||
};
|
||||
const { run } = await match3dRuntimeAdapter.startRun(
|
||||
const activeRuntimeAdapter = resolveMatch3DRuntimeAdapter(
|
||||
runtimeProfile.profileId,
|
||||
);
|
||||
const { run } = await activeRuntimeAdapter.startRun(
|
||||
runtimeProfile.profileId,
|
||||
runtimeOptions,
|
||||
);
|
||||
@@ -8409,9 +8453,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
},
|
||||
[
|
||||
isMatch3DBusy,
|
||||
match3dDemoProfile,
|
||||
match3dFlow,
|
||||
match3dRuntimeAdapter,
|
||||
resolveMatch3DErrorMessage,
|
||||
resolveMatch3DRuntimeAdapter,
|
||||
setMatch3DError,
|
||||
setSelectionStage,
|
||||
],
|
||||
@@ -9945,13 +9990,12 @@ export function PlatformEntryFlowShellImpl({
|
||||
setPuzzleDetailReturnTarget(null);
|
||||
setPuzzleRun(null);
|
||||
setPuzzleRuntimeAuthMode('default');
|
||||
setPuzzleGalleryEntries((current) =>
|
||||
current.filter((entry) => entry.profileId !== profileId),
|
||||
);
|
||||
setPuzzleError(null);
|
||||
setPublicWorkDetailError(null);
|
||||
setPlatformTab('home');
|
||||
setSelectionStage('platform');
|
||||
if (!maybeAlertWorkNotFoundAndReturnHome()) {
|
||||
pushAppHistoryPath('/');
|
||||
}
|
||||
returnPlatformHomeAfterMissingWork();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9969,7 +10013,6 @@ export function PlatformEntryFlowShellImpl({
|
||||
resolvePuzzleErrorMessage,
|
||||
setIsPuzzleBusy,
|
||||
setPuzzleError,
|
||||
setPlatformTab,
|
||||
setSelectionStage,
|
||||
],
|
||||
);
|
||||
@@ -9984,8 +10027,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
try {
|
||||
const entries =
|
||||
match3dGalleryEntries.length > 0
|
||||
? match3dGalleryEntries
|
||||
: await refreshMatch3DGallery();
|
||||
? [...match3dGalleryEntries, match3dDemoProfile]
|
||||
: await refreshMatch3DGallery().then((items) => [
|
||||
...items,
|
||||
match3dDemoProfile,
|
||||
]);
|
||||
const matchedEntry = entries.find(
|
||||
(entry) => entry.profileId === profileId,
|
||||
);
|
||||
@@ -10005,6 +10051,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
},
|
||||
[
|
||||
match3dGalleryEntries,
|
||||
match3dDemoProfile,
|
||||
openPublicWorkDetail,
|
||||
refreshMatch3DGallery,
|
||||
resolveMatch3DErrorMessage,
|
||||
@@ -10254,8 +10301,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
resolvePuzzleErrorMessage,
|
||||
setIsPuzzleBusy,
|
||||
setPuzzleError,
|
||||
setPlatformTab,
|
||||
setSelectionStage,
|
||||
returnPlatformHomeAfterMissingWork,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -11338,7 +11384,9 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
match3dFlow.setIsBusy(true);
|
||||
setMatch3DError(null);
|
||||
void match3dRuntimeAdapter
|
||||
void resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
)
|
||||
.restartRun(match3dRun.runId)
|
||||
.then(({ run }) => {
|
||||
setMatch3DRun(run);
|
||||
@@ -11358,14 +11406,18 @@ export function PlatformEntryFlowShellImpl({
|
||||
if (!runId) {
|
||||
return Promise.reject(new Error('抓大鹅运行态缺少 runId。'));
|
||||
}
|
||||
return match3dRuntimeAdapter.clickItem(runId, payload);
|
||||
return resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
).clickItem(runId, payload);
|
||||
}}
|
||||
onTimeExpired={() => {
|
||||
if (!match3dRun?.runId) {
|
||||
return;
|
||||
}
|
||||
|
||||
void match3dRuntimeAdapter
|
||||
void resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
)
|
||||
.finishTimeUp(match3dRun.runId)
|
||||
.then(({ run }) => {
|
||||
setMatch3DRun(run);
|
||||
@@ -12176,8 +12228,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
const tryOpenMatch3DGalleryEntry = async () => {
|
||||
const entries =
|
||||
match3dGalleryEntries.length > 0
|
||||
? match3dGalleryEntries
|
||||
: await refreshMatch3DGallery();
|
||||
? [...match3dGalleryEntries, match3dDemoProfile]
|
||||
: await refreshMatch3DGallery().then((items) => [
|
||||
...items,
|
||||
match3dDemoProfile,
|
||||
]);
|
||||
const matchedEntry = entries.find((entry) => {
|
||||
const detailEntry = mapMatch3DWorkToPublicWorkDetail(entry);
|
||||
return (
|
||||
@@ -12383,11 +12438,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
setPuzzleRuntimeAuthMode('default');
|
||||
setPuzzleError(null);
|
||||
setPublicWorkDetailError(null);
|
||||
setPlatformTab('home');
|
||||
setSelectionStage('platform');
|
||||
if (!maybeAlertWorkNotFoundAndReturnHome()) {
|
||||
pushAppHistoryPath('/');
|
||||
}
|
||||
returnPlatformHomeAfterMissingWork();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12416,6 +12467,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
refreshSquareHoleGallery,
|
||||
refreshVisualNovelGallery,
|
||||
squareHoleGalleryEntries,
|
||||
returnPlatformHomeAfterMissingWork,
|
||||
selectionStage,
|
||||
setPlatformTab,
|
||||
setPuzzleError,
|
||||
@@ -12597,6 +12649,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
refreshBigFishGallery,
|
||||
resolveBigFishErrorMessage,
|
||||
setBigFishError,
|
||||
match3dDemoProfile,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -13775,7 +13828,9 @@ export function PlatformEntryFlowShellImpl({
|
||||
match3dRun?.runId &&
|
||||
match3dRun.status === 'running'
|
||||
) {
|
||||
void match3dRuntimeAdapter
|
||||
void resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
)
|
||||
.stopRun(match3dRun.runId)
|
||||
.catch(() => undefined);
|
||||
}
|
||||
@@ -13788,7 +13843,9 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
match3dFlow.setIsBusy(true);
|
||||
setMatch3DError(null);
|
||||
void match3dRuntimeAdapter
|
||||
void resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
)
|
||||
.restartRun(match3dRun.runId)
|
||||
.then(({ run }) => {
|
||||
setMatch3DRun(run);
|
||||
@@ -13813,14 +13870,18 @@ export function PlatformEntryFlowShellImpl({
|
||||
new Error('抓大鹅运行态缺少 runId。'),
|
||||
);
|
||||
}
|
||||
return match3dRuntimeAdapter.clickItem(runId, payload);
|
||||
return resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
).clickItem(runId, payload);
|
||||
}}
|
||||
onTimeExpired={() => {
|
||||
if (!match3dRun?.runId) {
|
||||
return;
|
||||
}
|
||||
|
||||
void match3dRuntimeAdapter
|
||||
void resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
)
|
||||
.finishTimeUp(match3dRun.runId)
|
||||
.then(({ run }) => {
|
||||
setMatch3DRun(run);
|
||||
|
||||
Reference in New Issue
Block a user