refactor: 收口玩过作品打开意图
This commit is contained in:
@@ -512,6 +512,7 @@ import {
|
||||
resolveMatch3DRuntimeGeneratedBackgroundAsset,
|
||||
resolveMatch3DRuntimeGeneratedItemAssets,
|
||||
} from './platformMatch3DRuntimeProfile';
|
||||
import { resolvePlatformPlayedWorkOpenIntent } from './platformPlayedWorkOpenModel';
|
||||
import {
|
||||
type PlatformPublicCodeSearchStep,
|
||||
resolvePlatformPublicCodeSearchPlan,
|
||||
@@ -13815,145 +13816,59 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
const openPlayedWork = useCallback(
|
||||
(work: ProfilePlayedWorkSummary) => {
|
||||
const worldType = (work.worldType ?? '').toLowerCase();
|
||||
const intent = resolvePlatformPlayedWorkOpenIntent(work);
|
||||
setIsProfilePlayStatsOpen(false);
|
||||
|
||||
if (worldType === 'puzzle' || work.worldKey.startsWith('puzzle:')) {
|
||||
const profileId =
|
||||
work.profileId ?? work.worldKey.replace(/^puzzle:/u, '');
|
||||
if (profileId) {
|
||||
void openPuzzlePublicWorkDetail(profileId, { tab: 'profile' });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
worldType === 'match3d' ||
|
||||
worldType === 'match_3d' ||
|
||||
work.worldKey.startsWith('match3d:')
|
||||
) {
|
||||
const profileId =
|
||||
work.profileId ?? work.worldKey.replace(/^match3d:/u, '');
|
||||
if (profileId) {
|
||||
void openMatch3DPublicWorkDetail(profileId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
worldType === 'square-hole' ||
|
||||
worldType === 'square_hole' ||
|
||||
work.worldKey.startsWith('square-hole:')
|
||||
) {
|
||||
const profileId =
|
||||
work.profileId ?? work.worldKey.replace(/^square-hole:/u, '');
|
||||
if (profileId) {
|
||||
void openSquareHolePublicWorkDetail(profileId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
worldType === 'jump-hop' ||
|
||||
worldType === 'jump_hop' ||
|
||||
work.worldKey.startsWith('jump-hop:')
|
||||
) {
|
||||
const profileId =
|
||||
work.profileId ?? work.worldKey.replace(/^jump-hop:/u, '');
|
||||
if (profileId) {
|
||||
void openJumpHopPublicWorkDetail(profileId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
worldType === 'wooden-fish' ||
|
||||
worldType === 'wooden_fish' ||
|
||||
work.worldKey.startsWith('wooden-fish:')
|
||||
) {
|
||||
const profileId =
|
||||
work.profileId ?? work.worldKey.replace(/^wooden-fish:/u, '');
|
||||
if (profileId) {
|
||||
void openWoodenFishPublicWorkDetail(profileId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
worldType === 'big_fish' ||
|
||||
worldType === 'big-fish' ||
|
||||
work.worldKey.startsWith('big-fish:')
|
||||
) {
|
||||
const sessionId =
|
||||
work.profileId ?? work.worldKey.replace(/^big-fish:/u, '');
|
||||
if (!sessionId) {
|
||||
switch (intent.type) {
|
||||
case 'noop':
|
||||
return;
|
||||
}
|
||||
void refreshBigFishGallery()
|
||||
.then((entries) => {
|
||||
const matchedEntry = entries.find(
|
||||
(entry) => entry.sourceSessionId === sessionId,
|
||||
);
|
||||
if (matchedEntry) {
|
||||
openPublicWorkDetail(
|
||||
mapBigFishWorkToPublicWorkDetail(matchedEntry),
|
||||
);
|
||||
return;
|
||||
}
|
||||
openPublicWorkDetail(
|
||||
mapBigFishWorkToPublicWorkDetail({
|
||||
workId: `big-fish:${sessionId}`,
|
||||
sourceSessionId: sessionId,
|
||||
ownerUserId: work.ownerUserId ?? '',
|
||||
authorDisplayName: work.worldSubtitle || '玩家',
|
||||
title: work.worldTitle,
|
||||
subtitle: work.worldSubtitle,
|
||||
summary: work.worldSubtitle,
|
||||
coverImageSrc: null,
|
||||
status: 'published',
|
||||
updatedAt: work.lastPlayedAt,
|
||||
publishReady: true,
|
||||
levelCount: 0,
|
||||
levelMainImageReadyCount: 0,
|
||||
levelMotionReadyCount: 0,
|
||||
backgroundReady: false,
|
||||
}),
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
setBigFishError(
|
||||
resolveBigFishErrorMessage(error, '进入大鱼吃小鱼作品失败。'),
|
||||
);
|
||||
case 'open-puzzle':
|
||||
void openPuzzlePublicWorkDetail(intent.profileId, {
|
||||
tab: intent.tab,
|
||||
});
|
||||
return;
|
||||
return;
|
||||
case 'open-match3d':
|
||||
void openMatch3DPublicWorkDetail(intent.profileId);
|
||||
return;
|
||||
case 'open-square-hole':
|
||||
void openSquareHolePublicWorkDetail(intent.profileId);
|
||||
return;
|
||||
case 'open-jump-hop':
|
||||
void openJumpHopPublicWorkDetail(intent.profileId);
|
||||
return;
|
||||
case 'open-wooden-fish':
|
||||
void openWoodenFishPublicWorkDetail(intent.profileId);
|
||||
return;
|
||||
case 'open-big-fish':
|
||||
void refreshBigFishGallery()
|
||||
.then((entries) => {
|
||||
const matchedEntry = entries.find(
|
||||
(entry) => entry.sourceSessionId === intent.sessionId,
|
||||
);
|
||||
if (matchedEntry) {
|
||||
openPublicWorkDetail(
|
||||
mapBigFishWorkToPublicWorkDetail(matchedEntry),
|
||||
);
|
||||
return;
|
||||
}
|
||||
openPublicWorkDetail(
|
||||
mapBigFishWorkToPublicWorkDetail(intent.fallbackWork),
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
setBigFishError(
|
||||
resolveBigFishErrorMessage(error, '进入大鱼吃小鱼作品失败。'),
|
||||
);
|
||||
});
|
||||
return;
|
||||
case 'open-rpg':
|
||||
void openRpgPublicWorkDetail(intent.detail);
|
||||
return;
|
||||
default: {
|
||||
const exhaustive: never = intent;
|
||||
return exhaustive;
|
||||
}
|
||||
}
|
||||
|
||||
const profileId = work.profileId ?? work.worldKey;
|
||||
const ownerUserId = work.ownerUserId;
|
||||
if (!ownerUserId || !profileId) {
|
||||
return;
|
||||
}
|
||||
|
||||
void openRpgPublicWorkDetail({
|
||||
ownerUserId,
|
||||
profileId,
|
||||
publicWorkCode: null,
|
||||
authorPublicUserCode: null,
|
||||
visibility: 'published',
|
||||
publishedAt: work.firstPlayedAt,
|
||||
updatedAt: work.lastPlayedAt,
|
||||
authorDisplayName: work.worldSubtitle,
|
||||
worldName: work.worldTitle,
|
||||
subtitle: work.worldSubtitle,
|
||||
summaryText: '',
|
||||
coverImageSrc: null,
|
||||
themeMode: 'martial',
|
||||
playableNpcCount: 0,
|
||||
landmarkCount: 0,
|
||||
playCount: 0,
|
||||
remixCount: 0,
|
||||
likeCount: 0,
|
||||
});
|
||||
},
|
||||
[
|
||||
openMatch3DPublicWorkDetail,
|
||||
|
||||
Reference in New Issue
Block a user