fix: 支持删除图片异常批次

This commit is contained in:
hh
2026-07-15 17:52:29 +08:00
parent ff0a93677a
commit 755e210951
9 changed files with 531 additions and 51 deletions
+26 -3
View File
@@ -3,10 +3,10 @@ import type { CSSProperties } from "react";
import { api } from "../api";
import { ConfirmModal } from "../components/overlays";
import type { NavigateFn } from "./route-config";
import type { Asset, FreeVideoTask, ImageConversation, ModelEntity, Product, Project } from "../types";
import type { Asset, FreeVideoTask, ImageConversation, ImageExceptionBatchTrash, ModelEntity, Product, Project } from "../types";
import "../trash-page.css";
type TrashKind = "product" | "asset" | "model" | "image" | "freeVideo" | "project";
type TrashKind = "product" | "asset" | "model" | "image" | "imageExceptionBatch" | "freeVideo" | "project";
type TrashRow = {
id: string;
@@ -81,6 +81,21 @@ const rowsFromConversations = (items: ImageConversation[]): TrashRow[] =>
subtitle: `${c.task_count || 0} 个生成任务${dateOf(c.updated_at) ? ` · 删除于 ${dateOf(c.updated_at)}` : ""}`
}));
const IMAGE_MODE_LABEL: Record<ImageExceptionBatchTrash["mode"], string> = {
image: "图片创作",
model: "模特上身图",
cover: "平台套图"
};
const rowsFromImageExceptionBatches = (items: ImageExceptionBatchTrash[]): TrashRow[] =>
items.map((batch) => ({
id: batch.id,
kind: "imageExceptionBatch",
title: batch.prompt || batch.product_title || "未命名图片生成",
subtitle: `${IMAGE_MODE_LABEL[batch.mode]} · ${batch.count}${dateOf(batch.updated_at) ? ` · 删除于 ${dateOf(batch.updated_at)}` : ""}`,
cover: batch.cover_preview_url || ""
}));
const rowsFromFreeVideos = (items: FreeVideoTask[]): TrashRow[] =>
items.map((task) => ({
id: task.id,
@@ -125,9 +140,10 @@ export function TrashPage({ onRestore, onPurge, onRestoreProducts, onPurgeProduc
api.assetsTrash(),
api.modelsTrash(),
api.conversationsTrash("image"),
api.imageExceptionBatchesTrash(),
api.freeVideoTrash(0, 100),
api.projectsTrash()
]).then(([products, assets, models, conversations, freeVideos, projects]) => {
]).then(([products, assets, models, conversations, imageExceptionBatches, freeVideos, projects]) => {
if (!alive) return;
const rawSections: TrashSection[] = [
{
@@ -150,6 +166,11 @@ export function TrashPage({ onRestore, onPurge, onRestoreProducts, onPurgeProduc
title: "自由创作图片",
rows: conversations.status === "fulfilled" ? rowsFromConversations(conversations.value.results) : []
},
{
key: "imageExceptionBatch",
title: "图片异常批次",
rows: imageExceptionBatches.status === "fulfilled" ? rowsFromImageExceptionBatches(imageExceptionBatches.value.results) : []
},
{
key: "freeVideo",
title: "自由创作视频",
@@ -185,6 +206,7 @@ export function TrashPage({ onRestore, onPurge, onRestoreProducts, onPurgeProduc
if (row.kind === "asset") return api.restoreAsset(row.id);
if (row.kind === "model") return api.restoreModel(row.id);
if (row.kind === "image") return api.restoreConversation(row.id);
if (row.kind === "imageExceptionBatch") return api.restoreWorkbenchImageBatch(row.id);
if (row.kind === "freeVideo") return api.restoreFreeVideo(row.id);
return api.restoreProject(row.id);
}
@@ -194,6 +216,7 @@ export function TrashPage({ onRestore, onPurge, onRestoreProducts, onPurgeProduc
if (row.kind === "asset") return api.purgeAsset(row.id);
if (row.kind === "model") return api.purgeModel(row.id);
if (row.kind === "image") return api.purgeConversation(row.id);
if (row.kind === "imageExceptionBatch") return api.purgeWorkbenchImageBatch(row.id);
if (row.kind === "freeVideo") return api.purgeFreeVideo(row.id);
return api.purgeProject(row.id);
}