refactor: 收口公开码搜索映射

This commit is contained in:
2026-06-04 06:04:55 +08:00
parent 217cc881e6
commit e570d50e9f
9 changed files with 749 additions and 123 deletions

View File

@@ -226,15 +226,7 @@ import {
buildSquareHolePublicWorkCode,
buildVisualNovelPublicWorkCode,
buildWoodenFishPublicWorkCode,
isSameBabyObjectMatchPublicWorkCode,
isSameBarkBattlePublicWorkCode,
isSameBigFishPublicWorkCode,
isSameJumpHopPublicWorkCode,
isSameMatch3DPublicWorkCode,
isSamePuzzlePublicWorkCode,
isSameSquareHolePublicWorkCode,
isSameVisualNovelPublicWorkCode,
isSameWoodenFishPublicWorkCode,
} from '../../services/publicWorkCode';
import {
createPuzzleAgentSession,
@@ -356,8 +348,6 @@ import {
} from '../rpg-entry/rpgEntryPublicGalleryViewModel';
import {
isEdutainmentGalleryEntry,
mapBabyObjectMatchDraftToPlatformGalleryCard,
mapBarkBattleWorkToPlatformGalleryCard,
mapPuzzleWorkToPlatformGalleryCard,
type PlatformPublicGalleryCard,
resolvePlatformPublicWorkCode,
@@ -550,8 +540,18 @@ import {
resolveProfileWalletBalance,
} from './platformProfileWalletDeltaModel';
import {
mapRpgPublicCodeSearchDetailToGalleryCard,
type PlatformPublicCodeSearchStep,
resolveBabyObjectMatchPublicCodeSearchMatch,
resolveBarkBattlePublicCodeSearchMatch,
resolveBigFishPublicCodeSearchMatch,
resolveJumpHopPublicCodeSearchMatch,
resolveMatch3DPublicCodeSearchMatch,
resolvePlatformPublicCodeSearchPlan,
resolvePuzzlePublicCodeSearchMatch,
resolveSquareHolePublicCodeSearchMatch,
resolveVisualNovelPublicCodeSearchMatch,
resolveWoodenFishPublicCodeSearchMatch,
} from './platformPublicCodeSearchModel';
import {
buildPlatformPublicGalleryFeeds,
@@ -12281,26 +12281,7 @@ export function PlatformEntryFlowShellImpl({
const tryOpenGalleryEntry = async () => {
const entry =
await getRpgEntryWorldGalleryDetailByCode(normalizedKeyword);
const card = {
ownerUserId: entry.ownerUserId,
profileId: entry.profileId,
publicWorkCode: entry.publicWorkCode,
authorPublicUserCode: entry.authorPublicUserCode,
visibility: 'published',
publishedAt: entry.publishedAt,
updatedAt: entry.updatedAt,
authorDisplayName: entry.authorDisplayName,
worldName: entry.worldName,
subtitle: entry.subtitle,
summaryText: entry.summaryText,
coverImageSrc: entry.coverImageSrc,
themeMode: entry.themeMode,
playableNpcCount: entry.playableNpcCount,
landmarkCount: entry.landmarkCount,
playCount: entry.playCount ?? 0,
remixCount: entry.remixCount ?? 0,
likeCount: entry.likeCount ?? 0,
} satisfies CustomWorldGalleryCard;
const card = mapRpgPublicCodeSearchDetailToGalleryCard(entry);
if (!canExposePublicWork(card)) {
throw new Error(EDUTAINMENT_HIDDEN_MESSAGE);
}
@@ -12313,18 +12294,16 @@ export function PlatformEntryFlowShellImpl({
puzzleGalleryEntries.length > 0
? puzzleGalleryEntries
: await refreshPuzzleGallery();
const matchedEntry = entries
.map(mapPuzzleWorkToPublicWorkDetail)
.filter(canExposePublicWork)
.find((entry) =>
isSamePuzzlePublicWorkCode(normalizedKeyword, entry.profileId),
);
const matchedEntry = resolvePuzzlePublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到拼图作品。');
}
await openPuzzlePublicWorkDetail(matchedEntry.profileId, {
await openPuzzlePublicWorkDetail(matchedEntry.detail.profileId, {
tab: platformBootstrap.platformTab,
});
};
@@ -12333,170 +12312,133 @@ export function PlatformEntryFlowShellImpl({
bigFishGalleryEntries.length > 0
? bigFishGalleryEntries
: await refreshBigFishGallery();
const matchedEntry = entries.find((entry) => {
const detailEntry = mapBigFishWorkToPublicWorkDetail(entry);
return (
canExposePublicWork(detailEntry) &&
isSameBigFishPublicWorkCode(
normalizedKeyword,
entry.sourceSessionId,
)
);
});
const matchedEntry = resolveBigFishPublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到大鱼吃小鱼作品。');
}
openPublicWorkDetail(mapBigFishWorkToPublicWorkDetail(matchedEntry));
openPublicWorkDetail(matchedEntry.detail);
};
const tryOpenJumpHopGalleryEntry = async () => {
const entries =
jumpHopGalleryEntries.length > 0
? jumpHopGalleryEntries
: await refreshJumpHopGallery();
const matchedEntry = entries.find((entry) => {
const detailEntry = mapJumpHopWorkToPublicWorkDetail(entry);
return (
canExposePublicWork(detailEntry) &&
isSameJumpHopPublicWorkCode(normalizedKeyword, entry.profileId)
);
});
const matchedEntry = resolveJumpHopPublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到跳一跳作品。');
}
openPublicWorkDetail(mapJumpHopWorkToPublicWorkDetail(matchedEntry));
openPublicWorkDetail(matchedEntry.detail);
};
const tryOpenWoodenFishGalleryEntry = async () => {
const entries =
woodenFishGalleryEntries.length > 0
? woodenFishGalleryEntries
: await refreshWoodenFishGallery();
const matchedEntry = entries.find((entry) => {
const detailEntry = mapWoodenFishWorkToPublicWorkDetail(entry);
return (
canExposePublicWork(detailEntry) &&
isSameWoodenFishPublicWorkCode(normalizedKeyword, entry.profileId)
);
});
const matchedEntry = resolveWoodenFishPublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到敲木鱼作品。');
}
openPublicWorkDetail(mapWoodenFishWorkToPublicWorkDetail(matchedEntry));
openPublicWorkDetail(matchedEntry.detail);
};
const tryOpenMatch3DGalleryEntry = async () => {
const entries =
match3dGalleryEntries.length > 0
? match3dGalleryEntries
: await refreshMatch3DGallery();
const matchedEntry = entries.find((entry) => {
const detailEntry = mapMatch3DWorkToPublicWorkDetail(entry);
return (
canExposePublicWork(detailEntry) &&
isSameMatch3DPublicWorkCode(normalizedKeyword, entry.profileId)
);
});
const matchedEntry = resolveMatch3DPublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到抓大鹅作品。');
}
openPublicWorkDetail(mapMatch3DWorkToPublicWorkDetail(matchedEntry));
openPublicWorkDetail(matchedEntry.detail);
};
const tryOpenSquareHoleGalleryEntry = async () => {
const entries =
squareHoleGalleryEntries.length > 0
? squareHoleGalleryEntries
: await refreshSquareHoleGallery();
const matchedEntry = entries.find((entry) => {
const detailEntry = mapSquareHoleWorkToPublicWorkDetail(entry);
return (
canExposePublicWork(detailEntry) &&
isSameSquareHolePublicWorkCode(normalizedKeyword, entry.profileId)
);
});
const matchedEntry = resolveSquareHolePublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到方洞挑战作品。');
}
openPublicWorkDetail(mapSquareHoleWorkToPublicWorkDetail(matchedEntry));
openPublicWorkDetail(matchedEntry.detail);
};
const tryOpenVisualNovelGalleryEntry = async () => {
const entries =
visualNovelGalleryEntries.length > 0
? visualNovelGalleryEntries
: await refreshVisualNovelGallery();
const matchedEntry = entries.find((entry) => {
const detailEntry = mapVisualNovelWorkToPublicWorkDetail(entry);
return (
canExposePublicWork(detailEntry) &&
isSameVisualNovelPublicWorkCode(normalizedKeyword, entry.profileId)
);
});
const matchedEntry = resolveVisualNovelPublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到视觉小说作品。');
}
openPublicWorkDetail(
mapVisualNovelWorkToPublicWorkDetail(matchedEntry),
);
openPublicWorkDetail(matchedEntry.detail);
};
const tryOpenBabyObjectMatchGalleryEntry = async () => {
const entries = (await listLocalBabyObjectMatchDrafts()).filter(
(draft) => draft.publicationStatus === 'published',
);
const matchedDraft = entries.find((draft) => {
const detailEntry =
mapBabyObjectMatchDraftToPlatformGalleryCard(draft);
return (
canExposePublicWork(detailEntry) &&
isSameBabyObjectMatchPublicWorkCode(
normalizedKeyword,
draft.profileId,
)
);
});
const matchedDraft = resolveBabyObjectMatchPublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedDraft) {
throw new Error('未找到宝贝识物作品。');
}
const detailEntry =
mapBabyObjectMatchDraftToPlatformGalleryCard(matchedDraft);
setBabyObjectMatchDraft(matchedDraft);
openPublicWorkDetail(detailEntry);
setBabyObjectMatchDraft(matchedDraft.item);
openPublicWorkDetail(matchedDraft.detail);
};
const tryOpenBarkBattleGalleryEntry = async () => {
const entries =
barkBattleGalleryEntries.length > 0
? barkBattleGalleryEntries
: await refreshBarkBattleGallery();
const matchedEntry = entries.find((entry) => {
const detailEntry = mapBarkBattleWorkToPlatformGalleryCard(entry);
return (
canExposePublicWork(detailEntry) &&
isSameBarkBattlePublicWorkCode(normalizedKeyword, entry.workId)
);
});
const matchedEntry = resolveBarkBattlePublicCodeSearchMatch(
entries,
normalizedKeyword,
);
if (!matchedEntry) {
throw new Error('未找到汪汪声浪作品。');
}
if (selectionStage === 'bark-battle-runtime') {
startBarkBattleRunFromWork(matchedEntry, 'platform');
startBarkBattleRunFromWork(matchedEntry.item, 'platform');
return;
}
openPublicWorkDetail(
mapBarkBattleWorkToPlatformGalleryCard(matchedEntry),
);
openPublicWorkDetail(matchedEntry.detail);
};
const runSearchStep = async (step: PlatformPublicCodeSearchStep) => {