feat(short-drama-agent-front): 完善视觉资产审核流程

This commit is contained in:
GJ committed 2026-11-04 14:09:21 +08:00
1 parent dc8bb17a23
commit b88ad8770f
45 files changed
+2258 -352

No files matched your search

@@ -1,3 +1,4 @@
import { ApiError } from '../../lib/http'
import { imageValidationPassed } from '../subject-images/validation'
import type { ImageGenerationSubmission } from '../subject-images/generation-preview'
import { computed, ref, shallowRef, watch } from 'vue'
@@ -271,9 +272,18 @@ export function useSubjectIdentity() {
*/
async function validateImage(imageId: string) {
const image = images.value.find(item => item.id === imageId)
if (detailBlocked.value || !subject.value || image?.status !== 'completed' || !image.imageUrl) return
if (
detailBlocked.value ||
!subject.value ||
image?.viewType !== 'primary' ||
image.status !== 'completed' ||
!image.imageUrl
)
return
const id = subject.value.id
const name = subject.value.name
const project = projectId.value
const module = subject.value.module
delete validationResults.value[id]
const sourceKey = validationSourceKey.value
await runImageOperation(
@@ -284,12 +294,20 @@ export function useSubjectIdentity() {
const result = await subjectIdentityApi.validateImage(id, imageId)
if (result.subjectId !== id || result.imageId !== imageId)
throw new Error('身份校验回执与提交目标不匹配')
if (validationSourceKey.value === sourceKey) validationResults.value[id] = result
if (validationSourceKey.value === sourceKey) {
await refreshImageConfirmation(project, id)
if (
projectId.value === project &&
selectedId.value === id &&
images.value.some(item => item.id === imageId && item.imageUrl === image.imageUrl)
)
validationResults.value[id] = result
}
return result
},
result => ({
type: imageValidationPassed(result) ? 'success' : 'warning',
content: `${name} 的身份图片校验${imageValidationPassed(result) ? '通过' : '未通过或待复核'}:${result.summary}`
type: imageValidationPassed(result, module) ? 'success' : 'warning',
content: `${name} 的身份图片校验${imageValidationPassed(result, module) ? '通过' : '未通过或待复核'}:${result.summary}`
})
)
}
@@ -520,7 +538,7 @@ export function useSubjectIdentity() {
image.identityId !== identityId ||
!['pending', 'generating'].includes(image.status)
) {
throw new Error(image?.error || '身份参考图任务未成功创建,请刷新后重试。')
throw new ApiError('身份参考图任务回执待核对,请刷新候选和任务。', 202)
}
if (projectId.value === project && selectedId.value === id) {
// 先展示真实回执中的生成记录,后续读取失败也能保留状态并继续轮询。
@@ -555,7 +573,7 @@ export function useSubjectIdentity() {
async () => {
const image = await subjectIdentityApi.generateCastingCandidate(id, input)
if (!image || image.identityId !== identityId || !['pending', 'generating'].includes(image.status)) {
throw new Error(image?.error || '选角候选任务未成功创建,请刷新后重试。')
throw new ApiError('角色候选任务回执待核对,请刷新候选和任务。', 202)
}
if (projectId.value === project)
await Promise.all([
@@ -612,14 +630,16 @@ export function useSubjectIdentity() {
(subject.value?.module !== 'scene' && subject.value?.module !== 'prop') ||
!identity.value ||
!image ||
!canBeAnchor(image)
!canBeAnchor(image) ||
validationResult.value?.imageId !== imageId ||
!imageValidationPassed(validationResult.value, subject.value.module)
)
return
const subjectId = subject.value.id
const identityId = identity.value.id
const project = projectId.value
const name = subject.value.name
await runImageOperation(
const confirmed = await runImageOperation(
'confirm',
imageId,
`确认 ${name} 身份母版`,
@@ -641,6 +661,10 @@ export function useSubjectIdentity() {
},
{ type: 'success', content: `${name} 的身份母版已确认并锁定。` }
)
if (!confirmed) {
delete validationResults.value[subjectId]
await refreshImageConfirmation(project, subjectId)
}
}
/**
@@ -656,14 +680,16 @@ export function useSubjectIdentity() {
!!castingQuery.error.value ||
!identity.value ||
!image ||
!canBeAnchor(image)
!canBeAnchor(image) ||
validationResult.value?.imageId !== imageId ||
!imageValidationPassed(validationResult.value, subject.value.module)
)
return
const subjectId = subject.value.id
const identityId = identity.value.id
const project = projectId.value
const name = subject.value.name
await runImageOperation(
const confirmed = await runImageOperation(
'confirm',
imageId,
`确认 ${name} 角色选角`,
@@ -685,6 +711,10 @@ export function useSubjectIdentity() {
},
{ type: 'success', content: `${name} 的角色选角已确认,身份已锁定。` }
)
if (!confirmed) {
delete validationResults.value[subjectId]
await refreshImageConfirmation(project, subjectId)
}
}
return {