feat(short-drama-agent-front): 支持母版复用并优化生成交互

This commit is contained in:
GJ committed 2026-10-12 15:22:03 +08:00
1 parent 49fb9c7a27
commit ee5e49957a
28 files changed
+634 -326

No files matched your search

+77 -30
View File
@@ -5,7 +5,8 @@ import { integerRule, fieldRule } from '../../lib/form-rules'
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue'
import { NScrollbar, NAlert, NButton, NCheckbox, NInputNumber, NProgress, NTab, NTable, NTabs } from 'naive-ui'
import { computed, onScopeDispose, ref, watch } from 'vue'
import { computed, h, onScopeDispose, ref, watch } from 'vue'
import { useActionMessage } from '../../components/ui/useActionMessage'
import { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
import { useProjectContext } from '../projects/context'
@@ -27,7 +28,6 @@ const groupSize = ref(3)
const modules = ref<BreakdownModule[]>(['character', 'scene', 'prop'])
const preview = ref<BreakdownPreview | null>(null)
const previewBusy = ref(false)
const previewError = ref('')
const tab = ref('character')
const toolsOpen = ref(false)
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
@@ -65,7 +65,54 @@ const configValid = computed(
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
)
const input = computed<BreakdownInput>(() => ({ groupSize: groupSize.value, modules: [...modules.value] }))
/** 后端就绪状态决定是否显示后续制作入口。 */
const stageComplete = computed(() => stageReadiness.value?.breakdown.ready === true)
/** 拆解提示复用全局 NMessage,详细问题留在设置弹窗。 */
const actionMessage = useActionMessage()
/** 问题内容变化才通知,轮询取得相同快照时不会重复弹出。 */
const issueSignature = computed(() =>
JSON.stringify({
error: execution.value?.errorMessage || '',
issues: validation.value?.valid === false ? validation.value.issues : []
})
)
/** 首次读取或问题变化时只显示一条汇总,保留可操作的详情入口。 */
watch(
issueSignature,
() => {
const executionError = execution.value?.errorMessage
const invalid = validation.value?.valid === false
if (!executionError && !invalid) return
actionMessage?.warning(
() =>
h('div', { class: 'flex flex-wrap items-center gap-3' }, [
h(
'span',
invalid
? `分镜校验未通过,共 ${validation.value?.issues.length ?? 0} 项问题。`
: '拆解任务未完成,请查看错误详情。'
),
h(
NButton,
{
text: true,
onClick: () => {
toolsOpen.value = true
}
},
() => '查看详情与恢复操作'
)
]),
{ duration: 6000, closable: true }
)
},
{ immediate: true }
)
/** 已加载的就绪状态由未完成变为完成时通知,不重放首次读取的历史结果。 */
watch([() => stageReadiness.value, stageComplete], ([, ready], [previousReadiness, previous]) => {
if (previousReadiness && ready && !previous)
actionMessage?.success('剧本拆解已准备完成,可以继续视觉风格。', { duration: 4000, closable: true })
})
const canStart = computed(
() =>
!!project.value?.episodes.length &&
@@ -86,7 +133,6 @@ function invalidatePreview() {
previewController?.abort()
preview.value = null
previewBusy.value = false
previewError.value = ''
}
watch(
[
@@ -115,7 +161,7 @@ async function loadPreview() {
const data = await breakdownApi.preview(project.value.id, input.value, previewController.signal)
if (version === previewVersion) preview.value = data
} catch (cause) {
if (version === previewVersion) previewError.value = errorMessage(cause)
if (version === previewVersion) actionMessage?.error(errorMessage(cause), { duration: 6000, closable: true })
} finally {
if (version === previewVersion) previewBusy.value = false
}
@@ -132,11 +178,16 @@ async function run(action: BreakdownAction) {
'resume-storyboard': '正在修复分镜绑定'
}
const id = project.value.id
await runOperation(id, labels[action], async () => {
const started = await breakdownApi.run(id, action, action === 'start' ? input.value : undefined)
await backgroundExecution.track(started.executionId)
return started
})
await runOperation(
id,
labels[action],
async () => {
const started = await breakdownApi.run(id, action, action === 'start' ? input.value : undefined)
await backgroundExecution.track(started.executionId)
return started
},
{ type: 'info', content: '拆解任务已提交,可在“拆解设置与恢复”中查看进度。' }
)
await refresh()
}
@@ -159,15 +210,6 @@ const rules = {
<template>
<!-- 以下是手机完成提示自然滚走、分类导航与设置入口吸顶的拆解工作区 -->
<WorkspacePage split compact mobile-scroll class="breakdown-workspace-page">
<template #notice>
<!-- 以下是拆解完成后的下一步提示模块 -->
<NAlert v-if="stageComplete" type="success" :show-icon="false">
剧本拆解已经准备完成,人物、场景、道具和正式镜头都可以进入后续制作。
<RouterLink :to="`/projects/${projectId}/visual-style`" class="text-button ml-2"
>继续视觉风格 →</RouterLink
>
</NAlert>
</template>
<template #header>
<!-- 以下是拆解状态与设置 -->
<div class="workspace-toolbar">
@@ -188,7 +230,18 @@ const rules = {
"
/>
</div>
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗 -->
<div v-if="project?.episodes.length" class="toolbar-actions">
<NButton
v-if="execution?.errorMessage || validation?.valid === false"
text
type="error"
@click="toolsOpen = true"
>查看拆解问题</NButton
>
<RouterLink v-if="stageComplete" :to="`/projects/${projectId}/visual-style`" class="text-button"
>继续视觉风格 →</RouterLink
>
<WorkspaceTools v-model:open="toolsOpen" title="拆解设置与恢复" label="拆解设置与恢复">
<section class="panel workspace-panel breakdown-settings-panel">
<div class="flex flex-wrap items-start justify-between gap-3">
@@ -269,9 +322,6 @@ const rules = {
</NButton>
</div>
</AppForm>
<NAlert v-if="previewError" role="alert" type="error" :show-icon="false" class="mt-4">{{
previewError
}}</NAlert>
<div v-if="preview" class="group-preview">
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<p class="text-sm">
@@ -309,6 +359,8 @@ const rules = {
<WorkflowExecutionPanel
v-if="backgroundExecution.executionId.value"
title="剧本拆解任务"
class="breakdown-execution-panel"
:show-status-hint="false"
:execution="backgroundExecution.query.data.value"
:loading="backgroundExecution.query.loading.value"
:error="backgroundExecution.query.error.value"
@@ -433,15 +485,6 @@ const rules = {
></EmptyState>
</NScrollbar>
<template v-else>
<NScrollbar v-if="execution?.errorMessage || (validation && !validation.valid)" class="workspace-feedback">
<NAlert v-if="execution?.errorMessage" role="alert" type="error" :show-icon="false">{{
execution.errorMessage
}}</NAlert>
<NAlert v-if="validation && !validation.valid" role="alert" type="error" :show-icon="false">
分镜校验未通过,共 {{ validation.issues.length }} 项问题。
<NButton text @click="toolsOpen = true">查看详情与恢复操作</NButton>
</NAlert>
</NScrollbar>
<section class="breakdown-results-section">
<div class="result-toolbar tabs-toolbar">
<NTabs v-model:value="tab" class="workspace-tabs" type="line" size="small" aria-label="拆解结果"
@@ -561,6 +604,10 @@ const rules = {
<style>
/* 本组件专属布局与 Naive 内部结构覆盖。 */
@reference "../../styles/styles.css";
/* 任务卡片取消二次内缩,与快照、校验详情及设置卡片边缘对齐。 */
.workspace-tools-body .breakdown-execution-panel {
padding: 0;
}
.group-preview {
@apply mt-6 pt-5;
}
+60 -48
View File
@@ -94,52 +94,54 @@ function exportScript() {
<Check v-if="stage.done" :size="15" /><Circle v-else :size="13" /><span>{{ stage.label }}</span
><ArrowRight v-if="index < stages.length - 1" :size="13" class="stage-arrow" />
</div>
</div></div
></template>
<WorkflowExecutionPanel
v-if="backgroundExecution.executionId.value"
title="剧本创作任务"
:execution="backgroundExecution.query.data.value"
:loading="backgroundExecution.query.loading.value"
:error="backgroundExecution.query.error.value"
@refresh="backgroundExecution.query.refresh"
@dismiss="backgroundExecution.dismiss"
/>
<div v-if="!complete" class="mt-5 flex flex-wrap items-center justify-between gap-4">
<p class="text-sm text-muted">
已写入 {{ episodes.length }}<span v-if="total"> / {{ total }}</span> 集<span v-if="!total">
· 等待计划集数</span
>。{{
project?.status === 'generating'
? '剧本仍在生成,请等待状态更新。'
: '如中途停止,可从当前阶段继续。'
}}
</p>
<div class="flex flex-wrap gap-2">
<ConfirmAction
label="恢复生成"
description="用于剧集尚未写完的情况。系统会从已保存的角色、世界观和剧集进度继续生成。"
acknowledgement
:disabled="!canGenerate || operation.pending || backgroundExecution.active.value || !!error"
@confirm="resume('resume-generation')"
/><ConfirmAction
label="恢复改写"
description="用于剧集已齐全但审核未通过的情况。系统会从已保存的改写进度继续审核和调整。"
acknowledgement
:disabled="!canRewrite || operation.pending || backgroundExecution.active.value || !!error"
@confirm="resume('resume-rewrite')"
/>
</div>
</div>
</div>
<NProgress
v-if="total && !complete"
aria-label="已写入剧集数量"
type="line"
:show-indicator="false"
:height="4"
:percentage="Math.min(100, Math.max(0, (Math.min(episodes.length, total) / Math.max(1, total)) * 100))"
class="mt-4"
></NProgress>
<!-- 以下是唯一的创作任务进度与恢复操作模块,随标题区滚动 -->
<WorkflowExecutionPanel
v-if="backgroundExecution.executionId.value"
title="剧本创作任务"
:execution="backgroundExecution.query.data.value"
:loading="backgroundExecution.query.loading.value"
:error="backgroundExecution.query.error.value"
@refresh="backgroundExecution.query.refresh"
@dismiss="backgroundExecution.dismiss"
/>
<div v-if="!complete" class="mt-5 flex flex-wrap items-center justify-between gap-4">
<p class="text-sm text-muted">
已写入 {{ episodes.length }}<span v-if="total"> / {{ total }}</span> 集<span v-if="!total">
· 等待计划集数</span
>。{{
project?.status === 'generating'
? '剧本仍在生成,请等待状态更新。'
: '如中途停止,可从当前阶段继续。'
}}
</p>
<div class="flex flex-wrap gap-2">
<ConfirmAction
label="恢复生成"
description="用于剧集尚未写完的情况。系统会从已保存的角色、世界观和剧集进度继续生成。"
acknowledgement
:disabled="!canGenerate || operation.pending || backgroundExecution.active.value || !!error"
@confirm="resume('resume-generation')"
/><ConfirmAction
label="恢复改写"
description="用于剧集已齐全但审核未通过的情况。系统会从已保存的改写进度继续审核和调整。"
acknowledgement
:disabled="!canRewrite || operation.pending || backgroundExecution.active.value || !!error"
@confirm="resume('resume-rewrite')"
/>
</div>
</div>
<NProgress
v-if="total && !complete"
aria-label="已写入剧集数量"
type="line"
:show-indicator="false"
:height="4"
:percentage="Math.min(100, Math.max(0, (Math.min(episodes.length, total) / Math.max(1, total)) * 100))"
class="mt-4"
></NProgress>
</template>
<div class="script-section">
<!-- 以下是剧本内容标签与直接导出模块 -->
<div class="tabs-toolbar">
@@ -271,7 +273,7 @@ function exportScript() {
}
@media (max-width: 760px) {
/* 手机直接通过内容 Tab 查看结果,隐藏重复的流程进度行以增加正文空间。 */
.script-workspace-page .workspace-heading-scroll {
.script-workspace-page .stage-strip {
display: none;
}
}
@@ -327,7 +329,17 @@ function exportScript() {
/* 标签栏下方使用与页面上方相同的模块间距。 */
margin-top: var(--app-content-gap);
}
.script-workspace-page .workspace-split > :not(.script-section) {
@apply shrink-0;
/* 任务详情与恢复操作在有界提示区滚动,为正文保留可用高度。 */
.script-workspace-page .workspace-heading-scroll {
max-height: min(40dvh, 320px);
}
.script-workspace-page .workspace-heading {
display: flex;
flex-direction: column;
gap: var(--app-content-gap);
}
.script-workspace-page .workspace-heading > * {
margin-block: 0;
flex-shrink: 0;
}
</style>
+21 -55
View File
@@ -14,7 +14,6 @@ import { useActionMessage } from '../../components/ui/useActionMessage'
import { productionMessage } from '../production/production-messages'
import ProjectSettingsDialog from '../generation-config/components/ProjectSettingsDialog.vue'
import { projectGenerationRevisionKey } from '../generation-config/context'
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
import CreateDramaSkeleton from '../create-drama/CreateDramaSkeleton.vue'
import BreakdownSkeleton from '../breakdown/BreakdownSkeleton.vue'
import VisualStyleSkeleton from '../visual-style/VisualStyleSkeleton.vue'
@@ -114,6 +113,7 @@ type OperationGuide = {
action?: string
target?: 'profile' | 'style' | 'identity' | 'keyframe'
}
/** 仅为明确缺失的前置条件提供恢复入口,不把同页生成失败变成无效跳转。 */
const operationGuide = computed<OperationGuide | null>(() => {
const error = operation.value.error?.trim()
if (!error) return null
@@ -139,7 +139,11 @@ const operationGuide = computed<OperationGuide | null>(() => {
action: '设置视觉风格',
target: 'style'
}
if (error.includes('身份') || normalized.includes('identity'))
if (
currentSection.value !== 'subject-identity' &&
(error.includes('身份') || normalized.includes('identity')) &&
/缺少|缺失|未就绪|未锁定|尚未|未确认|missing|not ready|not locked|not found|unconfirmed/i.test(error)
)
return {
title: '主体身份尚未就绪',
description: '先按主体身份页的步骤补齐文本、母版并完成锁定。',
@@ -151,22 +155,21 @@ const operationGuide = computed<OperationGuide | null>(() => {
/** 操作结果只在当前项目收到新响应后通知,不在进入工作区时重放旧提示。 */
const actionMessage = useActionMessage()
/** 分镜、生产和主体身份的操作结果使用临时消息。 */
const quietFeedback = computed(() =>
['production', 'storyboard', 'subject-identity'].includes(currentSection.value ?? '')
)
/** 主体身份请求进度使用消息,其余工作区继续展示已有任务进度。 */
const inlinePendingFeedback = computed(() => operation.value.pending && currentSection.value !== 'subject-identity')
/** 当前身份请求的加载消息,完成或离开工作区后立即销毁。 */
/** 当前请求的加载消息,完成或离开工作区后销毁。 */
let pendingMessage: MessageReactive | null = null
/** 请求开始即反馈,切换主体时保留请求目标名称,避免无反馈的禁用按钮。 */
/** 新操作用短消息反馈,页面切换不重放后台任务提示。 */
watch(
() => [id.value, currentSection.value, operation.value.pending, operation.value.label] as const,
([, section, pending, label]) => {
([projectId, section, pending, label], [previousId, previousSection, previousPending, previousLabel]) => {
pendingMessage?.destroy()
pendingMessage = null
if (section === 'subject-identity' && pending)
pendingMessage = actionMessage?.loading(`${label || '主体身份操作'},请稍候…`, { duration: 0 }) ?? null
if (projectId !== previousId || section !== previousSection || !pending) return
if (previousPending && label === previousLabel) return
pendingMessage =
actionMessage?.loading(`${label || '后台任务执行中'},请稍候…`, {
duration: section === 'subject-identity' ? 0 : 4000,
closable: true
}) ?? null
}
)
/** 关闭页面时清理未完成请求的加载消息。 */
@@ -176,8 +179,11 @@ watch(
() => [id.value, operation.value.error, operation.value.notice] as const,
([projectId, error, notice], [previousProject, previousError, previousNotice]) => {
if (projectId !== previousProject) return
if ((error && error !== previousError) || (notice && notice !== previousNotice)) {
pendingMessage?.destroy()
pendingMessage = null
}
if (error && error !== previousError) {
if (!quietFeedback.value) return
const guide = operationGuide.value
const content =
currentSection.value === 'subject-identity'
@@ -205,7 +211,6 @@ watch(
{ duration: 8000, closable: true }
)
} else if (notice && notice !== previousNotice) {
if (!quietFeedback.value) return
if (operation.value.noticeType)
actionMessage?.[operation.value.noticeType](notice, {
duration: operation.value.noticeType === 'warning' ? 8000 : 4000,
@@ -278,50 +283,14 @@ onScopeDispose(() => {
</template>
</NPageHeader>
</header>
<NScrollbar
v-if="
context.error.value ||
inlinePendingFeedback ||
(!quietFeedback && operation.error) ||
(!quietFeedback && operation.notice)
"
class="project-notices"
content-class="project-notices-content"
>
<NScrollbar v-if="context.error.value" class="project-notices" content-class="project-notices-content">
<NAlert v-if="context.error.value" type="error" :show-icon="false"
>{{ context.error.value }}<span v-if="context.project.value"> 当前保留上次成功读取的数据。</span>
<NButton text class="ml-3" :loading="context.loading.value" @click="context.refresh"
>重试读取</NButton
></NAlert
>
<NAlert v-if="inlinePendingFeedback" :show-icon="false" role="status"
>{{ operation.label || '后台制作任务执行中' }}。可切换页面查看结果,请勿重复提交。</NAlert
>
<NAlert v-if="operationGuide && !quietFeedback" type="error" :show-icon="false" class="operation-guide">
<div class="operation-guide-content">
<div>
<strong>{{ operationGuide.title }}</strong>
<span class="ml-2">{{ operationGuide.description }}</span>
</div>
<NButton v-if="operationGuide.action" size="small" type="primary" @click="resolveOperationError">{{
operationGuide.action
}}</NButton>
</div>
</NAlert>
<NAlert v-if="operation.notice && !quietFeedback" :show-icon="false" role="status">{{
operation.notice
}}</NAlert>
</NScrollbar>
<WorkflowExecutionPanel
v-if="isCreation && createDramaExecution.executionId.value"
class="project-workflow-status"
title="剧本创作后台任务"
:execution="createDramaExecution.query.data.value"
:loading="createDramaExecution.query.loading.value"
:error="createDramaExecution.query.error.value"
@refresh="createDramaExecution.query.refresh"
@dismiss="createDramaExecution.dismiss"
/>
<!-- 以下是当前项目图片与视频配置弹窗模块 -->
<ProjectSettingsDialog
:key="id"
@@ -392,9 +361,6 @@ onScopeDispose(() => {
padding: var(--app-content-padding) var(--app-content-padding) 0;
gap: var(--app-content-gap);
}
.project-workflow-status {
margin: var(--app-content-gap) var(--app-content-padding) 0;
}
.operation-guide-content {
@apply flex items-center justify-between gap-4;
}
@@ -90,16 +90,6 @@ const {
const stageAccess = useProjectStageAccess(projectId, projectContext.stageReadiness)
/** 当前项目是否允许进入形态图片,以及尚未开放的具体原因。 */
const subjectImagesAccess = computed(() => stageAccess.sections.value['subject-images'])
/** 只在两栏上方展示当前生成进度,历史失败在候选弹窗的对应图片卡片内说明。 */
const generationFeedback = computed(() => {
if (!subject.value) return null
if (activeIdentityGeneration.value)
return {
type: 'info' as const,
message: `${subject.value.name} 的身份图片正在生成,刷新页面不会重复提交,请等待当前任务完成。`
}
return null
})
/** 首次读取目录才替换整页,刷新已有主体时保留选择与阅读位置。 */
const initialLoading = computed(() => catalog.loading.value && !catalog.data.value)
/** 切换主体时只替换尚未返回的详情,不遮挡已读取的主体目录。 */
@@ -220,21 +210,42 @@ function exportReceipt() {
downloadText('subject-identities-receipt.json', JSON.stringify(session.value.receipt, null, 2), 'application/json')
}
/** Character 使用确认选角事务;Scene / Prop 保留普通母版切换。 */
/**
* 前置校验通过并开始提交时关闭原主体弹窗,后续状态通过消息反馈。
* @param input 已确认的身份图生成参数
* @returns 提交与详情刷新完成
*/
async function submitIdentityImage(input: Parameters<typeof generateImage>[0]) {
await generateImage(input)
if (!operation.value.error) imageOpen.value = false
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]) {
await generateCastingCandidate(input)
if (!operation.value.error) castingOpen.value = false
const targetId = selectedId.value
await generateCastingCandidate(input, () => {
if (selectedId.value === targetId) castingOpen.value = false
})
}
/** Character 使用确认选角事务;Scene / Prop 保留普通母版切换。 */
/**
* 按主体类型确认母版,成功后关闭原主体的管理弹窗。
* @param imageId 用户明确选择的图片编号
*/
function chooseAnchor(imageId: string) {
if (subject.value?.module === 'character') void confirmCasting(imageId)
else void confirmStableAnchor(imageId)
const targetId = selectedId.value
/** 迟到响应不能关闭另一个主体的弹窗。 */
const closeConfirmedDialog = () => {
if (selectedId.value === targetId) identityGallery.value?.closeCandidates()
}
if (subject.value?.module === 'character') void confirmCasting(imageId, closeConfirmedDialog)
else void confirmStableAnchor(imageId, closeConfirmedDialog)
}
/** 当前主体生图暂不可用时,在失败记录旁说明具体恢复步骤。 */
const imageRetryDisabledReason = computed(() => {
@@ -356,8 +367,9 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
return {
action: 'confirm',
title: '第 3 步:确认并锁定',
description: '在“管理候选”弹窗中确认母版;人物会同时锁定,场景和道具还需保存锁定状态。',
label: '管理候选并确认'
description:
'在下方图片卡片中确认母版;其他图片可通过“管理候选”查看。人物会同时锁定,场景和道具还需保存锁定状态。',
label: '查看候选并确认'
}
return {
action: 'forms',
@@ -374,7 +386,7 @@ function openProfileSettings() {
if (route.query.configure !== 'profile') void router.replace({ query: { ...route.query, configure: 'profile' } })
}
/** 根据当前主体的下一步引导执行操作,形态图片跳转仍遵守项目统一准入规则。 */
/** 下一步引导定位单张图片或打开多候选管理,形态图片跳转遵守项目准入规则。 */
function runNextAction() {
if (nextAction.value.action === 'style') void router.push(`/projects/${projectId.value}/visual-style`)
else if (nextAction.value.action === 'profile') openProfileSettings()
@@ -382,7 +394,7 @@ function runNextAction() {
if (subject.value?.module === 'character') castingOpen.value = true
else imageOpen.value = true
} else if (nextAction.value.action === 'confirm') {
identityGallery.value?.openCandidates()
document.querySelector('#identity-reference-gallery')?.scrollIntoView({ behavior: 'smooth', block: 'center' })
} else if (nextAction.value.action === 'lock') {
document.querySelector('#identity-lock')?.scrollIntoView({ behavior: 'smooth', block: 'center' })
} else if (nextAction.value.action === 'forms' && subjectImagesAccess.value.enabled) {
@@ -720,19 +732,6 @@ function runNextAction() {
</div>
</NAlert>
<div v-if="subjects.length" class="identity-workspace-region">
<!-- 以下是目录与详情上方的全栏生成提示模块,显示和隐藏时平滑收放高度 -->
<Transition name="identity-feedback" appear>
<div v-if="generationFeedback" class="identity-feedback-motion">
<div class="identity-feedback-body workspace-feedback">
<NAlert
:type="generationFeedback.type"
:show-icon="false"
class="identity-generation-feedback text-xs"
>{{ generationFeedback.message }}</NAlert
>
</div>
</div>
</Transition>
<!-- 以下是与分镜一致的融合工作区模块,目录与详情共用外层背景。 -->
<div class="panel workspace-surface directory-workspace identity-workspace">
<!-- 以下是主体目录模块,标题和搜索固定,条目通过独立滚动容器浏览。 -->
@@ -900,7 +899,7 @@ function runNextAction() {
@anchor="chooseAnchor"
@regenerate="retryIdentityImage"
>
<!-- 以下是母版卡片底部的生成入口模块,候选在独立弹窗中管理 -->
<!-- 以下是母版卡片底部的生成入口模块,单张候选直接展示,多张候选在弹窗中管理 -->
<template #actions>
<NButton
v-if="subject.module === 'scene' || subject.module === 'prop'"
@@ -1034,40 +1033,10 @@ function runNextAction() {
.identity-prerequisite {
@apply shrink-0 mx-0 mb-3;
}
/* 全栏提示与双栏工作区共用外层宽度,提示的间距随自身高度一起收放。 */
/* 目录与详情占满工作区,图片生成状态统一由图库展示。 */
.identity-workspace-region {
@apply flex flex-col flex-1 min-h-0 overflow-hidden;
}
.identity-feedback-motion {
display: grid;
grid-template-rows: 1fr;
flex-shrink: 0;
}
.identity-feedback-body {
min-height: 0;
overflow: hidden;
}
.identity-generation-feedback {
margin-bottom: var(--app-content-gap);
}
/* 使用自然内容高度适配手机长文案,避免出现和消失时直接挤动目录与详情。 */
.identity-feedback-enter-active,
.identity-feedback-leave-active {
transition:
grid-template-rows 240ms cubic-bezier(0.25, 1, 0.5, 1),
opacity 180ms ease;
}
.identity-feedback-enter-from,
.identity-feedback-leave-to {
grid-template-rows: 0fr;
opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
.identity-feedback-enter-active,
.identity-feedback-leave-active {
transition: none;
}
}
.identity-flow {
/* 步骤、下一步说明与上下方标题和字段共用面板边界,避免二次缩进。 */
@apply mt-5;
+6 -1
View File
@@ -1,6 +1,7 @@
import { request } from '../../lib/http'
import type {
IdentityImagePreview,
IdentityImageGenerationStart,
IdentityValidationResult,
StableAnchorQualityInput,
StableAnchorQualityResult,
@@ -74,7 +75,11 @@ export const subjectIdentityApi = {
listImages: (subjectId: string, signal?: AbortSignal) =>
request<IdentityImage[]>(`${identityPath(subjectId)}/images`, { signal }),
generateImage: (subjectId: string, input: GenerateIdentityImageInput) =>
request<IdentityImage>(`${identityPath(subjectId)}/images`, { method: 'POST', body: input, timeoutMs: 0 }),
request<IdentityImageGenerationStart>(`${identityPath(subjectId)}/images`, {
method: 'POST',
body: input,
timeoutMs: 0
}),
/**
* 读取与实际生图同源的输入预览,道具可能执行已确认的结构模型编译。
* @param subjectId 正式主体 ID
@@ -1,13 +1,14 @@
<script setup lang="ts">
import { NButton, NTag } from 'naive-ui'
import { LoaderCircle } from '@lucide/vue'
import { computed, ref, watch } from 'vue'
import { AppDialog } from '../../../components/ui'
import { candidateDialogWidth } from '../../../lib/candidate-layout'
import { canBeAnchor, currentAnchor } from '../model'
import { currentAnchor } from '../model'
import type { IdentityImage, IdentityImageOperation } from '../types'
import IdentityImageCard from './IdentityImageCard.vue'
/** 身份图片主区域只展示正式母版,候选与辅助图在弹窗中管理。 */
/** 身份图片主区域展示正式母版与单张候选,多张候选和辅助图使用管理弹窗。 */
const props = defineProps<{
/** 后端正式身份图片列表。 */
images: IdentityImage[]
@@ -35,14 +36,27 @@ const emit = defineEmits<{
}>()
/** 母版仅认后端正式标记,不用首张候选填补空状态。 */
const anchor = computed(() => currentAnchor(props.images))
/** 其余 primary、辅助视图与未完成记录集中在管理弹窗。 */
/** 除正式母版外的候选、辅助视图与未完成记录。 */
const candidates = computed(() => props.images.filter(image => image.id !== anchor.value?.id))
/** 只有已完成的 primary 候选才可引导用户确认母版。 */
const hasPrimaryCandidate = computed(() => candidates.value.some(canBeAnchor))
/** 当前主体正在排队或生成的图片数量,候选数量不影响进度展示。 */
const generatingCount = computed(
() => props.images.filter(image => image.status === 'pending' || image.status === 'generating').length
)
/** 主内容优先展示正式母版、成功候选、生成中记录,最后回退到失败记录。 */
const displayImage = computed(
() =>
anchor.value ??
candidates.value.find(image => image.status === 'completed' && !!image.imageUrl) ??
candidates.value.find(image => image.status === 'pending' || image.status === 'generating') ??
candidates.value[0] ??
null
)
/** 弹窗仅展示主内容之外的记录,避免同一图片和操作重复出现。 */
const managedCandidates = computed(() => props.images.filter(image => image.id !== displayImage.value?.id))
/** 候选管理弹窗开关。 */
const candidatesOpen = ref(false)
/** 候选弹窗按固定卡片宽度适配列数,并由公共弹窗限制视口宽度。 */
const candidatesWidth = computed(() => candidateDialogWidth(candidates.value.length))
const candidatesWidth = computed(() => candidateDialogWidth(managedCandidates.value.length))
/** 母版卡片说明与身份锁定状态一致。 */
const anchorDescription = computed(() =>
props.identityLocked ? '后续形态图片会使用此母版。' : '请先锁定身份,后续形态图片才会稳定引用此母版。'
@@ -54,9 +68,16 @@ watch(
candidatesOpen.value = false
}
)
/** 为步骤引导提供候选入口,打开弹窗只读取已有图片。 */
/** 没有剩余候选时关闭管理弹窗,主内容始终保留当前卡片。 */
watch(
() => managedCandidates.value.length,
count => {
if (count === 0) candidatesOpen.value = false
}
)
/** 为步骤引导提供多候选管理入口,单张候选直接在页面内操作。 */
function openCandidates() {
if (candidates.value.length) candidatesOpen.value = true
if (managedCandidates.value.length) candidatesOpen.value = true
}
/**
* 关闭候选弹窗后打开原图片类型的参数设置,避免多个生成弹窗重叠。
@@ -66,54 +87,70 @@ function regenerate(imageId: string) {
candidatesOpen.value = false
emit('regenerate', imageId)
}
/** 暴露只读管理入口供主体身份步骤引导复用。 */
defineExpose({ openCandidates })
/** 后端确认母版成功后立即收起管理弹窗,不等待列表刷新。 */
function closeCandidates() {
candidatesOpen.value = false
}
/** 暴露候选浏览与提交成功关闭入口。 */
defineExpose({ openCandidates, closeCandidates })
</script>
<template>
<section class="identity-gallery mt-5 pt-5" aria-label="身份参考图库">
<!-- 以下是正式身份母版模块,主页面不展示候选与重复预览 -->
<!-- 以下是正式身份母版模块,仅展示后端正式确认的母版 -->
<div class="identity-gallery-toolbar">
<h3 class="text-sm font-medium">身份母版</h3>
<NTag v-if="!anchor" size="small" :bordered="false">尚无母版</NTag>
</div>
<div v-if="anchor" class="identity-anchor-grid mt-4">
<p v-if="!displayImage" class="mt-4 text-xs leading-6 text-muted">
尚无身份图片。先保存身份文本,再生成母版候选。
</p>
<!-- 以下是图库内持续展示的生成状态,完成或失败后随真实任务状态移除 -->
<p
v-if="generatingCount"
role="status"
aria-live="polite"
class="mt-4 flex items-center gap-2 text-xs leading-6 text-muted"
>
<LoaderCircle :size="16" class="animate-spin motion-reduce:animate-none" aria-hidden="true" />
正在生成中<span v-if="generatingCount > 1">({{ generatingCount }} 张)</span>,完成后会自动更新图片。
</p>
<!-- 以下是当前图片与生成、确认或失败状态模块,不经过候选管理弹窗 -->
<div v-if="displayImage" class="identity-anchor-grid mt-4">
<IdentityImageCard
:image="anchor"
:key="displayImage.id"
:image="displayImage"
:subject-name="subjectName"
:module="module"
:identity-locked="identityLocked"
:disabled="disabled"
:pending-operation="pendingOperation"
:description="anchorDescription"
:retry-disabled-reason="retryDisabledReason"
:active="true"
:description="displayImage.isAnchor ? anchorDescription : undefined"
@anchor="emit('anchor', $event)"
@validate="emit('validate', $event)"
@regenerate="regenerate"
/>
</div>
<p v-else class="mt-4 text-xs leading-6 text-muted">
{{
hasPrimaryCandidate
? '尚未确认身份母版。请在“管理候选”中选择已完成的母版候选并确认。'
: candidates.length
? '尚无可确认的母版候选。请生成母版候选,已有图片可在“管理候选”中查看。'
: '尚无身份母版。先保存身份文本,再生成母版候选。'
}}
</p>
<!-- 以下是与镜头生产一致的底部图片操作模块 -->
<div class="identity-gallery-actions">
<NButton v-if="candidates.length" @click="openCandidates">管理候选({{ candidates.length }})</NButton>
<NButton v-if="managedCandidates.length" @click="openCandidates"
>管理候选({{ managedCandidates.length }})</NButton
>
<slot name="actions" />
</div>
<!-- 以下是候选与辅助图片管理弹窗模块,确认和校验始终针对具体图片 -->
<AppDialog
v-if="managedCandidates.length"
v-model:open="candidatesOpen"
title="身份候选管理"
:description="`${subjectName} 的候选与辅助参考图;确认母版后,主页面会展示新母版。辅助参考图不能设为母版。`"
:description="`${subjectName} 的其他候选与辅助参考图;已在主页面展示的图片不重复列出。辅助参考图不能设为母版。`"
:width="candidatesWidth"
>
<div class="identity-candidate-grid">
<IdentityImageCard
v-for="image in candidates"
v-for="image in managedCandidates"
:key="image.id"
:image="image"
:subject-name="subjectName"
@@ -62,9 +62,11 @@ const canSelect = computed(
/** 卡片标识区分身份母版、母版候选和辅助视角,不重复强调当前状态。 */
const imageLabel = computed(() =>
props.image.isAnchor
? '身份母版'
? '已确认母版'
: props.image.viewType === 'primary'
? '母版候选'
? props.image.status === 'completed'
? '母版候选 · 未确认'
: '母版候选'
: identityViewLabels[props.image.viewType]
)
/** 后台重启表示原请求结果未知,不能误导用户直接调整模型参数。 */
@@ -1,4 +1,5 @@
<script setup lang="ts">
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'
@@ -96,13 +97,21 @@ watch(
{ immediate: true }
)
/** 道具由后端加入结构参考图;其它主体显式或自动引用母版时也按图生图约束。 */
const usesReferenceImages = computed(() => props.module === 'prop' || !!referenceImageId.value || !!anchor.value)
/** 当前流程可用的模型参数,避免选择 Qwen 不支持的扩写模式。 */
const compatibleCatalog = computed(() => referenceGenerationCatalog(props.catalog, usesReferenceImages.value))
/** 控件、预览与提交共享同一份兼容参数。 */
const compatibleOptions = computed(() =>
referenceGenerationOptions(provider.value, generationOptions.value, usesReferenceImages.value)
)
/** 预览与正式生图共享的最终请求参数。 */
const generationInput = computed<GenerateIdentityImageInput>(() => ({
viewType: props.module === 'character' ? viewType.value : 'primary',
...(referenceImageId.value ? { referenceImageId: referenceImageId.value } : {}),
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
provider: provider.value,
generationOptions: { ...generationOptions.value }
generationOptions: { ...compatibleOptions.value }
}))
/** 当前参数的预览结果。 */
const preview = ref<IdentityImagePreview | null>(null)
@@ -198,7 +207,13 @@ const rules = {
调用 图片模型,每次新增一张图片,可能产生费用。第一张成功的 primary 图自动成为母版;已有母版时,新
primary 图仅作为停用候选保留。
</NAlert>
<NFormItem class="block" path="viewType" label="参考视角" :label-props="{ for: 'identity-view' }"
<!-- 以下是多视角与已有身份图选择模块,单一选项不显示选择器 -->
<NFormItem
v-if="allowedViews.length > 1"
class="block"
path="viewType"
label="参考视角"
:label-props="{ for: 'identity-view' }"
><NSelect
id="identity-view"
v-model:value="viewType"
@@ -207,6 +222,7 @@ const rules = {
></NSelect
></NFormItem>
<NFormItem
v-if="references.length"
class="block"
path="referenceImageId"
label="身份锚定来源"
@@ -223,7 +239,7 @@ const rules = {
v-model:value="referenceImageId"
:options="[
{
label: String(anchor ? '自动引用当前身份母版' : '自动选择(当前无母版,将按文本生成)'),
label: String(anchor ? '自动引用当前身份母版' : '自动选择(由后端解析参考图)'),
value: ''
},
...references.map(image => ({
@@ -253,9 +269,9 @@ const rules = {
</p>
<GenerationModelControls
type="image"
:catalog="catalog"
:catalog="compatibleCatalog"
:provider="provider"
:options="generationOptions"
:options="compatibleOptions"
:aspect-ratio="profile.aspectRatio"
:disabled="disabled"
@update:provider="provider = $event"
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { referenceGenerationCatalog, referenceGenerationOptions } from '../reference-generation'
import { computed, ref, watch } from 'vue'
import { NAlert, NButton, NCheckbox, NInputNumber } from 'naive-ui'
import { AppDialog } from '../../../components/ui'
@@ -27,6 +28,10 @@ const emit = defineEmits<{ generate: [input: StableAnchorQualityInput] }>()
const provider = ref('')
/** 本次图片参数。 */
const options = ref<GenerationOptions>({})
/** 稳定母版质量流程可能使用结构图或修复参考图,统一使用兼容模式。 */
const compatibleCatalog = computed(() => referenceGenerationCatalog(props.catalog, true))
/** 展示和提交的参数一致,不继承项目中不兼容的 agent 模式。 */
const compatibleOptions = computed(() => referenceGenerationOptions(provider.value, options.value, true))
/** 最多修复次数。 */
const maxRepairAttempts = ref(0)
/** 明确费用确认。 */
@@ -68,7 +73,7 @@ function submit() {
if (props.disabled || !valid.value || !acknowledged.value) return
emit('generate', {
provider: provider.value,
generationOptions: { ...options.value },
generationOptions: { ...compatibleOptions.value },
maxRepairAttempts: maxRepairAttempts.value
})
open.value = false
@@ -86,9 +91,9 @@ function submit() {
>
<GenerationModelControls
type="image"
:catalog="catalog"
:catalog="compatibleCatalog"
:provider="provider"
:options="options"
:options="compatibleOptions"
:aspect-ratio="profile.aspectRatio"
:disabled="disabled"
@update:provider="provider = $event"
@@ -0,0 +1,47 @@
import type { GenerationModelCatalog, GenerationOptions } from '../generation-config/types'
/**
* 按参考图链路约束 Qwen 参数,不修改项目默认配置。
* @param provider 当前图片供应方
* @param options 本次生成参数
* @param hasReference 是否可能使用结构、身份或修复参考图
* @returns 与参考图兼容的独立参数
*/
export function referenceGenerationOptions(provider: string, options: GenerationOptions, hasReference: boolean) {
return provider === 'qwen-image' && hasReference ? { ...options, promptExtendMode: 'direct' } : { ...options }
}
/**
* 参考图流程只提供 Qwen 支持的扩写模式,切换模型时也使用兼容默认值。
* @param catalog 后端模型目录
* @param hasReference 当前流程是否可能携带参考图
* @returns 当前流程专用目录
*/
export function referenceGenerationCatalog(
catalog: GenerationModelCatalog,
hasReference: boolean
): GenerationModelCatalog {
if (!hasReference) return catalog
return {
...catalog,
images: catalog.images.map(model =>
model.provider !== 'qwen-image'
? model
: {
...model,
defaults: referenceGenerationOptions(model.provider, model.defaults, true),
generationOptions: model.generationOptions.map(option =>
option.key !== 'promptExtendMode'
? option
: {
...option,
options: option.options?.filter(choice => choice.value === 'direct'),
providerDefault: 'direct',
userEditable: false,
description: '此流程可能使用结构或身份参考图,Qwen 图生图仅支持直接增强。'
}
)
}
)
}
}
+8
View File
@@ -33,6 +33,14 @@ export interface IdentityImage {
updatedAt: string
}
/** 普通身份生图接口的异步提交回执,图片记录位于 image 字段。 */
export interface IdentityImageGenerationStart {
/** 已持久化的后台任务编号。 */
executionId: string
/** 本次创建的图片记录,用于立即显示生成状态。 */
image: IdentityImage
}
/** 稳定身份描述及生图提示词,不混入具体形态的临时状态。 */
export interface SubjectIdentity {
id: string
@@ -1,4 +1,4 @@
import { computed, ref, watch } from 'vue'
import { computed, ref, shallowRef, watch } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { visualStyleApi } from '../visual-style'
import { useProjectGenerationRevision } from '../generation-config/context'
@@ -95,11 +95,13 @@ export function useSubjectIdentity() {
)
const subject = computed(() => subjects.value.find(item => item.id === selectedId.value))
const selectionKey = computed(() => subject.value?.id ?? '')
const detailRef = {} as {
current?: ReturnType<typeof usePolling<{ identity: SubjectIdentity | null; images: IdentityImage[] }>>
}
/** 延后关联详情查询,使用响应式引用让任务轮询在查询建立后重新计算。 */
const detailRef = shallowRef<ReturnType<
typeof usePolling<{ identity: SubjectIdentity | null; images: IdentityImage[] }>
> | null>(null)
/** 仅当前主体存在未结束图片时轮询,终态后停止。 */
const detailPollInterval = computed(() =>
detailRef.current?.data.value?.images.some(image => image.status === 'pending' || image.status === 'generating')
detailRef.value?.data.value?.images.some(image => image.status === 'pending' || image.status === 'generating')
? 4000
: false
)
@@ -116,7 +118,23 @@ export function useSubjectIdentity() {
},
detailPollInterval
)
detailRef.current = detail
detailRef.value = detail
/** 图片从生成中进入终态后同步母版、目录、选角和阶段准入,切换主体不消费旧结果。 */
watch(detail.data, (current, previous) => {
if (!current?.identity || !previous?.identity || current.identity.id !== previous.identity.id) return
if (current.identity.subjectId !== selectedId.value) return
const runningIds = new Set(
previous.images
.filter(image => image.status === 'pending' || image.status === 'generating')
.map(image => image.id)
)
if (
current.images.some(
image => runningIds.has(image.id) && (image.status === 'completed' || image.status === 'failed')
)
)
void refreshImageConfirmation(projectId.value, selectedId.value)
})
const identity = computed(() => detail.data.value?.identity ?? null)
const images = computed(() => detail.data.value?.images ?? [])
const castingItem = computed(() =>
@@ -433,8 +451,9 @@ export function useSubjectIdentity() {
/**
* 生图不修改文字锁定;即使有自定义提示词,也需已有身份提示词与项目风格。
* @param input 已确认的视图、模型与参考图片参数
* @param onSubmitStarted 通过前置检查并开始提交时的回调
*/
async function generateImage(input: GenerateIdentityImageInput) {
async function generateImage(input: GenerateIdentityImageInput, onSubmitStarted?: () => void) {
if (!canGenerateImage.value || !subject.value || !identity.value) return
if (
input.referenceImageId &&
@@ -451,11 +470,27 @@ export function useSubjectIdentity() {
project,
`提交 ${name} 身份参考图生成`,
async () => {
const image = await subjectIdentityApi.generateImage(id, input)
if (!image || image.identityId !== identityId || !['pending', 'generating'].includes(image.status)) {
onSubmitStarted?.()
const started = await subjectIdentityApi.generateImage(id, input)
const image = started?.image
if (
!started?.executionId ||
!image ||
image.identityId !== identityId ||
!['pending', 'generating'].includes(image.status)
) {
throw new Error(image?.error || '身份参考图任务未成功创建,请刷新后重试。')
}
if (projectId.value === project && selectedId.value === id) await detail.refresh()
if (projectId.value === project && selectedId.value === id) {
// 先展示真实回执中的生成记录,后续读取失败也能保留状态并继续轮询。
const current = detail.data.value
if (current?.identity?.id === identityId)
detail.data.value = {
...current,
images: [image, ...current.images.filter(item => item.id !== image.id)]
}
await detail.refresh()
}
},
{ type: 'info', content: `${name} 的身份参考图已提交生成,完成后会显示结果。` }
)
@@ -464,8 +499,9 @@ export function useSubjectIdentity() {
/**
* 单角色候选图固定独立生成,不复用旧母版,生成成功后仍需人工确认选角。
* @param input 已确认的候选图模型与生成参数
* @param onSubmitStarted 通过前置检查并开始提交时的回调
*/
async function generateCastingCandidate(input: GenerateCastingCandidateInput) {
async function generateCastingCandidate(input: GenerateCastingCandidateInput, onSubmitStarted?: () => void) {
if (!canGenerateCandidate.value || !subject.value || !identity.value) return
const id = subject.value.id
const identityId = identity.value.id
@@ -475,6 +511,7 @@ export function useSubjectIdentity() {
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 || '选角候选任务未成功创建,请刷新后重试。')
@@ -524,8 +561,9 @@ export function useSubjectIdentity() {
/**
* 场景或道具人工确认母版时原子完成母版切换与身份锁定。
* @param imageId 要确认的正式身份图片编号
* @param onConfirmed 后端确认成功后的回调,不等待关联数据刷新
*/
async function confirmStableAnchor(imageId: string) {
async function confirmStableAnchor(imageId: string, onConfirmed?: () => void) {
const image = images.value.find(item => item.id === imageId)
if (
detailBlocked.value ||
@@ -556,6 +594,7 @@ export function useSubjectIdentity() {
!canBeAnchor(result.anchor)
)
throw new Error('身份母版确认结果未保存,请刷新后核对。')
onConfirmed?.()
await refreshImageConfirmation(project, subjectId)
},
{ type: 'success', content: `${name} 的身份母版已确认并锁定。` }
@@ -565,8 +604,9 @@ export function useSubjectIdentity() {
/**
* 角色确认选角必须原子切换身份母版并锁定身份。
* @param imageId 要确认的正式角色图片编号
* @param onConfirmed 后端确认成功后的回调,不等待关联数据刷新
*/
async function confirmCasting(imageId: string) {
async function confirmCasting(imageId: string, onConfirmed?: () => void) {
const image = images.value.find(item => item.id === imageId)
if (
detailBlocked.value ||
@@ -598,6 +638,7 @@ export function useSubjectIdentity() {
!canBeAnchor(result.anchor)
)
throw new Error('角色选角确认结果未保存,请刷新后核对。')
onConfirmed?.()
await refreshImageConfirmation(project, subjectId)
},
{ type: 'success', content: `${name} 的角色选角已确认,身份已锁定。` }
@@ -14,7 +14,7 @@ import { AssetImage, EmptyState, StatusBadge } from '../../components/ui'
import { downloadText } from '../../lib/format'
import ConfirmAction from '../workflows/ConfirmAction.vue'
import { useSubjectImages } from './useSubjectImages'
import { hasRunningImages, primaryImage } from './model'
import { hasRunningImages, primaryImage, isIdentityAnchorReuse } from './model'
import type { GenerateFormImageInput, SubjectFormAsset } from './types'
import GenerateImageDialog from './components/GenerateImageDialog.vue'
import ImageGalleryDialog from './components/ImageGalleryDialog.vue'
@@ -321,7 +321,7 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
/></RouterLink>
</div>
<DetailDisclosure title="母版继承与过期处理" class="mt-4">
人物、场景、道具形态图都会继承已锁定的主体母版。母版变化后,旧主图会自动标记为需要更新;候选图只有明确设为主参考图后才会供分镜使用。
人物、场景、道具的基础形态默认复用已确认并锁定的身份母版,无需再次生图。其他形态仍需单独生成。自动复用的主图随母版更新;你手选或独立生成的主图保留,母版变化后需要核对。
<RouterLink :to="`/projects/${id}/subject-identity`" class="text-button ml-2"
>管理主体身份 →</RouterLink
></DetailDisclosure
@@ -358,7 +358,7 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
</p>
</div>
<p class="mt-2 text-[11px] leading-6 text-muted">
图库在进入和操作完成后读取最新记录。主图供分镜引用,候选图和历史失败记录均保留;过期主图不会自动删除或替换。
图库在进入和操作完成后读取最新记录。基础形态会自动复用已锁定身份母版,主图可直接供分镜引用;独立候选与历史失败记录均保留。
</p>
<section class="mt-4 pt-4">
<h3 class="text-sm font-semibold">项目批量生图</h3>
@@ -699,7 +699,9 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
? '后台正在生成图片'
: form.images.some(image => image.status === 'completed' && image.imageUrl)
? '已有候选图,请确认主参考图'
: '尚未生成主参考图'
: form.isDefault
? '确认并锁定身份母版后自动复用'
: '尚未生成主参考图'
"
/>
<div class="p-4">
@@ -716,7 +718,9 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
</p>
<div class="mt-3 flex flex-wrap items-center gap-2">
<StatusBadge v-if="hasRunningImages(form.images)" status="generating" />
<NTag v-else-if="primaryImage(form.images)" size="small" :bordered="false">主参考图</NTag>
<NTag v-else-if="primaryImage(form.images)" size="small" :bordered="false">{{
isIdentityAnchorReuse(primaryImage(form.images)) ? '复用身份母版' : '主参考图'
}}</NTag>
<NTag
v-else-if="form.images.some(image => image.status === 'completed' && image.imageUrl)"
size="small"
@@ -772,9 +776,11 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
<NButton :disabled="blocked || hasRunningImages(form.images)" @click="openGenerate(form)"
><ImagePlus :size="14" />
{{
form.images.some(image => image.status === 'completed' && image.imageUrl)
? '再生成一张'
: '生成图片'
isIdentityAnchorReuse(primaryImage(form.images))
? '重新生成'
: form.images.some(image => image.status === 'completed' && image.imageUrl)
? '再生成一张'
: '生成图片'
}}</NButton
>
</div>
@@ -30,18 +30,14 @@ const preview = ref<SubjectImageGenerationPreview | null>(null)
const previewError = ref('')
const previewPending = ref(false)
/** 预览与当前形态、提示词及模型配置绑定,避免显示过期结果。 */
const previewKey = computed(() => JSON.stringify([
props.form?.id,
prompt.value,
provider.value,
generationOptions.value
]))
const previewKey = computed(() =>
JSON.stringify([props.form?.id, prompt.value, provider.value, generationOptions.value])
)
watch(previewKey, () => {
preview.value = null
previewError.value = ''
})
/** 每次打开重新建立表单,避免把另一形态的 Prompt 或尺寸带入请求。 */
watch(
() => [open.value, props.form?.id],
@@ -133,8 +129,7 @@ const rules = {}
>使用后端配置的图片模型,可能产生费用。每次新增一张图片,不删除历史结果。</NAlert
>
<p class="text-xs leading-6 text-muted">
人物、场景、道具均会引用已锁定身份的当前母版,保持身份、空间骨架或物件结构;身份未锁定或没有母版时不会继承该图片。更换母版不会自动更新已有形态图。
身份母版与此处的“形态主参考图”是两种不同用途的图片。
基础形态默认复用已确认并锁定的身份母版,无需重复生成。此处会调用图片模型新增独立候选,用于不同形态或需要调整外观的情况;是否替换主图由下方选项决定。
</p>
<div class="flex flex-wrap items-center gap-3">
<NButton :loading="previewPending" :disabled="!form" @click="loadPreview">预览实际生成输入</NButton>
@@ -8,7 +8,7 @@ import { referenceImageUrl } from '../../../lib/assets'
import { formatDate } from '../../../lib/format'
import { getOperation, runOperation } from '../../workflows/operations'
import { subjectImagesApi } from '../api'
import { hasRunningImages, primaryImage, currentIdentityAnchorId } from '../model'
import { hasRunningImages, primaryImage, currentIdentityAnchorId, isIdentityAnchorReuse } from '../model'
import type { SubjectFormAsset } from '../types'
/** 形态图片历史与主图选择;历史查询只在弹窗打开时进行。 */
@@ -29,6 +29,15 @@ const selected = computed(
() => images.value.find(image => image.id === selectedId.value) ?? primaryImage(images.value) ?? images.value[0]
)
const operation = computed(() => getOperation(props.projectId))
/** 历史复用图失去当前母版或基础形态条件时只供查看,不能重新设为主图。 */
const reusedImageUnavailable = computed(
() =>
isIdentityAnchorReuse(selected.value) &&
(!props.form?.isDefault ||
!props.form.subject.identity?.isLocked ||
selected.value?.identityAnchorImageId !== currentIdentityAnchorId(props.form))
)
/** 当前图片与形态满足正式主图选择条件时才开放确认。 */
const canSetPrimary = computed(
() =>
!props.disabled &&
@@ -37,7 +46,8 @@ const canSetPrimary = computed(
!hasRunningImages(images.value) &&
selected.value?.status === 'completed' &&
!!selected.value.imageUrl &&
!selected.value.isPrimary
!selected.value.isPrimary &&
!reusedImageUnavailable.value
)
const imageUrl = computed(() => (selected.value?.imageUrl ? referenceImageUrl(selected.value.imageUrl) : null))
watch(key, () => {
@@ -133,21 +143,22 @@ async function choosePrimary() {
]
"
/><span class="image-history-label">{{
image.isPrimary
? '主参考图'
: { completed: '候选图', failed: '失败记录', pending: '排队中', generating: '生成中' }[
image.status
]
isIdentityAnchorReuse(image)
? '复用身份母版'
: image.isPrimary
? '主参考图'
: { completed: '候选图', failed: '失败记录', pending: '排队中', generating: '生成中' }[
image.status
]
}}</span></NButton
>
</NScrollbar>
<div class="mt-4 flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-2">
<StatusBadge :status="selected.status" /><NTag
v-if="selected.isPrimary"
size="small"
:bordered="false"
>当前主参考图</NTag
<StatusBadge :status="selected.status" />
<!-- 以下是形态图片的真实来源模块 -->
<NTag v-if="isIdentityAnchorReuse(selected)" size="small" :bordered="false">复用身份母版</NTag>
<NTag v-if="selected.isPrimary" size="small" :bordered="false">当前主参考图</NTag
><span class="text-xs text-muted">{{ selected.width || '—' }} × {{ selected.height || '—' }}</span>
</div>
<a
@@ -174,6 +185,10 @@ async function choosePrimary() {
>{{ selected.provider }} · {{ selected.model }} · {{ formatDate(selected.createdAt) }}</span
>
</div>
<!-- 以下是失效复用历史的说明模块 -->
<p v-if="reusedImageUnavailable" class="mt-3 text-xs text-muted">
此图片复用的身份母版已变更,或当前形态不再满足复用条件,仅保留作历史查看。
</p>
<NAlert v-if="confirming" type="info" :show-icon="false" class="mt-3"
><p class="text-xs">确认将这张图用于此形态后续的分镜参考?旧主图仍会保留,此操作不调用模型。</p>
<div class="mt-3 flex gap-3">
+9
View File
@@ -14,6 +14,15 @@ export function primaryImage(images: SubjectImage[]): SubjectImage | undefined {
return images.find(image => image.isPrimary && image.status === 'completed')
}
/**
* 判断后端正式图片是否直接复用了身份母版。
* @param image 正式形态图片或空值
* @returns 是否展示复用来源标识
*/
export function isIdentityAnchorReuse(image: SubjectImage | null | undefined): boolean {
return image?.source === 'identity-anchor'
}
/** 列表优先展示主图,否则展示最新成功候选图;失败记录不会遮住可用图片。 */
export function coverImage(form: SubjectFormAsset): SubjectImage | undefined {
return primaryImage(form.images) ?? form.images.find(image => image.status === 'completed' && image.imageUrl)
+4
View File
@@ -3,6 +3,10 @@ export type SubjectImageStatus = 'pending' | 'generating' | 'completed' | 'faile
/** 图库列表返回的图片元数据;正式图片 ID 与形态 ID 均来自数据库。 */
export interface SubjectImage {
/** 图片来源;旧后端未提供时按独立生成处理。 */
source?: 'generated' | 'identity-anchor'
/** 生成或复用时记录的身份母版编号。 */
identityAnchorImageId?: string | null
id: string
subjectFormId: string
provider: string
@@ -6,10 +6,23 @@ import { formatDate } from '../../lib/format'
import { executionPercentage, executionStageLabel } from './execution'
import type { WorkflowExecution } from './execution.types'
/** 后台任务面板的展示数据与加载状态。 */
const props = withDefaults(
defineProps<{ title?: string; execution: WorkflowExecution | null; loading: boolean; error: string }>(),
{ title: '制作任务' }
defineProps<{
/** 任务标题。 */
title?: string
/** 后端任务记录。 */
execution: WorkflowExecution | null
/** 是否正在读取状态。 */
loading: boolean
/** 状态读取错误。 */
error: string
/** 是否展示运行与完成说明,已有消息及详细快照的页面可关闭。 */
showStatusHint?: boolean
}>(),
{ title: '制作任务', showStatusHint: true }
)
/** 刷新状态与隐藏任务记录事件。 */
const emit = defineEmits<{ refresh: []; dismiss: [] }>()
const percentage = computed(() => executionPercentage(props.execution?.current ?? 0, props.execution?.total ?? 0))
const result = computed(() => props.execution?.result ?? {})
@@ -21,6 +34,8 @@ const statusType = computed(() =>
props.execution?.status === 'completed' ? 'success' : props.execution?.status === 'failed' ? 'error' : 'warning'
)
const finished = computed(() => ['completed', 'failed'].includes(props.execution?.status ?? ''))
/** 是否为剧本创作任务,避免使用镜头素材的提示文案。 */
const scriptCreation = computed(() => props.execution?.workflowName === 'create-drama')
const videoQuality = computed(() => props.execution?.workflowName === 'video-quality')
/** 首帧质量后台任务使用独立的通过与修复失败统计,不套用普通生图字段。 */
const keyframeQuality = computed(() => props.execution?.workflowName === 'keyframe-quality')
@@ -110,18 +125,20 @@ function isInputMode(value: unknown, inputMode: string): boolean {
/>
<p class="mt-3 text-xs">
<template v-if="execution.total > 0">已处理 {{ execution.current }} / {{ execution.total }}</template>
<template v-else>正在准备本次任务</template>
<template v-if="execution.currentResourceId">
<template v-else>{{
finished ? '本次任务已结束' : scriptCreation ? '正在创作剧本' : '正在准备本次任务'
}}</template>
<template v-if="execution.currentResourceId && !scriptCreation">
· 当前镜头 <code>{{ execution.currentResourceId }}</code></template
>
</p>
<NAlert v-if="execution.status === 'running'" type="info" :show-icon="false" class="mt-3">
<NAlert v-if="execution.status === 'running' && showStatusHint" type="info" :show-icon="false" class="mt-3">
{{
videoQuality ? '系统会继续生成、检查并按需修复。' : '系统会继续处理剩余内容并保存已完成结果。'
}}可以离开或刷新页面,返回后会继续显示本次任务进度,请勿重复提交。
</NAlert>
<NAlert
v-else-if="execution.status === 'completed'"
v-else-if="execution.status === 'completed' && showStatusHint"
:type="
keyframeQuality && (!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
? 'warning'
@@ -130,7 +147,13 @@ function isInputMode(value: unknown, inputMode: string): boolean {
:show-icon="false"
class="mt-3"
>
<p>本轮任务已结束,页面正在重新读取镜头资产状态。</p>
<p>
{{
scriptCreation
? '剧本创作任务已结束,页面正在重新读取剧本内容。'
: '本轮任务已结束,页面正在重新读取镜头资产状态。'
}}
</p>
<p v-if="videoQuality" class="mt-2 text-xs">
目标 {{ result.targetCount ?? execution.total }} · 通过 {{ result.passed ?? 0 }} · 修复耗尽
{{ result.exhausted ?? 0 }} · 模型失败 {{ result.providerFailed ?? 0 }} · 提交失败
@@ -147,7 +170,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
>
<template v-else>后端首帧质量统计不完整,请查看任务详情并刷新核对。</template>
</p>
<p v-else-if="!videoQuality" class="mt-2 text-xs">
<p v-else-if="!videoQuality && !scriptCreation" class="mt-2 text-xs">
共 {{ result.total ?? execution.total }} · 生成 {{ result.generated ?? execution.current }} · 跳过
{{ result.skipped ?? 0 }} · 阻塞 {{ result.blocked ?? 0 }} · 失败 {{ result.failed ?? 0 }}
</p>
@@ -155,7 +178,11 @@ function isInputMode(value: unknown, inputMode: string): boolean {
<NAlert v-else-if="execution.status === 'failed'" type="error" :show-icon="false" class="mt-3">
<p>{{ execution.error || '制作任务执行失败。' }}</p>
<p class="mt-2 text-xs">
请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。
{{
scriptCreation
? '请先核对已保存的剧本内容,处理报错原因后从当前阶段恢复生成或改写。'
: '请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。'
}}
</p>
</NAlert>
<details class="mt-3 text-[10px] text-muted">