feat(short-drama-agent-front): 接入素材预览审核并完善创作流程
This commit is contained in:
1 parent
f8b0fbb8ca
commit
dc8bb17a23
66 files changed
+2864
-632
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import { imageValidationPassed } from '../subject-images/validation'
|
||||
import type { ImageGenerationSubmission } from '../subject-images/generation-preview'
|
||||
import { computed, ref, shallowRef, watch } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { visualStyleApi } from '../visual-style'
|
||||
@@ -5,7 +7,7 @@ import { useProjectGenerationRevision } from '../generation-config/context'
|
||||
import { generationConfigApi } from '../generation-config/api'
|
||||
import { subjectImagesApi } from '../subject-images/api'
|
||||
import { hasRunningImages } from '../subject-images/model'
|
||||
import { batchResultNotice, runOperation, type OperationNotice } from '../workflows/operations'
|
||||
import { batchResultNotice, getOperation, runOperation, type OperationNotice } from '../workflows/operations'
|
||||
import { useProjectMutationGuard } from '../workflows/useProjectMutationGuard'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { subjectIdentityApi } from './api'
|
||||
@@ -207,6 +209,18 @@ export function useSubjectIdentity() {
|
||||
const validationResults = ref<Record<string, IdentityValidationResult>>({})
|
||||
/** 质量闭环结果以正式主体 ID 保存。 */
|
||||
const qualityResults = ref<Record<string, StableAnchorQualityResult>>({})
|
||||
/** 审核只适用于本次主体、身份版本和图片输入。 */
|
||||
const validationSourceKey = computed(() =>
|
||||
JSON.stringify([projectId.value, selectedId.value, identity.value, images.value])
|
||||
)
|
||||
/** 来源变化或切换主体后清除旧审核展示,不能沿用历史通过。 */
|
||||
watch(
|
||||
validationSourceKey,
|
||||
() => {
|
||||
delete validationResults.value[selectedId.value]
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 当前主体的指定图片校验结果。 */
|
||||
const validationResult = computed(() => validationResults.value[selectedId.value] ?? null)
|
||||
/** 当前主体的质量闭环回执。 */
|
||||
@@ -261,6 +275,7 @@ export function useSubjectIdentity() {
|
||||
const id = subject.value.id
|
||||
const name = subject.value.name
|
||||
delete validationResults.value[id]
|
||||
const sourceKey = validationSourceKey.value
|
||||
await runImageOperation(
|
||||
'validate',
|
||||
imageId,
|
||||
@@ -269,12 +284,12 @@ export function useSubjectIdentity() {
|
||||
const result = await subjectIdentityApi.validateImage(id, imageId)
|
||||
if (result.subjectId !== id || result.imageId !== imageId)
|
||||
throw new Error('身份校验回执与提交目标不匹配')
|
||||
validationResults.value[id] = result
|
||||
if (validationSourceKey.value === sourceKey) validationResults.value[id] = result
|
||||
return result
|
||||
},
|
||||
result => ({
|
||||
type: result.passed ? 'success' : 'warning',
|
||||
content: `${name} 的身份图片校验${result.passed ? '通过' : '未通过'}:${result.summary}`
|
||||
type: imageValidationPassed(result) ? 'success' : 'warning',
|
||||
content: `${name} 的身份图片校验${imageValidationPassed(result) ? '通过' : '未通过或待复核'}:${result.summary}`
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -478,26 +493,25 @@ export function useSubjectIdentity() {
|
||||
/**
|
||||
* 生图不修改文字锁定;即使有自定义提示词,也需已有身份提示词与项目风格。
|
||||
* @param input 已确认的视图、模型与参考图片参数
|
||||
* @param onSubmitStarted 通过前置检查并开始提交时的回调
|
||||
* @returns 任务创建结果及原始错误
|
||||
*/
|
||||
async function generateImage(input: GenerateIdentityImageInput, onSubmitStarted?: () => void) {
|
||||
if (!canGenerateImage.value || !subject.value || !identity.value) return
|
||||
async function generateImage(input: GenerateIdentityImageInput): Promise<ImageGenerationSubmission> {
|
||||
if (!canGenerateImage.value || !subject.value || !identity.value) return { accepted: false }
|
||||
if (
|
||||
input.referenceImageId &&
|
||||
!images.value.some(
|
||||
image => image.id === input.referenceImageId && image.status === 'completed' && image.imageUrl
|
||||
)
|
||||
)
|
||||
return
|
||||
return { accepted: false }
|
||||
const id = subject.value.id
|
||||
const identityId = identity.value.id
|
||||
const project = projectId.value
|
||||
const name = subject.value.name
|
||||
await runOperation(
|
||||
const accepted = await runOperation(
|
||||
project,
|
||||
`提交 ${name} 身份参考图生成`,
|
||||
async () => {
|
||||
onSubmitStarted?.()
|
||||
const started = await subjectIdentityApi.generateImage(id, input)
|
||||
const image = started?.image
|
||||
if (
|
||||
@@ -521,24 +535,24 @@ export function useSubjectIdentity() {
|
||||
},
|
||||
{ type: 'info', content: `${name} 的身份参考图已提交生成,完成后会显示结果。` }
|
||||
)
|
||||
return { accepted, cause: getOperation(project).cause }
|
||||
}
|
||||
|
||||
/**
|
||||
* 单角色候选图固定独立生成,不复用旧母版,生成成功后仍需人工确认选角。
|
||||
* @param input 已确认的候选图模型与生成参数
|
||||
* @param onSubmitStarted 通过前置检查并开始提交时的回调
|
||||
* @returns 任务创建结果及原始错误
|
||||
*/
|
||||
async function generateCastingCandidate(input: GenerateCastingCandidateInput, onSubmitStarted?: () => void) {
|
||||
if (!canGenerateCandidate.value || !subject.value || !identity.value) return
|
||||
async function generateCastingCandidate(input: GenerateCastingCandidateInput): Promise<ImageGenerationSubmission> {
|
||||
if (!canGenerateCandidate.value || !subject.value || !identity.value) return { accepted: false }
|
||||
const id = subject.value.id
|
||||
const identityId = identity.value.id
|
||||
const project = projectId.value
|
||||
const name = subject.value.name
|
||||
await runOperation(
|
||||
const accepted = await runOperation(
|
||||
project,
|
||||
`提交 ${name} 角色候选图生成`,
|
||||
async () => {
|
||||
onSubmitStarted?.()
|
||||
const image = await subjectIdentityApi.generateCastingCandidate(id, input)
|
||||
if (!image || image.identityId !== identityId || !['pending', 'generating'].includes(image.status)) {
|
||||
throw new Error(image?.error || '选角候选任务未成功创建,请刷新后重试。')
|
||||
@@ -552,6 +566,7 @@ export function useSubjectIdentity() {
|
||||
},
|
||||
{ type: 'info', content: `${name} 的角色候选图已提交生成,完成后会显示结果。` }
|
||||
)
|
||||
return { accepted, cause: getOperation(project).cause }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user