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
@@ -91,7 +91,8 @@ const {
|
||||
confirmCasting,
|
||||
validateImage,
|
||||
generateStableAnchorQuality,
|
||||
pendingImageOperation
|
||||
pendingImageOperation,
|
||||
validationResult
|
||||
} = useSubjectIdentity()
|
||||
/** 所有形态图片入口复用侧栏和路由的服务端阶段准入规则。 */
|
||||
const stageAccess = useProjectStageAccess(projectId, projectContext.stageReadiness)
|
||||
@@ -225,30 +226,6 @@ function exportReceipt() {
|
||||
downloadText('subject-identities-receipt.json', JSON.stringify(session.value.receipt, null, 2), 'application/json')
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置校验通过并开始提交时关闭原主体弹窗,后续状态通过消息反馈。
|
||||
* @param input 已确认的身份图生成参数
|
||||
* @returns 提交与详情刷新完成
|
||||
*/
|
||||
async function submitIdentityImage(input: Parameters<typeof generateImage>[0]) {
|
||||
const targetId = selectedId.value
|
||||
await generateImage(input, () => {
|
||||
if (selectedId.value === targetId) imageOpen.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置校验通过并开始提交时关闭原主体选角弹窗,不等待接口返回。
|
||||
* @param input 已确认的选角生成参数
|
||||
* @returns 提交与列表刷新完成
|
||||
*/
|
||||
async function submitCastingCandidate(input: Parameters<typeof generateCastingCandidate>[0]) {
|
||||
const targetId = selectedId.value
|
||||
await generateCastingCandidate(input, () => {
|
||||
if (selectedId.value === targetId) castingOpen.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 按主体类型确认母版,成功后关闭原主体的管理弹窗。
|
||||
* @param imageId 用户明确选择的图片编号
|
||||
@@ -461,8 +438,7 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
|
||||
return {
|
||||
action: 'confirm',
|
||||
title: '第 3 步:确认并锁定',
|
||||
description:
|
||||
'在下方图片卡片中确认母版;其他图片可通过“管理候选”查看。人物会同时锁定,场景和道具还需保存锁定状态。',
|
||||
description: '在下方图片卡片中核对并确认母版,质量通过后会同时锁定身份;其他图片可通过“管理候选”查看。',
|
||||
label: '查看候选并确认'
|
||||
}
|
||||
return {
|
||||
@@ -642,7 +618,7 @@ function runNextAction() {
|
||||
</p>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
未注明人物背景时,AI
|
||||
默认采用中国人物特征;剧本和角色设定优先。点击下方角色可关闭此界面并查看详情,不会确认或更改选角。
|
||||
遵循剧本与角色特征;未明确人物背景时保持地域与族裔中性。点击下方角色可关闭此界面并查看详情,不会确认或更改选角。
|
||||
</p>
|
||||
<div class="casting-list" role="group" aria-label="角色选角进度">
|
||||
<NButton
|
||||
@@ -982,6 +958,7 @@ function runNextAction() {
|
||||
detailBlocked || (subject.module === 'character' && !!castingQuery.error.value)
|
||||
"
|
||||
:pending-operation="pendingImageOperation"
|
||||
:validation-result="validationResult"
|
||||
:retry-disabled-reason="imageRetryDisabledReason"
|
||||
@validate="validateImage"
|
||||
@anchor="chooseAnchor"
|
||||
@@ -1068,7 +1045,7 @@ function runNextAction() {
|
||||
:catalog="generationModelsQuery.data.value"
|
||||
:profile="profileQuery.data.value.profile"
|
||||
:disabled="!canGenerateImage"
|
||||
@generate="submitIdentityImage" />
|
||||
:submit-generation="generateImage" />
|
||||
<CastingCandidateDialog
|
||||
v-if="
|
||||
subject?.module === 'character' && profileQuery.data.value?.profile && generationModelsQuery.data.value
|
||||
@@ -1079,7 +1056,7 @@ function runNextAction() {
|
||||
:catalog="generationModelsQuery.data.value"
|
||||
:profile="profileQuery.data.value.profile"
|
||||
:disabled="!canGenerateCandidate"
|
||||
@generate="submitCastingCandidate"
|
||||
:submit-generation="generateCastingCandidate"
|
||||
/></WorkspacePage>
|
||||
<!-- 以下是点击生图时才展示的模型配置引导,关闭后交给唯一项目配置抽屉 -->
|
||||
<AppDialog v-model:open="modelPromptOpen" title="需要配置生成模型" status="warning" @closed="finishModelPrompt">
|
||||
|
||||
@@ -81,10 +81,10 @@ export const subjectIdentityApi = {
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 读取与实际生图同源的输入预览,道具可能执行已确认的结构模型编译。
|
||||
* 只读编译当前已有资料,与实际生图输入同源,不补齐结构规格。
|
||||
* @param subjectId 正式主体 ID
|
||||
* @param input 与实际生图相同的参数
|
||||
* @param signal 只读预览取消信号,可能付费的道具不传
|
||||
* @param signal 取消过期预览
|
||||
* @returns 后端真实输入与最终参数
|
||||
*/
|
||||
previewImage: (subjectId: string, input: GenerateIdentityImageInput, signal?: AbortSignal) =>
|
||||
@@ -117,19 +117,40 @@ export const subjectIdentityApi = {
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 确认身份母版,质量审核可能耗时,等待真实服务结果。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param imageId 当前候选编号
|
||||
* @returns 已通过事务确认的图片或锁定回执
|
||||
*/
|
||||
setAnchor: (subjectId: string, imageId: string) =>
|
||||
request<IdentityImage>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/anchor`, {
|
||||
method: 'PUT'
|
||||
method: 'PUT',
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 确认场景或道具母版,通过质量门禁后锁定身份。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param imageId 当前候选编号
|
||||
* @returns 已通过事务确认的图片或锁定回执
|
||||
*/
|
||||
confirmStableAnchor: (subjectId: string, imageId: string) =>
|
||||
request<ConfirmCastingResult>(
|
||||
`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/stable-anchor`,
|
||||
{
|
||||
method: 'PUT'
|
||||
method: 'PUT',
|
||||
timeoutMs: 0
|
||||
}
|
||||
),
|
||||
/**
|
||||
* 确认角色选角,通过质量门禁后锁定演员。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param imageId 当前候选编号
|
||||
* @returns 已通过事务确认的图片或锁定回执
|
||||
*/
|
||||
confirmCasting: (subjectId: string, imageId: string) =>
|
||||
request<ConfirmCastingResult>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/casting`, {
|
||||
method: 'PUT'
|
||||
method: 'PUT',
|
||||
timeoutMs: 0
|
||||
})
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { imageGenerationDefaults } from '../../generation-config/image-defaults'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
|
||||
import { subjectIdentityApi } from '../api'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { NButton, NCheckbox, NFormItem, NInput } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { AppDrawer } from '../../../components/ui'
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
@@ -11,67 +15,78 @@ import type { GenerateCastingCandidateInput } from '../types'
|
||||
|
||||
/** Character 选角候选表单固定使用 primary,每次独立生成且不会自动选择演员。 */
|
||||
const props = defineProps<{
|
||||
/** 正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 主体名称。 */
|
||||
subjectName: string
|
||||
/** 项目活动任务锁。 */
|
||||
disabled: boolean
|
||||
/** 模型能力目录。 */
|
||||
catalog: GenerationModelCatalog
|
||||
/** 项目默认配置。 */
|
||||
profile: CreativeProfile
|
||||
/** 提交已核对的独立选角输入。 */
|
||||
submitGeneration: (input: GenerateCastingCandidateInput) => Promise<ImageGenerationSubmission>
|
||||
}>()
|
||||
/** 全屏生成表单开关。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
const emit = defineEmits<{ generate: [input: GenerateCastingCandidateInput] }>()
|
||||
/** 统一表单校验入口。 */
|
||||
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
/** 仅本次使用的完整画面描述。 */
|
||||
const prompt = ref('')
|
||||
/** 当前模型供应方。 */
|
||||
const provider = ref('')
|
||||
/** 模型动态参数。 */
|
||||
const generationOptions = ref<GenerationOptions>({})
|
||||
const acknowledged = ref(false)
|
||||
/** 供应方是否可用。 */
|
||||
const valid = computed(() => Boolean(provider.value))
|
||||
|
||||
/** 每次切换角色或重新打开都恢复项目当前图片模型与参数。 */
|
||||
function reset() {
|
||||
prompt.value = ''
|
||||
provider.value = props.profile.imageProvider
|
||||
const selected =
|
||||
props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
props.catalog.images.find(item => item.enabled)
|
||||
provider.value = selected?.provider ?? ''
|
||||
generationOptions.value = {
|
||||
...selected?.defaults,
|
||||
...(selected?.provider === props.profile.imageProvider ? props.profile.imageOptions : {})
|
||||
}
|
||||
const sizeSchema = selected?.generationOptions.find(item => item.key === 'size')
|
||||
if (
|
||||
sizeSchema?.options?.length &&
|
||||
!sizeSchema.options.some(option => option.value === generationOptions.value.size)
|
||||
) {
|
||||
generationOptions.value.size = selected?.defaults.size ?? sizeSchema.options[0]?.value ?? ''
|
||||
}
|
||||
acknowledged.value = false
|
||||
const defaults = imageGenerationDefaults(props.catalog, props.profile)
|
||||
provider.value = defaults.provider
|
||||
generationOptions.value = defaults.options
|
||||
}
|
||||
watch([() => props.subjectId, open, () => props.profile], reset, { immediate: true })
|
||||
|
||||
/** 候选生成显式携带当前图片 Provider 与动态参数,避免 Seedream 尺寸污染 Qwen。 */
|
||||
function submit() {
|
||||
if (props.disabled || !valid.value || !acknowledged.value) return
|
||||
emit('generate', {
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: generationOptions.value
|
||||
/** 选角正式请求不接收视角和母版开关,固定规则只传入预览。 */
|
||||
const generationInput = computed<GenerateCastingCandidateInput>(() => ({
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: { ...generationOptions.value }
|
||||
}))
|
||||
/** 选角使用 primary 且不引用当前母版,与正式候选生成一致。 */
|
||||
const { preview, acknowledged, loading, submitting, error, staleNotice, canSubmit, loadPreview, submit } =
|
||||
useImageGenerationPreview({
|
||||
open,
|
||||
target: () => JSON.stringify([props.subjectId, props.profile]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !valid.value,
|
||||
load: (input, signal) =>
|
||||
subjectIdentityApi.previewImage(
|
||||
props.subjectId,
|
||||
{ ...input, viewType: 'primary', useAnchorReference: false },
|
||||
signal
|
||||
),
|
||||
generate: input => props.submitGeneration(input)
|
||||
})
|
||||
}
|
||||
/** 当前描述草稿对应的表单模型。 */
|
||||
const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是 AI 生成角色候选图模块,生成后仍需用户确认选角 -->
|
||||
<AppDialog
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
title="AI 生成角色候选图"
|
||||
:busy="submitting"
|
||||
:description="`${subjectName} · 生成后需确认选角,才能设为角色母版`"
|
||||
>
|
||||
<AppForm
|
||||
ref="formRef"
|
||||
:model="formModel"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
:reset-key="`${open}:${subjectId}`"
|
||||
validate-on-change
|
||||
class="dialog-form-stack"
|
||||
@@ -88,7 +103,7 @@ const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
:label-props="{ for: 'casting-candidate-prompt' }"
|
||||
>
|
||||
<NInput
|
||||
placeholder="建议留空,自动使用已保存的角色特征;未明确人物背景时默认中国人物"
|
||||
placeholder="建议留空,自动使用已保存的角色特征;未明确人物背景时保持地域与族裔中性"
|
||||
:input-props="{ id: 'casting-candidate-prompt' }"
|
||||
class="min-h-24"
|
||||
v-model:value="prompt"
|
||||
@@ -105,27 +120,32 @@ const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
:provider="provider"
|
||||
:options="generationOptions"
|
||||
:aspect-ratio="profile.aspectRatio"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
@update:provider="provider = $event"
|
||||
@update:options="generationOptions = $event"
|
||||
/>
|
||||
<!-- 以下是独立选角的输入预览与费用确认模块 -->
|
||||
<ImageGenerationPreview
|
||||
:preview="preview"
|
||||
:loading="loading"
|
||||
:disabled="disabled || submitting || !valid"
|
||||
:error="error"
|
||||
:stale-notice="staleNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<NCheckbox
|
||||
id="casting-candidate-cost"
|
||||
v-model:checked="acknowledged"
|
||||
:disabled="!preview || submitting"
|
||||
class="flex items-start gap-2 text-xs leading-6"
|
||||
>我已确认调用图片模型可能产生费用,且当前没有同项目生成任务。
|
||||
>我已核对本次独立选角预览,确认图片模型费用。
|
||||
</NCheckbox>
|
||||
</AppForm>
|
||||
<template #footer>
|
||||
<NButton @click="open = false">取消</NButton>
|
||||
<NButton
|
||||
:disabled="disabled || !valid || !acknowledged"
|
||||
:loading="disabled"
|
||||
type="primary"
|
||||
@click="formRef?.validate(submit)"
|
||||
>
|
||||
{{ disabled ? '生成中…' : 'AI 生成角色候选图' }}
|
||||
<NButton :disabled="submitting" @click="open = false">取消</NButton>
|
||||
<NButton :disabled="!canSubmit" :loading="submitting" type="primary" @click="formRef?.validate(submit)">
|
||||
{{ submitting ? '提交中…' : 'AI 生成角色候选图' }}
|
||||
</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import ImageValidationPanel from '../../subject-images/components/ImageValidationPanel.vue'
|
||||
import type { IdentityValidationResult } from '../types'
|
||||
import { NButton, NTag } from 'naive-ui'
|
||||
import { LoaderCircle } from '@lucide/vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
@@ -24,6 +26,8 @@ const props = defineProps<{
|
||||
pendingOperation?: IdentityImageOperation | null
|
||||
/** 重新生成暂不可用的具体恢复步骤。 */
|
||||
retryDisabledReason?: string
|
||||
/** 本主体最近一次显式图片审核结果。 */
|
||||
validationResult?: IdentityValidationResult | null
|
||||
}>()
|
||||
/** 图片操作交给父页面核验并执行,浏览候选不会修改母版。 */
|
||||
const emit = defineEmits<{
|
||||
@@ -133,6 +137,12 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
@regenerate="regenerate"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是主页面图片本次审核证据模块 -->
|
||||
<ImageValidationPanel
|
||||
v-if="validationResult && images.some(image => image.id === validationResult?.imageId) && !candidatesOpen"
|
||||
class="mt-5"
|
||||
:result="validationResult"
|
||||
/>
|
||||
<!-- 以下是与镜头生产一致的底部图片操作模块 -->
|
||||
<div class="identity-gallery-actions">
|
||||
<NButton v-if="managedCandidates.length" @click="openCandidates"
|
||||
@@ -147,6 +157,7 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
title="身份候选管理"
|
||||
:description="`${subjectName} 的其他候选与辅助参考图;已在主页面展示的图片不重复列出。辅助参考图不能设为母版。`"
|
||||
:width="candidatesWidth"
|
||||
:busy="!!pendingOperation"
|
||||
>
|
||||
<div class="identity-candidate-grid">
|
||||
<IdentityImageCard
|
||||
@@ -165,6 +176,12 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
@regenerate="regenerate"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是候选管理中的审核证据模块 -->
|
||||
<ImageValidationPanel
|
||||
v-if="validationResult && managedCandidates.some(image => image.id === validationResult?.imageId)"
|
||||
class="mt-5"
|
||||
:result="validationResult"
|
||||
/>
|
||||
</AppDialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -132,8 +132,11 @@ function regenerate() {
|
||||
<div class="identity-image-card-body">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<!-- 母版已是完成图,仅保留身份标识;候选继续显示生成状态。 -->
|
||||
<NTag v-if="!image.isAnchor && image.status === 'completed'" :bordered="false" size="small"
|
||||
>图片已生成</NTag
|
||||
>
|
||||
<StatusBadge
|
||||
v-if="!image.isAnchor && !failureNotice"
|
||||
v-else-if="!image.isAnchor && !failureNotice"
|
||||
:status="image.status"
|
||||
:label="image.status === 'pending' ? '排队中' : undefined"
|
||||
/>
|
||||
@@ -236,6 +239,10 @@ function regenerate() {
|
||||
: `确认切换 ${subjectName} 的身份母版?旧母版会保留在候选记录中,后续形态图片生成会使用新母版。`
|
||||
"
|
||||
>
|
||||
<!-- 以下是身份母版采纳的费用与门禁说明模块 -->
|
||||
<p class="text-sm leading-7 text-muted">
|
||||
确认时会核对当前来源和质量,可能调用视觉模型并产生审核费用。通过后才锁定并采纳;未通过时保留旧母版,不自动追加生图。
|
||||
</p>
|
||||
<template #footer>
|
||||
<NButton @click="confirming = false">取消</NButton>
|
||||
<NButton :disabled="!canSelect" type="primary" @click="chooseAnchor">{{
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
|
||||
import { imageGenerationDefaults } from '../../generation-config/image-defaults'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { referenceGenerationCatalog, referenceGenerationOptions } from '../reference-generation'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { fieldRule } from '../../../lib/form-rules'
|
||||
import { NButton, NCheckbox, NInput, NSelect } from 'naive-ui'
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { AppDialog, FieldLabel } from '../../../components/ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AppDrawer, FieldLabel } from '../../../components/ui'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
import { subjectIdentityApi } from '../api'
|
||||
import type { IdentityImagePreview } from '../types'
|
||||
import { currentAnchor, identityViewLabels } from '../model'
|
||||
import type { GenerateIdentityImageInput, IdentityImage, IdentityViewType } from '../types'
|
||||
|
||||
@@ -38,12 +34,14 @@ const props = defineProps<{
|
||||
catalog: GenerationModelCatalog
|
||||
/** 已保存的项目默认生成配置。 */
|
||||
profile: CreativeProfile
|
||||
/** 提交当前参数与已核对的输入版本。 */
|
||||
submitGeneration: (input: GenerateIdentityImageInput) => Promise<ImageGenerationSubmission>
|
||||
}>()
|
||||
/** open 的当前界面状态与输入绑定。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** emit 的当前界面状态与输入绑定。 */
|
||||
const emit = defineEmits<{ generate: [input: GenerateIdentityImageInput] }>()
|
||||
/** 统一表单校验入口。 */
|
||||
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
/** 当前生成视角。 */
|
||||
const viewType = ref<IdentityViewType>('primary')
|
||||
/** referenceImageId 的当前界面状态与输入绑定。 */
|
||||
const referenceImageId = ref('')
|
||||
@@ -51,9 +49,8 @@ const referenceImageId = ref('')
|
||||
const prompt = ref('')
|
||||
/** provider 的当前界面状态与输入绑定。 */
|
||||
const provider = ref('')
|
||||
/** 当前模型参数。 */
|
||||
const generationOptions = ref<GenerationOptions>({})
|
||||
/** acknowledged 的当前界面状态与输入绑定。 */
|
||||
const acknowledged = ref(false)
|
||||
/** anchor 的当前界面状态与输入绑定。 */
|
||||
const anchor = computed(() => currentAnchor(props.images))
|
||||
/** allowedViews 的当前界面状态与输入绑定。 */
|
||||
@@ -82,22 +79,9 @@ watch(
|
||||
: 'primary'
|
||||
referenceImageId.value = ''
|
||||
prompt.value = ''
|
||||
const selected =
|
||||
props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
props.catalog.images.find(item => item.enabled)
|
||||
provider.value = selected?.provider ?? ''
|
||||
generationOptions.value = {
|
||||
...selected?.defaults,
|
||||
...(selected?.provider === props.profile.imageProvider ? props.profile.imageOptions : {})
|
||||
}
|
||||
const sizeSchema = selected?.generationOptions.find(item => item.key === 'size')
|
||||
if (
|
||||
sizeSchema?.options?.length &&
|
||||
!sizeSchema.options.some(option => option.value === generationOptions.value.size)
|
||||
) {
|
||||
generationOptions.value.size = selected?.defaults.size ?? sizeSchema.options[0]?.value ?? ''
|
||||
}
|
||||
acknowledged.value = false
|
||||
const defaults = imageGenerationDefaults(props.catalog, props.profile)
|
||||
provider.value = defaults.provider
|
||||
generationOptions.value = defaults.options
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
@@ -118,69 +102,26 @@ const generationInput = computed<GenerateIdentityImageInput>(() => ({
|
||||
provider: provider.value,
|
||||
generationOptions: { ...compatibleOptions.value }
|
||||
}))
|
||||
/** 当前参数的预览结果。 */
|
||||
const preview = ref<IdentityImagePreview | null>(null)
|
||||
/** 预览读取状态。 */
|
||||
const previewLoading = ref(false)
|
||||
/** 道具预览可能付费,保持项目锁直到真实请求结束,不能因关闭弹窗提前释放。 */
|
||||
const paidPreviewPending = ref(false)
|
||||
/** 预览读取错误。 */
|
||||
const previewError = ref('')
|
||||
/** 用于取消迟到预览的请求控制器。 */
|
||||
let previewController: AbortController | undefined
|
||||
/** 参数、主体或弹窗变化时清除旧结果和费用确认。 */
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
watch(
|
||||
() => [props.subjectId, open.value, JSON.stringify(generationInput.value), JSON.stringify(props.images)],
|
||||
() => {
|
||||
previewController?.abort()
|
||||
preview.value = null
|
||||
previewError.value = ''
|
||||
previewLoading.value = false
|
||||
acknowledged.value = false
|
||||
}
|
||||
)
|
||||
/** 卸载时取消未完成的只读请求。 */
|
||||
onBeforeUnmount(() => previewController?.abort())
|
||||
/** 读取当前参数的真实预览;道具后端可能编译结构模型,禁止当作免费读取。 */
|
||||
async function loadPreview() {
|
||||
if (props.disabled || !valid.value || previewLoading.value || paidPreviewPending.value) return
|
||||
previewController?.abort()
|
||||
const controller = new AbortController()
|
||||
previewController = controller
|
||||
const subjectId = props.subjectId
|
||||
const projectId = props.profile.projectId
|
||||
const paid = props.module === 'prop'
|
||||
const input = { ...generationInput.value, generationOptions: { ...generationInput.value.generationOptions } }
|
||||
previewLoading.value = true
|
||||
previewError.value = ''
|
||||
paidPreviewPending.value = paid
|
||||
/** 道具请求不传取消信号,取消客户端展示不能取消后端结构模型的工作。 */
|
||||
const inspect = async () => {
|
||||
const result = await subjectIdentityApi.previewImage(subjectId, input, paid ? undefined : controller.signal)
|
||||
if (!controller.signal.aborted && previewController === controller && subjectId === props.subjectId)
|
||||
preview.value = result
|
||||
}
|
||||
try {
|
||||
if (paid) {
|
||||
const ok = await runOperation(projectId, '预览道具结构输入', inspect)
|
||||
if (!ok && !controller.signal.aborted && subjectId === props.subjectId)
|
||||
previewError.value = getOperation(projectId).error
|
||||
} else await inspect()
|
||||
} catch (error) {
|
||||
if (!controller.signal.aborted)
|
||||
previewError.value = error instanceof Error ? error.message : '身份输入预览读取失败'
|
||||
} finally {
|
||||
paidPreviewPending.value = false
|
||||
if (previewController === controller) previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交生图参数;省略空参考 ID 以保留后端自动选择逻辑。 */
|
||||
function submit() {
|
||||
if (props.disabled || paidPreviewPending.value || !valid.value || !acknowledged.value) return
|
||||
emit('generate', generationInput.value)
|
||||
}
|
||||
/** 三类生图共用预览版本和确认失效保护,预览本身不收费。 */
|
||||
const {
|
||||
preview,
|
||||
acknowledged,
|
||||
loading: previewLoading,
|
||||
submitting,
|
||||
error: previewError,
|
||||
staleNotice,
|
||||
canSubmit,
|
||||
loadPreview,
|
||||
submit
|
||||
} = useImageGenerationPreview({
|
||||
open,
|
||||
target: () =>
|
||||
JSON.stringify([props.subjectId, props.images.filter(image => image.status === 'completed'), props.profile]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !valid.value,
|
||||
load: (input, signal) => subjectIdentityApi.previewImage(props.subjectId, input, signal),
|
||||
generate: input => props.submitGeneration(input)
|
||||
})
|
||||
/** formModel 的当前界面状态与输入绑定。 */
|
||||
const formModel = computed(() => ({
|
||||
prompt: prompt.value,
|
||||
@@ -197,12 +138,12 @@ const rules = {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppDialog v-model:open="open" title="生成身份参考图" :description="subjectName" :busy="paidPreviewPending">
|
||||
<AppDrawer v-model:open="open" title="生成身份参考图" :description="subjectName" :busy="submitting">
|
||||
<AppForm
|
||||
ref="formRef"
|
||||
:model="formModel"
|
||||
:rules="rules"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
:reset-key="`${open}:${subjectId}`"
|
||||
validate-on-change
|
||||
class="dialog-form-stack"
|
||||
@@ -210,7 +151,7 @@ const rules = {
|
||||
>
|
||||
<ContextNotice type="info" :show-icon="false" class="text-xs">
|
||||
调用
|
||||
图片模型,每次新增一张图片,可能产生费用。第一张成功的主视图会成为标准参考图;已经有标准参考图时,新主视图只作为候选保留。
|
||||
图片模型,每次新增一张图片,可能产生费用。新图片只作为候选保留,质量审核通过并由你确认后,才能成为身份母版。
|
||||
</ContextNotice>
|
||||
<!-- 以下是多视角与已有身份图选择模块,单一选项不显示选择器 -->
|
||||
<NFormItem
|
||||
@@ -278,51 +219,32 @@ const rules = {
|
||||
:provider="provider"
|
||||
:options="compatibleOptions"
|
||||
:aspect-ratio="profile.aspectRatio"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
@update:provider="provider = $event"
|
||||
@update:options="generationOptions = $event"
|
||||
/>
|
||||
<!-- 以下是真实生图输入预览模块 -->
|
||||
<ConfirmAction
|
||||
v-if="module === 'prop'"
|
||||
label="预览道具真实输入"
|
||||
description="缺少有效结构缓存时可能调用文本模型并产生费用;不会生成身份图片。确认后读取本次最终参数。"
|
||||
:disabled="disabled || !valid || previewLoading"
|
||||
acknowledgement
|
||||
@confirm="loadPreview"
|
||||
<ImageGenerationPreview
|
||||
:preview="preview"
|
||||
:loading="previewLoading"
|
||||
:disabled="disabled || submitting || !valid"
|
||||
:error="previewError"
|
||||
:stale-notice="staleNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<NButton v-else :disabled="disabled || !valid" :loading="previewLoading" @click="loadPreview"
|
||||
>预览本次真实输入</NButton
|
||||
>
|
||||
<FeedbackMessage v-if="previewError" :message="previewError" />
|
||||
<div v-if="preview" class="text-xs space-y-3">
|
||||
<p>实际供应方:{{ preview.provider }} · 模型:{{ preview.model }}</p>
|
||||
<p class="whitespace-pre-wrap">最终提示词:{{ preview.providerPrompt }}</p>
|
||||
<RawDataDetails
|
||||
:value="{
|
||||
referenceImages: preview.referenceImages,
|
||||
referencePlan: preview.referencePlan,
|
||||
generationConfig: preview.generationConfig
|
||||
}"
|
||||
title="参考图与生成设置(高级)"
|
||||
/>
|
||||
</div>
|
||||
<NCheckbox
|
||||
id="identity-image-cost"
|
||||
v-model:checked="acknowledged"
|
||||
:disabled="!preview || submitting"
|
||||
class="flex items-start gap-2 text-xs leading-6"
|
||||
>我已确认后台没有同项目任务,了解本次会调用模型并可能产生费用。</NCheckbox
|
||||
>我已核对本次预览,确认调用图片模型产生的费用。</NCheckbox
|
||||
>
|
||||
</AppForm>
|
||||
<template #footer>
|
||||
<NButton @click="open = false">取消</NButton
|
||||
><NButton
|
||||
:disabled="disabled || paidPreviewPending || !valid || !acknowledged"
|
||||
type="primary"
|
||||
@click="formRef?.validate(submit)"
|
||||
>
|
||||
<NButton :disabled="submitting" @click="open = false">取消</NButton
|
||||
><NButton :disabled="!canSubmit" :loading="submitting" type="primary" @click="formRef?.validate(submit)">
|
||||
确认生成身份图
|
||||
</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { SubjectImageStatus, SubjectFormAsset } from '../subject-images/types'
|
||||
import type { ImageGenerationPreview } from '../subject-images/generation-preview'
|
||||
import type { ImageValidationResult } from '../subject-images/validation'
|
||||
|
||||
/** 只有 primary 视图可以选为身份母版,其余视图是辅助参考。 */
|
||||
export type IdentityViewType = 'primary' | 'front' | 'three-quarter' | 'full-body'
|
||||
@@ -62,19 +64,31 @@ export type SaveIdentityInput = Partial<Pick<SubjectIdentity, 'description' | 'g
|
||||
|
||||
/** 单张身份生图;空 referenceImageId 应省略,由后端自动引用当前母版。 */
|
||||
export interface GenerateIdentityImageInput {
|
||||
/** 本次参考视角。 */
|
||||
viewType: IdentityViewType
|
||||
/** 用户显式选择的同主体参考图。 */
|
||||
referenceImageId?: string
|
||||
/** 是否使用当前母版,选角预览固定为 false。 */
|
||||
useAnchorReference?: boolean
|
||||
/** 用户核对的来源与输入版本。 */
|
||||
expectedPreviewFingerprint?: string
|
||||
/** 本次可选宽度。 */
|
||||
width?: number
|
||||
/** 本次可选高度。 */
|
||||
height?: number
|
||||
/** 本次完整画面描述。 */
|
||||
prompt?: string
|
||||
/** 本次图片供应方。 */
|
||||
provider?: string
|
||||
/** 模型支持的动态参数。 */
|
||||
generationOptions?: Record<string, string | number | boolean>
|
||||
}
|
||||
|
||||
/** Character 选角候选固定独立生成 primary,不复用旧 Anchor,也不会自动成为新 Anchor。 */
|
||||
export interface GenerateCastingCandidateInput {
|
||||
prompt?: string
|
||||
provider?: string
|
||||
generationOptions?: Record<string, string | number | boolean>
|
||||
}
|
||||
export type GenerateCastingCandidateInput = Omit<
|
||||
GenerateIdentityImageInput,
|
||||
'viewType' | 'referenceImageId' | 'useAnchorReference'
|
||||
>
|
||||
|
||||
/** 身份文本批量生成回执,不代表已生成参考图。 */
|
||||
export interface IdentityBatchResult {
|
||||
@@ -189,41 +203,10 @@ export type IdentityReceipt =
|
||||
| { kind: 'stable-anchors'; title: string; result: StableAnchorBatchResult }
|
||||
|
||||
/** 最终身份图片 Provider 输入,直接对应身份预览接口。 */
|
||||
export interface IdentityImagePreview {
|
||||
/** 实际供应方。 */
|
||||
provider: string
|
||||
/** 实际模型。 */
|
||||
model: string
|
||||
/** 最终提示词。 */
|
||||
providerPrompt: string
|
||||
/** 实际引用图片地址。 */
|
||||
referenceImages: string[]
|
||||
/** 后端参考图选择计划。 */
|
||||
referencePlan: Record<string, unknown>
|
||||
/** 后端解析后的生成配置。 */
|
||||
generationConfig: Record<string, unknown>
|
||||
}
|
||||
export type IdentityImagePreview = ImageGenerationPreview
|
||||
|
||||
/** 指定身份图片的视觉校验回执。 */
|
||||
export interface IdentityValidationResult {
|
||||
/** 正式主体 ID。 */
|
||||
subjectId: string
|
||||
/** 被校验的图片 ID。 */
|
||||
imageId: string
|
||||
/** 是否通过本次校验。 */
|
||||
passed: boolean
|
||||
/** 校验总结。 */
|
||||
summary: string
|
||||
/** 具体问题。 */
|
||||
issues: Array<{
|
||||
/** 问题类型。 */
|
||||
type: string
|
||||
/** 严重程度。 */
|
||||
severity: string
|
||||
/** 问题描述。 */
|
||||
description: string
|
||||
}>
|
||||
}
|
||||
export type IdentityValidationResult = ImageValidationResult
|
||||
|
||||
/** 有限预算的单主体稳定母版生成参数。 */
|
||||
export interface StableAnchorQualityInput {
|
||||
|
||||
@@ -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