feat: 形态图库接入模型配置与异步回执
This commit is contained in:
1 parent
3014fa1ae6
commit
5e2221ea88
1 file changed
+19
-2
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user