This commit is contained in:
2026-04-24 17:59:48 +08:00
parent 929febb4fe
commit 6cb3efae61
55 changed files with 2373 additions and 435 deletions

View File

@@ -1,4 +1,4 @@
import { AnimatePresence, motion } from 'motion/react';
import { AnimatePresence, motion } from 'motion/react';
import {
lazy,
Suspense,
@@ -43,7 +43,10 @@ import {
getBigFishCreationSession,
streamBigFishCreationMessage,
} from '../../services/big-fish-creation';
import { listBigFishWorks } from '../../services/big-fish-works';
import {
deleteBigFishWork,
listBigFishWorks,
} from '../../services/big-fish-works';
import {
startBigFishRuntimeRun,
submitBigFishRuntimeInput,
@@ -63,9 +66,10 @@ import {
startPuzzleRun,
swapPuzzlePieces,
} from '../../services/puzzle-runtime';
import { listPuzzleWorks } from '../../services/puzzle-works';
import { deletePuzzleWork, listPuzzleWorks } from '../../services/puzzle-works';
import { deleteRpgEntryWorldProfile } from '../../services/rpg-entry';
import { getRpgEntryWorldGalleryDetailByCode } from '../../services/rpg-entry/rpgEntryLibraryClient';
import { deleteRpgCreationAgentSession } from '../../services/rpg-creation';
import { rpgCreationPreviewAdapter } from '../../services/rpg-creation/rpgCreationPreviewAdapter';
import type { CustomWorldProfile } from '../../types';
import { useAuthUi } from '../auth/AuthUiContext';
@@ -1254,7 +1258,7 @@ export function PlatformEntryFlowShellImpl({
const handleDeletePublishedWork = useCallback(
(work: (typeof creationHubItems)[number]) => {
if (!work.profileId || deletingCreationWorkId) {
if (deletingCreationWorkId) {
return;
}
@@ -1265,18 +1269,22 @@ export function PlatformEntryFlowShellImpl({
if (!confirmed) {
return;
}
if (!work.profileId) {
platformBootstrap.setPlatformError('当前作品缺少 profileId暂时无法删除。');
return;
}
setDeletingCreationWorkId(work.workId);
platformBootstrap.setPlatformError(null);
void deleteRpgEntryWorldProfile(work.profileId)
.then(async (entries) => {
platformBootstrap.setSavedCustomWorldEntries(entries);
await platformBootstrap.refreshCustomWorldWorks().catch(() => []);
const deleteTask = work.profileId
? deleteRpgEntryWorldProfile(work.profileId).then(async (entries) => {
platformBootstrap.setSavedCustomWorldEntries(entries);
await platformBootstrap.refreshCustomWorldWorks().catch(() => []);
})
: work.sessionId
? deleteRpgCreationAgentSession(work.sessionId).then((items) => {
platformBootstrap.setCustomWorldWorkEntries(items);
})
: Promise.reject(new Error('当前 RPG 作品缺少可删除 ID。'));
void deleteTask
.then(async () => {
await platformBootstrap.refreshPublishedGallery().catch(() => []);
})
.catch((error) => {
@@ -1292,6 +1300,72 @@ export function PlatformEntryFlowShellImpl({
[deletingCreationWorkId, platformBootstrap, runProtectedAction],
);
const handleDeleteBigFishWork = useCallback(
(work: BigFishWorkSummary) => {
if (deletingCreationWorkId) {
return;
}
runProtectedAction(() => {
const confirmed = window.confirm(
`确认删除作品《${work.title}》吗?删除后会从你的作品列表中移除。`,
);
if (!confirmed) {
return;
}
setDeletingCreationWorkId(work.workId);
setBigFishError(null);
void deleteBigFishWork(work.sourceSessionId)
.then((response) => {
setBigFishWorks(response.items);
})
.catch((error) => {
setBigFishError(
resolveBigFishErrorMessage(error, '删除大鱼吃小鱼作品失败。'),
);
})
.finally(() => {
setDeletingCreationWorkId(null);
});
});
},
[deletingCreationWorkId, resolveBigFishErrorMessage, runProtectedAction],
);
const handleDeletePuzzleWork = useCallback(
(work: PuzzleWorkSummary) => {
if (deletingCreationWorkId) {
return;
}
runProtectedAction(() => {
const confirmed = window.confirm(
`确认删除作品《${work.levelName}》吗?删除后会从你的作品列表和公开广场中移除。`,
);
if (!confirmed) {
return;
}
setDeletingCreationWorkId(work.workId);
setPuzzleError(null);
void deletePuzzleWork(work.profileId)
.then((response) => {
setPuzzleWorks(response.items);
})
.catch((error) => {
setPuzzleError(resolvePuzzleErrorMessage(error, '删除拼图作品失败。'));
})
.finally(() => {
setDeletingCreationWorkId(null);
});
});
},
[deletingCreationWorkId, resolvePuzzleErrorMessage, runProtectedAction],
);
const openPuzzleDetail = useCallback(
async (profileId: string) => {
setIsPuzzleBusy(true);
@@ -1520,6 +1594,9 @@ export function PlatformEntryFlowShellImpl({
void startBigFishRunFromWork(item);
});
}}
onDeleteBigFish={(item) => {
handleDeleteBigFishWork(item);
}}
puzzleItems={puzzleWorks}
onOpenPuzzleDetail={(item) => {
runProtectedAction(() => {
@@ -1535,6 +1612,9 @@ export function PlatformEntryFlowShellImpl({
void startPuzzleRunFromProfile(profileId);
});
}}
onDeletePuzzle={(item) => {
handleDeletePuzzleWork(item);
}}
/>
);
@@ -2007,6 +2087,23 @@ export function PlatformEntryFlowShellImpl({
});
});
}}
onTestWorld={() => {
runProtectedAction(() => {
void enterWorldCoordinator
.enterWorldForTestFromCurrentResult()
.catch((error) => {
sessionController.setCustomWorldError(
resolveRpgCreationErrorMessage(
error,
'进入作品测试失败。',
),
);
});
});
}}
onPublishWorld={async () => {
await enterWorldCoordinator.publishCurrentResult();
}}
onGenerateEntity={
sessionController.isAgentDraftResultView
? async (kind) => {
@@ -2061,49 +2158,6 @@ export function PlatformEntryFlowShellImpl({
}
: undefined
}
onGenerateRoleAssets={
sessionController.isAgentDraftResultView
? async (roleId) => {
const latestSession =
await autosaveCoordinator.executeAgentActionAndWait({
action: 'generate_role_assets',
roleIds: [roleId],
});
const latestProfile = latestSession
? rpgCreationPreviewAdapter.buildPreviewFromSession(
latestSession,
)
: null;
if (latestProfile) {
sessionController.setGeneratedCustomWorldProfile(
latestProfile,
);
}
}
: undefined
}
onGenerateSceneAssets={
sessionController.isAgentDraftResultView
? async (sceneId, sceneKind) => {
const latestSession =
await autosaveCoordinator.executeAgentActionAndWait({
action: 'generate_scene_assets',
sceneIds: [sceneId],
sceneKind,
});
const latestProfile = latestSession
? rpgCreationPreviewAdapter.buildPreviewFromSession(
latestSession,
)
: null;
if (latestProfile) {
sessionController.setGeneratedCustomWorldProfile(
latestProfile,
);
}
}
: undefined
}
readOnly={false}
compactAgentResultMode={
sessionController.isAgentDraftResultView