From 5e2221ea884c0a743fc96f8cbd08f8252e98d043 Mon Sep 17 00:00:00 2001 From: GouJ Date: Fri, 25 Sep 2026 00:29:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BD=A2=E6=80=81=E5=9B=BE=E5=BA=93?= =?UTF-8?q?=E6=8E=A5=E5=85=A5=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE=E4=B8=8E?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=9B=9E=E6=89=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subject-images/useSubjectImages.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/features/subject-images/useSubjectImages.ts b/src/features/subject-images/useSubjectImages.ts index e14b97a..5e66d7d 100644 --- a/src/features/subject-images/useSubjectImages.ts +++ b/src/features/subject-images/useSubjectImages.ts @@ -4,6 +4,7 @@ import { ApiError } from '../../lib/http' import { useProjectContext } from '../projects/context' import { getOperation, runOperation } from '../workflows/operations' import { workflowCheckpoints } from '../workflows/selectors' +import { generationConfigApi } from '../generation-config/api' import { subjectImagesApi } from './api' import { getImageSession, hasRunningImages } from './model' import type { GenerateFormImageInput, SubjectModule } from './types' @@ -18,6 +19,16 @@ export function useSubjectImages() { const promptConcurrency = ref(3) const promptForce = ref(false) const batchModule = ref<'all' | SubjectModule>('all') + const generationModelsQuery = usePolling( + id, + async (_id, signal) => generationConfigApi.catalog(signal), + false + ) + const profileQuery = usePolling( + id, + async (projectId, signal) => ({ profile: await generationConfigApi.profile(projectId, signal) }), + false + ) const query = usePolling( id, async (projectId, signal) => { @@ -59,6 +70,10 @@ export function useSubjectImages() { !!context.error.value || !!query.error.value || query.data.value === null || + !!generationModelsQuery.error.value || + !generationModelsQuery.data.value || + !!profileQuery.error.value || + !profileQuery.data.value?.profile || running.value || breakdownRunning.value || context.project.value?.status !== 'completed' @@ -116,8 +131,8 @@ export function useSubjectImages() { const projectId = id.value await runOperation(projectId, `生成 ${form.subject.name} · ${form.name} 图片`, async () => { const image = await subjectImagesApi.generate(formId, input) - if (!image || image.subjectFormId !== formId || image.status !== 'completed' || !image.imageUrl) - throw new Error(image?.error || '接口未返回已完成的图片,请先刷新图片记录核对后端状态。') + if (!image || image.subjectFormId !== formId || !['pending', 'generating'].includes(image.status)) + throw new Error(image?.error || '接口未返回有效的形态图片生成任务,请刷新图片记录核对。') }) await query.refresh() } @@ -146,6 +161,8 @@ export function useSubjectImages() { return { id, forms, + generationModelsQuery, + profileQuery, query, refreshProject: context.refresh, operation,