refactor: 收口剩余草稿打开 intent

This commit is contained in:
2026-06-04 06:12:26 +08:00
parent e570d50e9f
commit c93b8fb570
6 changed files with 422 additions and 41 deletions

View File

@@ -447,8 +447,11 @@ import {
type PendingDraftShelfKind,
type PendingDraftShelfMap,
type PendingDraftShelfMetadata,
resolveBigFishDraftOpenIntent,
resolveMatch3DDraftOpenIntent,
resolvePuzzleDraftOpenIntent,
resolveSquareHoleDraftOpenIntent,
resolveVisualNovelDraftOpenIntent,
} from './platformDraftGenerationShelfModel';
import {
canExposePublicWork,
@@ -10685,42 +10688,42 @@ export function PlatformEntryFlowShellImpl({
item: SquareHoleWorkSummary,
options: { forceDraft?: boolean } = {},
) => {
const openIntent = resolveSquareHoleDraftOpenIntent({
item,
forceDraft: options.forceDraft,
activeSessionId: squareHoleSession?.sessionId,
hasActiveGenerationRunning: isMiniGameDraftGenerating(
squareHoleGenerationState,
),
isGenerationReady: isMiniGameDraftReady(squareHoleGenerationState),
});
setSquareHoleRun(null);
setSquareHoleError(null);
setSquareHoleProfile(null);
markDraftNoticeSeen(
collectDraftNoticeKeys('square-hole', [
item.workId,
item.profileId,
item.sourceSessionId,
]),
);
markDraftNoticeSeen(openIntent.noticeKeys);
if (item.publicationStatus === 'published' && !options.forceDraft) {
if (openIntent.type === 'open-published-detail') {
openPublicWorkDetail(mapSquareHoleWorkToPublicWorkDetail(item));
return;
}
if (!item.sourceSessionId?.trim()) {
setSquareHoleError('这份方洞挑战草稿缺少会话信息,请重新开始创作。');
if (openIntent.type === 'missing-session') {
setSquareHoleError(openIntent.errorMessage);
return;
}
if (
item.sourceSessionId === squareHoleSession?.sessionId &&
isMiniGameDraftGenerating(squareHoleGenerationState)
) {
if (openIntent.type === 'active-generation') {
enterCreateTab();
selectionStageRef.current = 'square-hole-generating';
setSelectionStage('square-hole-generating');
return;
}
if (!isMiniGameDraftReady(squareHoleGenerationState)) {
if (openIntent.shouldClearGenerationState) {
setSquareHoleGenerationState(null);
}
const restoredSession = await squareHoleFlow.restoreDraft(
item.sourceSessionId,
openIntent.sourceSessionId,
);
if (!restoredSession) {
await refreshSquareHoleShelf().catch(() => undefined);
@@ -10756,21 +10759,23 @@ export function PlatformEntryFlowShellImpl({
const openBigFishDraft = useCallback(
async (item: BigFishWorkSummary) => {
const openIntent = resolveBigFishDraftOpenIntent({
item,
activeSessionId: bigFishSession?.sessionId,
hasActiveGenerationRunning: isMiniGameDraftGenerating(
bigFishGenerationState,
),
});
setBigFishRun(null);
markDraftNoticeSeen(
collectDraftNoticeKeys('big-fish', [item.workId, item.sourceSessionId]),
);
if (
item.sourceSessionId === bigFishSession?.sessionId &&
isMiniGameDraftGenerating(bigFishGenerationState)
) {
markDraftNoticeSeen(openIntent.noticeKeys);
if (openIntent.type === 'active-generation') {
enterCreateTab();
selectionStageRef.current = 'big-fish-generating';
setSelectionStage('big-fish-generating');
return;
}
const restoredSession = await bigFishFlow.restoreDraft(
item.sourceSessionId,
openIntent.sourceSessionId,
);
if (!restoredSession) {
await refreshBigFishShelf().catch(() => undefined);
@@ -10823,27 +10828,27 @@ export function PlatformEntryFlowShellImpl({
item: VisualNovelWorkSummary,
options: { forceDraft?: boolean } = {},
) => {
if (item.publishStatus === 'published' && !options.forceDraft) {
const openIntent = resolveVisualNovelDraftOpenIntent({
item,
forceDraft: options.forceDraft,
activeSessionId: visualNovelSession?.sessionId,
hasActiveGenerationRunning: visualNovelGenerationPhase === 'generating',
hasActiveSessionDraft: Boolean(visualNovelSession?.draft),
});
if (openIntent.type === 'open-published-detail') {
openPublicWorkDetail(mapVisualNovelWorkToPublicWorkDetail(item));
return;
}
markDraftNoticeSeen(
collectDraftNoticeKeys('visual-novel', [item.profileId]),
);
if (
item.profileId === visualNovelSession?.sessionId &&
visualNovelGenerationPhase === 'generating'
) {
markDraftNoticeSeen(openIntent.noticeKeys);
if (openIntent.type === 'active-generation') {
enterCreateTab();
selectionStageRef.current = 'visual-novel-generating';
setSelectionStage('visual-novel-generating');
return;
}
if (
item.profileId === visualNovelSession?.sessionId &&
visualNovelSession.draft
) {
if (openIntent.type === 'current-result') {
enterCreateTab();
setSelectionStage('visual-novel-result');
return;
@@ -10856,7 +10861,7 @@ export function PlatformEntryFlowShellImpl({
setIsVisualNovelBusy(true);
try {
const { work } = await getVisualNovelWorkDetail(item.profileId);
const { work } = await getVisualNovelWorkDetail(openIntent.profileId);
setVisualNovelWork(work);
setVisualNovelSession(buildVisualNovelSessionFromWorkDetail(work));
enterCreateTab();