From 0a519ca892d30fb68fd6753975df9ccf3ad9204a Mon Sep 17 00:00:00 2001 From: zyc <1439655764@qq.com> Date: Sat, 27 Jun 2026 11:04:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E5=8F=AA=E5=B1=95=E7=A4=BA=E7=94=9F=E5=9B=BE=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?(=E6=A8=A1=E7=89=B9=E4=B8=8A=E8=BA=AB=E5=9B=BE/=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=A5=97=E5=9B=BE/=E5=9B=BE=E7=89=87=E5=88=9B?= =?UTF-8?q?=E4=BD=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AITaskViewSet 支持 ?task_type=a,b,c 过滤 - 前端任务中心请求 task_type=person_image,product_image,过滤掉 entity_extraction/script_*/storyboard 等流水线内部任务,只留生图工作室产出 Co-Authored-By: Claude Opus 4.8 --- core/backend/apps/ai/views.py | 11 +++++++++++ core/frontend/src/api.ts | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/backend/apps/ai/views.py b/core/backend/apps/ai/views.py index 5136dda..61fa203 100644 --- a/core/backend/apps/ai/views.py +++ b/core/backend/apps/ai/views.py @@ -78,6 +78,17 @@ class AITaskViewSet(TeamScopedViewSetMixin, ReadOnlyModelViewSet): search_fields = ["idempotency_key", "provider_task_id", "project__name"] ordering_fields = ["created_at", "updated_at", "completed_at"] + def get_queryset(self): + # 可选 ?task_type=a,b,c 过滤:生图工作室的任务中心只想看生图任务(模特上身图/平台套图/ + # 图片创作 = person_image / product_image),不掺脚本/实体抽取/故事板等流水线内部任务。 + queryset = super().get_queryset() + raw = self.request.query_params.get("task_type", "").strip() + if raw: + types = [t.strip() for t in raw.split(",") if t.strip()] + if types: + queryset = queryset.filter(task_type__in=types) + return queryset + class ModelConfigViewSet(ReadOnlyModelViewSet): # 按创建序固定排序:最早创建的 active 模型排第一 = 前端选择器默认项,与 get_default_model 口径一致 diff --git a/core/frontend/src/api.ts b/core/frontend/src/api.ts index e388c9f..219925a 100644 --- a/core/frontend/src/api.ts +++ b/core/frontend/src/api.ts @@ -580,9 +580,10 @@ export const api = { return request>("/api/ai/models/"); }, aiTasks() { - // 取一大页(后端上限 200):任务中心要按真实总量算 全部/已完成/失败 三个 tab 数, - // 只取默认首页(20 条)会把统计算偏,甚至误显示「全部失败」。 - return request>("/api/ai/tasks/?page_size=200"); + // 生图工作室的任务中心:只看生图任务(模特上身图/平台套图/图片创作 = person_image / + // product_image),不掺脚本/实体抽取/故事板等流水线内部任务。取一大页(后端上限 200) + // 以便 全部/已完成/失败 三个 tab 数按真实总量算。 + return request>("/api/ai/tasks/?page_size=200&task_type=person_image,product_image"); }, // 异步生图:提交后秒级返回任务列表(慢出图在 worker 跑),再用 generateImageStatus 轮询取结果 submitGenerateImage(payload: { prompt: string; mode?: "image" | "model" | "cover"; count?: number; product_id?: string; reference_product?: boolean; model_id?: string; model_entity_id?: string; ratio?: string; image_model?: string }) {