fix: 完善作品号复制与详情返回

This commit is contained in:
2026-04-26 15:19:53 +08:00
parent 874e10383b
commit 7aabbcc10c
11 changed files with 328 additions and 101 deletions

View File

@@ -101,7 +101,10 @@ import {
} from '../rpg-entry/rpgEntryWorldPresentation';
import { PlatformEntryCreationTypeModal } from './PlatformEntryCreationTypeModal';
import type { PlatformCreationTypeId } from './platformEntryCreationTypes';
import { PlatformEntryHomeView } from './PlatformEntryHomeView';
import {
PlatformEntryHomeView,
type PlatformHomeTab,
} from './PlatformEntryHomeView';
import {
buildCreationHubFallbackItems,
normalizeAgentBackedProfile,
@@ -119,6 +122,10 @@ type AgentResultPublishGateView = {
publishReady: boolean;
};
type PuzzleDetailReturnTarget = {
tab: PlatformHomeTab;
};
type AgentResultBlockerView = {
code?: string;
message: string;
@@ -363,6 +370,8 @@ export function PlatformEntryFlowShellImpl({
>([]);
const [selectedPuzzleDetail, setSelectedPuzzleDetail] =
useState<PuzzleWorkSummary | null>(null);
const [puzzleDetailReturnTarget, setPuzzleDetailReturnTarget] =
useState<PuzzleDetailReturnTarget | null>(null);
const [puzzleRun, setPuzzleRun] = useState<PuzzleRunSnapshot | null>(null);
const [isPuzzleLoadingLibrary, setIsPuzzleLoadingLibrary] = useState(false);
const [puzzleGenerationState, setPuzzleGenerationState] =
@@ -1393,14 +1402,19 @@ export function PlatformEntryFlowShellImpl({
);
const openPuzzleDetail = useCallback(
async (profileId: string) => {
async (
profileId: string,
returnTarget: PuzzleDetailReturnTarget = {
tab: platformBootstrap.platformTab,
},
) => {
setIsPuzzleBusy(true);
setPuzzleError(null);
try {
const { item } = await getPuzzleGalleryDetail(profileId);
setSelectedPuzzleDetail(item);
enterCreateTab();
setPuzzleDetailReturnTarget(returnTarget);
setSelectionStage('puzzle-gallery-detail');
} catch (error) {
setPuzzleError(resolvePuzzleErrorMessage(error, '读取拼图详情失败。'));
@@ -1408,7 +1422,11 @@ export function PlatformEntryFlowShellImpl({
setIsPuzzleBusy(false);
}
},
[enterCreateTab, resolvePuzzleErrorMessage, setSelectionStage],
[
platformBootstrap.platformTab,
resolvePuzzleErrorMessage,
setSelectionStage,
],
);
const openPuzzleDraft = useCallback(
@@ -1418,7 +1436,7 @@ export function PlatformEntryFlowShellImpl({
setSelectedPuzzleDetail(null);
if (!item.sourceSessionId?.trim()) {
if (item.publicationStatus === 'published') {
await openPuzzleDetail(item.profileId);
await openPuzzleDetail(item.profileId, { tab: 'create' });
return;
}
@@ -1495,7 +1513,9 @@ export function PlatformEntryFlowShellImpl({
throw new Error('未找到拼图作品。');
}
await openPuzzleDetail(matchedEntry.profileId);
await openPuzzleDetail(matchedEntry.profileId, {
tab: platformBootstrap.platformTab,
});
};
try {
@@ -1543,6 +1563,7 @@ export function PlatformEntryFlowShellImpl({
[
detailNavigation,
openPuzzleDetail,
platformBootstrap.platformTab,
puzzleGalleryEntries,
refreshPuzzleGallery,
],
@@ -1765,7 +1786,9 @@ export function PlatformEntryFlowShellImpl({
onOpenCreateTypePicker={openCreationTypePicker}
onOpenGalleryDetail={(entry) => {
if (isPuzzleGalleryEntry(entry)) {
void openPuzzleDetail(entry.profileId);
void openPuzzleDetail(entry.profileId, {
tab: platformBootstrap.platformTab,
});
return;
}
@@ -2150,7 +2173,10 @@ export function PlatformEntryFlowShellImpl({
isBusy={isPuzzleBusy}
error={puzzleError}
onBack={() => {
enterCreateTab();
platformBootstrap.setPlatformTab(
puzzleDetailReturnTarget?.tab ?? 'home',
);
setPuzzleDetailReturnTarget(null);
setSelectionStage('platform');
}}
onEdit={