refactor: 收口公开详情编辑意图
This commit is contained in:
@@ -7,7 +7,10 @@ import type {
|
||||
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';
|
||||
import type {
|
||||
CustomWorldGalleryCard,
|
||||
CustomWorldLibraryEntry,
|
||||
} from '../../../packages/shared/src/contracts/runtime';
|
||||
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
|
||||
import type { VisualNovelWorkSummary } from '../../../packages/shared/src/contracts/visualNovel';
|
||||
import type {
|
||||
@@ -15,6 +18,7 @@ import type {
|
||||
WoodenFishWorkProfileResponse,
|
||||
} from '../../../packages/shared/src/contracts/woodenFish';
|
||||
import { buildPublicWorkStagePath } from '../../routing/appPageRoutes';
|
||||
import type { CustomWorldProfile } from '../../types';
|
||||
import {
|
||||
isBarkBattleGalleryEntry,
|
||||
isBigFishGalleryEntry,
|
||||
@@ -51,6 +55,10 @@ export type PlatformPublicWorkDetailKind =
|
||||
| 'visual-novel'
|
||||
| 'wooden-fish';
|
||||
|
||||
export type PlatformRpgPublicWorkDetailEntry =
|
||||
| CustomWorldGalleryCard
|
||||
| CustomWorldLibraryEntry<CustomWorldProfile>;
|
||||
|
||||
export type PlatformPublicWorkDetailOpenStrategy =
|
||||
| {
|
||||
type: 'use-entry';
|
||||
@@ -77,7 +85,7 @@ export type PlatformPublicWorkDetailOpenStrategy =
|
||||
}
|
||||
| {
|
||||
type: 'load-rpg-detail';
|
||||
entry: CustomWorldGalleryCard;
|
||||
entry: PlatformRpgPublicWorkDetailEntry;
|
||||
};
|
||||
|
||||
export type PlatformPublicWorkActionMode = 'edit' | 'remix';
|
||||
@@ -122,6 +130,59 @@ export type PlatformPublicWorkRemixIntent =
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type PlatformPublicWorkEditIntent =
|
||||
| {
|
||||
type: 'blocked';
|
||||
errorMessage: string;
|
||||
}
|
||||
| {
|
||||
type: 'edit-big-fish';
|
||||
work: BigFishWorkSummary;
|
||||
}
|
||||
| {
|
||||
type: 'edit-puzzle';
|
||||
work: PuzzleWorkSummary;
|
||||
}
|
||||
| {
|
||||
type: 'edit-match3d';
|
||||
work: Match3DWorkSummary;
|
||||
forceDraft: true;
|
||||
}
|
||||
| {
|
||||
type: 'edit-square-hole';
|
||||
work: SquareHoleWorkSummary;
|
||||
forceDraft: true;
|
||||
}
|
||||
| {
|
||||
type: 'edit-visual-novel';
|
||||
work: VisualNovelWorkSummary;
|
||||
forceDraft: true;
|
||||
}
|
||||
| {
|
||||
type: 'resolve-edutainment-draft';
|
||||
entry: PlatformPublicGalleryCard;
|
||||
}
|
||||
| {
|
||||
type: 'edit-bark-battle';
|
||||
work: BarkBattleWorkSummary;
|
||||
forceDraft: true;
|
||||
}
|
||||
| {
|
||||
type: 'edit-rpg-gallery';
|
||||
entry: CustomWorldLibraryEntry<CustomWorldProfile>;
|
||||
};
|
||||
|
||||
export type PlatformPublicWorkEditIntentDeps = {
|
||||
selectedPuzzleDetail?: PuzzleWorkSummary | null;
|
||||
selectedRpgDetailEntry?: PlatformRpgPublicWorkDetailEntry | null;
|
||||
visualNovelWorks?: readonly VisualNovelWorkSummary[];
|
||||
barkBattleGalleryEntries?: readonly BarkBattleWorkSummary[];
|
||||
barkBattleWorks?: readonly BarkBattleWorkSummary[];
|
||||
mapMatch3DWork: (
|
||||
entry: PlatformPublicGalleryCard,
|
||||
) => Match3DWorkSummary | null;
|
||||
};
|
||||
|
||||
export type PlatformPublicWorkStartIntent =
|
||||
| {
|
||||
type: 'blocked';
|
||||
@@ -175,12 +236,12 @@ export type PlatformPublicWorkStartIntent =
|
||||
}
|
||||
| {
|
||||
type: 'record-rpg-gallery-play';
|
||||
entry: CustomWorldGalleryCard;
|
||||
entry: PlatformRpgPublicWorkDetailEntry;
|
||||
};
|
||||
|
||||
export type PlatformPublicWorkStartIntentDeps = {
|
||||
selectedPuzzleDetail?: PuzzleWorkSummary | null;
|
||||
selectedRpgDetailEntry?: CustomWorldGalleryCard | null;
|
||||
selectedRpgDetailEntry?: PlatformRpgPublicWorkDetailEntry | null;
|
||||
barkBattleGalleryEntries?: readonly BarkBattleWorkSummary[];
|
||||
barkBattleWorks?: readonly BarkBattleWorkSummary[];
|
||||
mapMatch3DWork: (
|
||||
@@ -213,21 +274,27 @@ export type PlatformPublicWorkDetailOpenDecisionDeps = {
|
||||
export type ActivePlatformPublicWorkAuthorEntryInput = {
|
||||
selectionStage: string;
|
||||
selectedPublicWorkDetail: PlatformPublicGalleryCard | null;
|
||||
selectedRpgDetailEntry: CustomWorldGalleryCard | null;
|
||||
selectedRpgDetailEntry: PlatformRpgPublicWorkDetailEntry | null;
|
||||
};
|
||||
|
||||
export function isRpgPublicWorkDetailEntry(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
): entry is CustomWorldGalleryCard {
|
||||
): entry is PlatformRpgPublicWorkDetailEntry {
|
||||
return !('sourceType' in entry);
|
||||
}
|
||||
|
||||
export function mapRpgGalleryCardToPublicWorkDetail(
|
||||
entry: CustomWorldGalleryCard,
|
||||
entry: PlatformRpgPublicWorkDetailEntry,
|
||||
): PlatformPublicGalleryCard {
|
||||
return entry;
|
||||
}
|
||||
|
||||
function isRpgPublicWorkLibraryEntry(
|
||||
entry: PlatformRpgPublicWorkDetailEntry | null | undefined,
|
||||
): entry is CustomWorldLibraryEntry<CustomWorldProfile> {
|
||||
return Boolean(entry && 'profile' in entry);
|
||||
}
|
||||
|
||||
export function mapPuzzleWorkToPublicWorkDetail(
|
||||
item: PuzzleWorkSummary,
|
||||
): PlatformPublicGalleryCard {
|
||||
@@ -689,6 +756,154 @@ export function resolvePlatformPublicWorkRemixIntent(
|
||||
};
|
||||
}
|
||||
|
||||
export function resolvePlatformPublicWorkEditIntent(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
deps: PlatformPublicWorkEditIntentDeps,
|
||||
): PlatformPublicWorkEditIntent {
|
||||
if (isBigFishGalleryEntry(entry)) {
|
||||
const work = mapPublicWorkDetailToBigFishWork(entry);
|
||||
if (!work?.sourceSessionId?.trim()) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份大鱼吃小鱼作品缺少原草稿会话,暂时无法编辑。',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'edit-big-fish',
|
||||
work,
|
||||
};
|
||||
}
|
||||
|
||||
if (isPuzzleGalleryEntry(entry)) {
|
||||
const work =
|
||||
deps.selectedPuzzleDetail?.profileId === entry.profileId
|
||||
? deps.selectedPuzzleDetail
|
||||
: mapPublicWorkDetailToPuzzleWork(entry);
|
||||
if (!work?.sourceSessionId?.trim()) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份拼图作品缺少原草稿会话,暂时无法编辑。',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'edit-puzzle',
|
||||
work,
|
||||
};
|
||||
}
|
||||
|
||||
if (isMatch3DGalleryEntry(entry)) {
|
||||
// 中文注释:抓大鹅草稿恢复仍复用 Match3D Module 的 public detail -> work Adapter。
|
||||
const work = deps.mapMatch3DWork(entry);
|
||||
if (!work?.sourceSessionId?.trim()) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份抓大鹅作品缺少原草稿会话,暂时无法编辑。',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'edit-match3d',
|
||||
work,
|
||||
forceDraft: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (isSquareHoleGalleryEntry(entry)) {
|
||||
const work = mapPublicWorkDetailToSquareHoleWork(entry);
|
||||
if (!work?.sourceSessionId?.trim()) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份方洞挑战作品缺少原草稿会话,暂时无法编辑。',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'edit-square-hole',
|
||||
work,
|
||||
forceDraft: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (isJumpHopGalleryEntry(entry)) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份跳一跳作品暂时请从作品架编辑。',
|
||||
};
|
||||
}
|
||||
|
||||
if (isWoodenFishGalleryEntry(entry)) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份敲木鱼作品暂时请从作品架编辑。',
|
||||
};
|
||||
}
|
||||
|
||||
if (isVisualNovelGalleryEntry(entry)) {
|
||||
const work =
|
||||
deps.visualNovelWorks?.find((item) => item.profileId === entry.profileId) ??
|
||||
null;
|
||||
if (!work) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份视觉小说缺少可编辑草稿。',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'edit-visual-novel',
|
||||
work,
|
||||
forceDraft: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (isEdutainmentGalleryEntry(entry)) {
|
||||
return {
|
||||
type: 'resolve-edutainment-draft',
|
||||
entry,
|
||||
};
|
||||
}
|
||||
|
||||
if (isBarkBattleGalleryEntry(entry)) {
|
||||
const work =
|
||||
deps.barkBattleWorks?.find((item) => item.workId === entry.workId) ??
|
||||
deps.barkBattleGalleryEntries?.find(
|
||||
(item) => item.workId === entry.workId,
|
||||
) ??
|
||||
mapBarkBattlePublicDetailToWorkSummary(entry);
|
||||
if (!work?.draftId?.trim()) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '这份汪汪声浪缺少可编辑草稿。',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'edit-bark-battle',
|
||||
work,
|
||||
forceDraft: true,
|
||||
};
|
||||
}
|
||||
|
||||
const editEntry =
|
||||
deps.selectedRpgDetailEntry?.profileId === entry.profileId &&
|
||||
isRpgPublicWorkLibraryEntry(deps.selectedRpgDetailEntry)
|
||||
? deps.selectedRpgDetailEntry
|
||||
: null;
|
||||
if (!editEntry) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
errorMessage: '作品详情尚未读取完成。',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'edit-rpg-gallery',
|
||||
entry: editEntry,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolvePlatformPublicWorkStartIntent(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
deps: PlatformPublicWorkStartIntentDeps,
|
||||
|
||||
Reference in New Issue
Block a user