fix: tighten public work type routing
This commit is contained in:
@@ -395,6 +395,7 @@ import {
|
||||
buildPlatformPublicGalleryCardKey,
|
||||
isBarkBattleGalleryEntry,
|
||||
isBigFishGalleryEntry,
|
||||
isCustomWorldGalleryEntry,
|
||||
isEdutainmentGalleryEntry,
|
||||
isJumpHopGalleryEntry,
|
||||
isMatch3DGalleryEntry,
|
||||
@@ -701,6 +702,10 @@ function getPlatformPublicGalleryEntryKey(entry: PlatformPublicGalleryCard) {
|
||||
function getPlatformRecommendRuntimeKind(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
): RecommendRuntimeKind {
|
||||
if (isCustomWorldGalleryEntry(entry)) {
|
||||
return 'rpg';
|
||||
}
|
||||
|
||||
if (isBigFishGalleryEntry(entry)) {
|
||||
return 'big-fish';
|
||||
}
|
||||
@@ -741,7 +746,7 @@ function getPlatformRecommendRuntimeKind(
|
||||
return 'edutainment';
|
||||
}
|
||||
|
||||
return 'rpg';
|
||||
throw new Error('未知公开作品类型,无法启动推荐玩法。');
|
||||
}
|
||||
|
||||
function resolveRecommendEntryShareStage(
|
||||
@@ -758,6 +763,14 @@ function resolveRecommendEntryShareStage(
|
||||
return 'work-detail';
|
||||
}
|
||||
|
||||
function resolveUnsupportedPublicWorkActionMessage(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
actionLabel: string,
|
||||
) {
|
||||
const sourceType = 'sourceType' in entry ? entry.sourceType : 'custom-world';
|
||||
return `作品类型 ${sourceType} 暂不支持${actionLabel}。`;
|
||||
}
|
||||
|
||||
function isRecommendRuntimeReadyForEntry(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
state: RecommendRuntimeState,
|
||||
@@ -800,8 +813,11 @@ function isRecommendRuntimeReadyForEntry(
|
||||
if (expectedKind === 'edutainment') {
|
||||
return Boolean(state.babyObjectMatchDraft);
|
||||
}
|
||||
if (expectedKind === 'rpg') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
throw new Error('未知推荐玩法类型。');
|
||||
}
|
||||
|
||||
function isSamePlatformPublicGalleryEntry(
|
||||
@@ -834,7 +850,10 @@ function mergePlatformPublicGalleryEntries(
|
||||
function mapRpgGalleryCardToPublicWorkDetail(
|
||||
entry: CustomWorldGalleryCard,
|
||||
): PlatformPublicGalleryCard {
|
||||
return entry;
|
||||
return {
|
||||
...entry,
|
||||
sourceType: 'custom-world',
|
||||
};
|
||||
}
|
||||
|
||||
function mapPuzzleWorkToPublicWorkDetail(
|
||||
@@ -13521,54 +13540,55 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEdutainmentGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('宝贝识物点赞将在后续版本开放。');
|
||||
if (isCustomWorldGalleryEntry(entry)) {
|
||||
void likeRpgEntryWorldGallery(entry.ownerUserId, entry.profileId)
|
||||
.then((updatedEntry) => {
|
||||
setSelectedDetailEntry((current) =>
|
||||
current?.profileId === updatedEntry.profileId
|
||||
? updatedEntry
|
||||
: current,
|
||||
);
|
||||
platformBootstrap.setPublishedGalleryEntries((current) =>
|
||||
current.map((item) =>
|
||||
item.profileId === updatedEntry.profileId
|
||||
? updatedEntry
|
||||
: item,
|
||||
),
|
||||
);
|
||||
syncUpdatedPublicWorkDetail(
|
||||
mapRpgGalleryCardToPublicWorkDetail(updatedEntry),
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
setPublicWorkDetailError(
|
||||
resolveRpgCreationErrorMessage(error, '点赞 RPG 作品失败。'),
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
isPuzzleClearGalleryEntry(entry) ||
|
||||
isJumpHopGalleryEntry(entry) ||
|
||||
isWoodenFishGalleryEntry(entry) ||
|
||||
isMatch3DGalleryEntry(entry) ||
|
||||
isEdutainmentGalleryEntry(entry) ||
|
||||
isBarkBattleGalleryEntry(entry) ||
|
||||
isSquareHoleGalleryEntry(entry) ||
|
||||
isVisualNovelGalleryEntry(entry)
|
||||
) {
|
||||
setPublicWorkDetailError(
|
||||
resolveUnsupportedPublicWorkActionMessage(entry, '点赞'),
|
||||
);
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBarkBattleGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('汪汪声浪点赞将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSquareHoleGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('方洞挑战点赞将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isVisualNovelGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('视觉小说点赞将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
void likeRpgEntryWorldGallery(entry.ownerUserId, entry.profileId)
|
||||
.then((updatedEntry) => {
|
||||
setSelectedDetailEntry((current) =>
|
||||
current?.profileId === updatedEntry.profileId
|
||||
? updatedEntry
|
||||
: current,
|
||||
);
|
||||
platformBootstrap.setPublishedGalleryEntries((current) =>
|
||||
current.map((item) =>
|
||||
item.profileId === updatedEntry.profileId ? updatedEntry : item,
|
||||
),
|
||||
);
|
||||
syncUpdatedPublicWorkDetail(
|
||||
mapRpgGalleryCardToPublicWorkDetail(updatedEntry),
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
setPublicWorkDetailError(
|
||||
resolveRpgCreationErrorMessage(error, '点赞 RPG 作品失败。'),
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
});
|
||||
setPublicWorkDetailError('未知公开作品类型,无法点赞。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
});
|
||||
},
|
||||
[
|
||||
@@ -14189,7 +14209,12 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
void openRpgPublicWorkDetail(entry);
|
||||
if (isCustomWorldGalleryEntry(entry)) {
|
||||
void openRpgPublicWorkDetail(entry);
|
||||
return;
|
||||
}
|
||||
|
||||
setPublicWorkDetailError('未知公开作品类型,无法打开作品详情。');
|
||||
},
|
||||
[
|
||||
openPuzzlePublicWorkDetail,
|
||||
@@ -15506,14 +15531,6 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isJumpHopGalleryEntry(selectedPublicWorkDetail)) {
|
||||
setPublicWorkDetailError(null);
|
||||
void startJumpHopRunFromProfile(selectedPublicWorkDetail.profileId, {
|
||||
returnStage: 'work-detail',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (isWoodenFishGalleryEntry(selectedPublicWorkDetail)) {
|
||||
setPublicWorkDetailError(null);
|
||||
void startWoodenFishRunFromProfile(selectedPublicWorkDetail.profileId, {
|
||||
@@ -15588,6 +15605,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isCustomWorldGalleryEntry(selectedPublicWorkDetail)) {
|
||||
setPublicWorkDetailError('未知公开作品类型,无法进入玩法。');
|
||||
return;
|
||||
}
|
||||
|
||||
const launchEntry =
|
||||
selectedDetailEntry?.profileId === selectedPublicWorkDetail.profileId
|
||||
? selectedDetailEntry
|
||||
@@ -15759,8 +15781,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
embedded: true,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
} else if (isCustomWorldGalleryEntry(entry)) {
|
||||
started = true;
|
||||
} else {
|
||||
throw new Error('未知公开作品类型,无法启动推荐玩法。');
|
||||
}
|
||||
|
||||
if (!isCurrentStartRequest()) {
|
||||
@@ -16403,74 +16427,49 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPuzzleClearGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('拼消消作品改造将在后续版本开放。');
|
||||
if (
|
||||
isPuzzleClearGalleryEntry(entry) ||
|
||||
isMatch3DGalleryEntry(entry) ||
|
||||
isSquareHoleGalleryEntry(entry) ||
|
||||
isJumpHopGalleryEntry(entry) ||
|
||||
isWoodenFishGalleryEntry(entry) ||
|
||||
isVisualNovelGalleryEntry(entry) ||
|
||||
isEdutainmentGalleryEntry(entry) ||
|
||||
isBarkBattleGalleryEntry(entry)
|
||||
) {
|
||||
setPublicWorkDetailError(
|
||||
resolveUnsupportedPublicWorkActionMessage(entry, '改造'),
|
||||
);
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMatch3DGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('抓大鹅作品改造将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
if (isCustomWorldGalleryEntry(entry)) {
|
||||
void remixRpgEntryWorldGallery(entry.ownerUserId, entry.profileId)
|
||||
.then((response) => {
|
||||
const nextEntry = response.entry;
|
||||
setSelectedDetailEntry(nextEntry);
|
||||
platformBootstrap.setSavedCustomWorldEntries([
|
||||
nextEntry,
|
||||
...platformBootstrap.savedCustomWorldEntries.filter(
|
||||
(entry) => entry.profileId !== nextEntry.profileId,
|
||||
),
|
||||
]);
|
||||
void detailNavigation.openSavedCustomWorldEditor(nextEntry);
|
||||
})
|
||||
.catch((error) => {
|
||||
setPublicWorkDetailError(
|
||||
resolveRpgCreationErrorMessage(error, 'Remix RPG 作品失败。'),
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSquareHoleGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('方洞挑战作品改造将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isJumpHopGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('跳一跳作品改造将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isWoodenFishGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('敲木鱼作品改造将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isVisualNovelGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('视觉小说作品改造将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEdutainmentGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('宝贝识物作品改造将在创作链路接入后开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBarkBattleGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('汪汪声浪作品改造将在后续版本开放。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
void remixRpgEntryWorldGallery(entry.ownerUserId, entry.profileId)
|
||||
.then((response) => {
|
||||
const nextEntry = response.entry;
|
||||
setSelectedDetailEntry(nextEntry);
|
||||
platformBootstrap.setSavedCustomWorldEntries([
|
||||
nextEntry,
|
||||
...platformBootstrap.savedCustomWorldEntries.filter(
|
||||
(entry) => entry.profileId !== nextEntry.profileId,
|
||||
),
|
||||
]);
|
||||
void detailNavigation.openSavedCustomWorldEditor(nextEntry);
|
||||
})
|
||||
.catch((error) => {
|
||||
setPublicWorkDetailError(
|
||||
resolveRpgCreationErrorMessage(error, 'Remix RPG 作品失败。'),
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
});
|
||||
setPublicWorkDetailError('未知公开作品类型,无法改造。');
|
||||
setIsPublicWorkDetailBusy(false);
|
||||
});
|
||||
},
|
||||
[
|
||||
@@ -16630,6 +16629,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isCustomWorldGalleryEntry(entry)) {
|
||||
setPublicWorkDetailError('未知公开作品类型,无法编辑。');
|
||||
return;
|
||||
}
|
||||
|
||||
const editEntry =
|
||||
selectedDetailEntry?.profileId === entry.profileId
|
||||
? selectedDetailEntry
|
||||
@@ -16737,6 +16741,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
const entry =
|
||||
await getRpgEntryWorldGalleryDetailByCode(normalizedKeyword);
|
||||
const card = {
|
||||
sourceType: 'custom-world',
|
||||
ownerUserId: entry.ownerUserId,
|
||||
profileId: entry.profileId,
|
||||
publicWorkCode: entry.publicWorkCode,
|
||||
@@ -16755,7 +16760,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
playCount: entry.playCount ?? 0,
|
||||
remixCount: entry.remixCount ?? 0,
|
||||
likeCount: entry.likeCount ?? 0,
|
||||
} satisfies CustomWorldGalleryCard;
|
||||
} satisfies PlatformPublicGalleryCard;
|
||||
if (!canExposePublicWork(card)) {
|
||||
throw new Error(EDUTAINMENT_HIDDEN_MESSAGE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user