refactor: 收口作品架删除确认模型

This commit is contained in:
2026-06-04 01:35:11 +08:00
parent 7301043afb
commit 75593b8860
7 changed files with 738 additions and 97 deletions

View File

@@ -412,6 +412,7 @@ import {
hasPuzzleRuntimeUrlStateValue,
normalizeCreationUrlValue,
} from './platformCreationUrlStateModel';
import { resolvePlatformCreationWorkDeleteConfirmationModel } from './platformCreationWorkDeleteFlow';
import {
buildPlatformErrorDialogDismissKey,
buildPlatformTaskCompletionDialogDismissKey,
@@ -10212,12 +10213,16 @@ export function PlatformEntryFlowShellImpl({
return;
}
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'rpg-library',
entry,
});
requestDeleteCreationWork({
id: entry.profileId,
title: entry.worldName,
detail: '删除后会从你的作品列表和公开广场中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(entry.profileId);
setDeletingCreationWorkId(deleteModel.id);
platformBootstrap.setPlatformError(null);
void deleteRpgEntryWorldProfile(entry.profileId)
@@ -10245,21 +10250,17 @@ export function PlatformEntryFlowShellImpl({
if (deletingCreationWorkId) {
return;
}
const noticeKeys = collectDraftNoticeKeys('rpg', [
work.workId,
work.sessionId,
work.profileId,
]);
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'rpg',
work,
});
requestDeleteCreationWork({
id: work.workId,
title: work.title,
detail:
work.status === 'published'
? '删除后会从你的作品列表和公开广场中移除。'
: '删除后会从你的作品列表中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(work.workId);
setDeletingCreationWorkId(deleteModel.id);
platformBootstrap.setPlatformError(null);
const deleteTask =
@@ -10282,7 +10283,7 @@ export function PlatformEntryFlowShellImpl({
void deleteTask
.then(async () => {
markDraftNoticeSeen(noticeKeys);
markDraftNoticeSeen(deleteModel.noticeKeys);
await platformBootstrap.refreshPublishedGallery().catch(() => []);
})
.catch((error) => {
@@ -10309,25 +10310,22 @@ export function PlatformEntryFlowShellImpl({
if (deletingCreationWorkId) {
return;
}
const noticeKeys = collectDraftNoticeKeys('big-fish', [
work.workId,
work.sourceSessionId,
]);
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'big-fish',
work,
});
requestDeleteCreationWork({
id: work.workId,
title: work.title,
detail:
work.status === 'published'
? '删除后会从你的作品列表和公开广场中移除。'
: '删除后会从你的作品列表中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(work.workId);
setDeletingCreationWorkId(deleteModel.id);
setBigFishError(null);
void deleteBigFishWork(work.sourceSessionId)
.then(async (response) => {
markDraftNoticeSeen(noticeKeys);
markDraftNoticeSeen(deleteModel.noticeKeys);
setBigFishWorks(response.items);
await refreshBigFishGallery().catch(() => []);
})
@@ -10357,31 +10355,22 @@ export function PlatformEntryFlowShellImpl({
if (deletingCreationWorkId) {
return;
}
const noticeKeys = collectDraftNoticeKeys('puzzle', [
work.workId,
work.profileId,
work.sourceSessionId,
buildPuzzleResultWorkId(work.sourceSessionId),
buildPuzzleResultProfileId(work.sourceSessionId),
]);
const displayName =
work.workTitle?.trim() || work.levelName.trim() || '未命名拼图';
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'puzzle',
work,
});
requestDeleteCreationWork({
id: work.workId,
title: displayName,
detail:
work.publicationStatus === 'published'
? '删除后会从你的作品列表和公开广场中移除。'
: '删除后会从你的作品列表中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(work.workId);
setDeletingCreationWorkId(deleteModel.id);
setPuzzleFormDraftPayload(null);
setPuzzleError(null);
void deletePuzzleWork(work.profileId)
.then((response) => {
markDraftNoticeSeen(noticeKeys);
markDraftNoticeSeen(deleteModel.noticeKeys);
setPuzzleWorks(response.items);
void refreshPuzzleGallery();
})
@@ -10411,27 +10400,23 @@ export function PlatformEntryFlowShellImpl({
if (deletingCreationWorkId) {
return;
}
const noticeKeys = collectDraftNoticeKeys('match3d', [
work.workId,
work.profileId,
work.sourceSessionId,
]);
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'match3d',
work,
});
requestDeleteCreationWork({
id: work.workId,
title: work.gameName,
detail:
work.publicationStatus === 'published'
? '删除后会从你的作品列表和公开广场中移除。'
: '删除后会从你的作品列表中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(work.workId);
setDeletingCreationWorkId(deleteModel.id);
setMatch3DFormDraftPayload(null);
setMatch3DError(null);
void deleteMatch3DWork(work.profileId)
.then((response) => {
markDraftNoticeSeen(noticeKeys);
markDraftNoticeSeen(deleteModel.noticeKeys);
setMatch3DWorks(mapMatch3DWorksForRuntimeUi(response.items));
void refreshMatch3DGallery();
})
@@ -10462,26 +10447,22 @@ export function PlatformEntryFlowShellImpl({
if (deletingCreationWorkId) {
return;
}
const noticeKeys = collectDraftNoticeKeys('square-hole', [
work.workId,
work.profileId,
work.sourceSessionId,
]);
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'square-hole',
work,
});
requestDeleteCreationWork({
id: work.workId,
title: work.gameName,
detail:
work.publicationStatus === 'published'
? '删除后会从你的作品列表和公开广场中移除。'
: '删除后会从你的作品列表中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(work.workId);
setDeletingCreationWorkId(deleteModel.id);
setSquareHoleError(null);
void deleteSquareHoleWork(work.profileId)
.then((response) => {
markDraftNoticeSeen(noticeKeys);
markDraftNoticeSeen(deleteModel.noticeKeys);
setSquareHoleWorks(response.items);
void refreshSquareHoleGallery();
})
@@ -10511,24 +10492,22 @@ export function PlatformEntryFlowShellImpl({
if (deletingCreationWorkId) {
return;
}
const noticeKeys = collectDraftNoticeKeys('visual-novel', [
work.profileId,
]);
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'visual-novel',
work,
});
requestDeleteCreationWork({
id: work.profileId,
title: work.title || '未命名视觉小说',
detail:
work.publishStatus === 'published'
? '删除后会从你的作品列表和公开广场中移除。'
: '删除后会从你的作品列表中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(work.profileId);
setDeletingCreationWorkId(deleteModel.id);
setVisualNovelError(null);
void deleteVisualNovelWork(work.profileId)
.then(async (response) => {
markDraftNoticeSeen(noticeKeys);
markDraftNoticeSeen(deleteModel.noticeKeys);
setVisualNovelWorks(response.works);
await refreshVisualNovelGallery();
})
@@ -10558,26 +10537,22 @@ export function PlatformEntryFlowShellImpl({
if (deletingCreationWorkId) {
return;
}
const noticeKeys = collectDraftNoticeKeys('baby-object-match', [
work.profileId,
work.draftId,
]);
const displayName = work.workTitle.trim() || work.templateName;
const deleteModel = resolvePlatformCreationWorkDeleteConfirmationModel({
kind: 'baby-object-match',
work,
});
requestDeleteCreationWork({
id: work.profileId,
title: displayName,
detail:
work.publicationStatus === 'published'
? '删除后会从你的作品列表和寓教于乐板块中移除。'
: '删除后会从你的作品列表中移除。',
id: deleteModel.id,
title: deleteModel.title,
detail: deleteModel.detail,
run: () => {
setDeletingCreationWorkId(work.profileId);
setDeletingCreationWorkId(deleteModel.id);
setBabyObjectMatchError(null);
void deleteLocalBabyObjectMatchDraft(work.profileId)
.then((nextDrafts) => {
markDraftNoticeSeen(noticeKeys);
markDraftNoticeSeen(deleteModel.noticeKeys);
setBabyObjectMatchDrafts(nextDrafts);
setBabyObjectMatchDraft((current) =>
current?.profileId === work.profileId ? null : current,