feat(short-drama-agent-front): 支持母版复用并优化生成交互
This commit is contained in:
1 parent
49fb9c7a27
commit
ee5e49957a
28 files changed
+634
-326
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# 项目协作规范
|
||||
|
||||
## 默认分支与工作目录
|
||||
|
||||
- 新增功能、新增文件、修复问题和重构,默认全部在本项目根目录的 `dev` 分支进行。
|
||||
- 开始修改前先确认当前分支。若不在 `dev`,应保留现有修改并安全切换到 `dev`,不得丢弃或覆盖用户已有工作。
|
||||
- 不创建新的 Git worktree,不在 `worktree`、`worktrees`、`.worktree` 或 `.worktrees` 目录中新增或修改文件。
|
||||
- 不因技能、模板或默认隔离流程而创建工作树;本规则覆盖此前“新功能在 worktree 中开发”的项目约定。
|
||||
- 已有工作树仅在用户要求迁回改动时作为只读来源;迁回后在项目根目录的 `dev` 分支继续修改和验证。
|
||||
- 未经用户明确要求,不提交代码、不推送、不切换或合并到其他发布分支。
|
||||
|
||||
## 开发与验证
|
||||
|
||||
- 尽量使用中文沟通,沿用项目现有的 Vue 3、TypeScript、Tailwind CSS 和 pnpm 约定。
|
||||
- 新增或修改的函数、类型、响应式状态及页面模块需要中文注释;函数有参数或返回值时补充 `@param`、`@returns`。
|
||||
- 超过两个位置使用的相同功能或组件,应抽成公共方法或组件。
|
||||
- 页面和交互验证使用本地 Chrome,地址使用 `localhost`,禁止使用 Playwright;已有对应测试标签页时复用它。
|
||||
- 以真实接口和后端契约为准,不用占位数据或其他功能代替缺失能力。
|
||||
- 提交代码时遵循项目的 Conventional Commits 规范,使用中文描述;提交前先检查实际差异。
|
||||
@@ -0,0 +1,48 @@
|
||||
# 基础形态复用身份母版 Implementation Plan
|
||||
|
||||
**Goal:** 默认形态在满足锁定与母版条件时直接使用身份图片,形态 API、就绪检查和分镜参考图共享同一真实数据。
|
||||
|
||||
**Architecture:** 通过独立 repository 同步复用记录,接入现有形态图库及主图读取入口;用现有 rawJson 记录来源和 anchor 快照,无需数据库迁移。前端展示后端公开的来源字段。
|
||||
|
||||
**Tech Stack:** TypeScript / Prisma SQLite / Vue 3 / Naive UI。
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- 按用户最新要求,功能已迁回前后端项目根目录的 `dev` 分支;后续遵循根目录 `AGENTS.md`,不在工作树中开发,不自动提交。
|
||||
- 不调用生图模型,不复制图片文件;Chrome + localhost 验证。
|
||||
- 新增及修改函数、类型、响应式状态需要中文注释。
|
||||
|
||||
## Task 1: Repository 数据与回归测试
|
||||
|
||||
- [x] 创建隔离 SQLite 回归测试,先通过现有 `subjectFormRepository.listAssetsByProjectId` 验证缺少自动复用,看到预期失败。
|
||||
- [x] 新建 `src/repositories/identity-anchor-form-image.repository.ts`,提供 `sync({ projectId })` / `sync({ subjectFormId })`,事务内复查身份和主图,使用按 form + anchor 确定的记录 ID,防止重复创建。
|
||||
- [x] `subjectFormRepository.listAssetsByProjectId` / `listImageGenerationCandidatesByProjectId`,以及 `subjectImageRepository.listBySubjectFormId` / `findPrimaryBySubjectFormId` 接入同步。
|
||||
- [x] 回归覆盖未锁定不复用、其他形态不复用、人工主图优先、同一请求重复读取无新增、身份母版更换或失效。
|
||||
|
||||
## Task 2: 全流程与 DTO
|
||||
|
||||
- [x] 移除 `subject-image.service.ts` 中批量生成的旧复用分支,普通批量使用统一主图判定跳过;强制生成始终走生成路径。
|
||||
- [x] 公开安全来源字段 `source: 'identity-anchor' | 'generated'` 与 `identityAnchorImageId`,图库与单形态图片 API 共用解析。
|
||||
- [x] 在独立 SQLite 库中验证真实图库 DTO、readiness 跳过、分镜引用与 anchor 快照一致。
|
||||
|
||||
## Task 3: 前端与本地验收
|
||||
|
||||
- [x] `SubjectImage` 增加兼容的可选来源字段;列表和图片详情标注“复用身份母版”。基础形态缺图时说明确认身份母版即可复用。
|
||||
- [x] 保留明确的“重新生成”入口及原有人工主图选择,不在 UI 伪造图片记录。
|
||||
- [x] 类型、定向 lint 与回归测试通过后,以 SQLite 副本启动隔离后端和前端,Chrome 验证已有主图、复用标记及非默认形态仍缺图。
|
||||
|
||||
## Review
|
||||
|
||||
确认迁回没有覆盖既有修改;在前后端 `dev` 验证实际接口和页面,不调用模型、不提交代码。
|
||||
|
||||
## 验证结果
|
||||
|
||||
- 后端全量:9 个文件、99 项测试通过;包含 20 项真实隔离 SQLite 复用回归。
|
||||
- 前端定向:5 个文件、50 项测试通过;类型检查与改动文件静态检查通过。
|
||||
- Chrome:localhost:4314 当前项目副本显示 8 个复用主图与 7 个待准备形态;历史详情显示复用来源,重新生成默认不替换当前主图。
|
||||
- 前端 dev 原有 diff 未变化,后端 dev 保持干净;无代码提交或模型生成。
|
||||
- 验收后端 localhost:3414 只开放 GET,并且不启动任务恢复;使用独立 SQLite 副本。
|
||||
|
||||
## 迁回 dev
|
||||
|
||||
2026-10-12 按用户要求迁回前后端项目根目录的 `dev` 分支。前端原有 15 个修改文件内容保留,追加 8 个功能及说明文件;后端迁入 8 个功能及测试文件。未复制预览数据库、环境配置或依赖目录。上述 worktree 验收记录保留为历史,今后开发以根目录 `AGENTS.md` 为准。
|
||||
@@ -0,0 +1,21 @@
|
||||
# 基础形态复用身份母版
|
||||
|
||||
用户已确认:基础形态默认复用已确认并锁定的身份母版,其他形态继续独立生成,保留重新生成入口,后端与分镜必须识别有效主图。
|
||||
|
||||
## 数据与选择规则
|
||||
|
||||
- 以正式 `SubjectForm.isDefault` 判定基础形态,不根据名称或列表顺序推测。
|
||||
- 锁定身份 + 启用、完成、有地址的 primary 身份图才可复用,适用于人物、场景和道具。
|
||||
- 复用落地为正式 `DramaSubjectImage`,复用现有图片地址而不调用模型或复制物理文件。元数据保留来源与身份母版快照。
|
||||
- 已有独立生成/人工选择的形态主图优先,不自动覆盖。基础形态也可主动生成新候选并选择替换。
|
||||
- 自动复用主图跟随身份母版切换;失去锁定、有效母版或基础形态身份后不再作为主图。旧记录保留。
|
||||
- 读取图库、主图或生产就绪状态时幂等同步已有项目;直接进入分镜也能取到真实形态主图。
|
||||
- `force` 批量生成应真正生成候选,不再被旧的道具复用分支截断。
|
||||
|
||||
## UI
|
||||
|
||||
主图标注“复用身份母版”,保留“重新生成”与历史记录。缺少身份母版的基础形态说明需要先确认并锁定;其他形态保持原生成流程。
|
||||
|
||||
## 验证
|
||||
|
||||
后端使用独立临时 SQLite 库:三类主体、非默认形态、未锁定/候选/失败母版、幂等并发、人工主图保护、换母版、解锁、图库 DTO、就绪与分镜取图。Chrome 在隔离端口查看真实接口返回的副本项目,不提交付费模型任务。初次验收使用隔离数据库副本,不提交代码。按用户最新要求,现已将前后端修改迁回项目根目录的 `dev`,后续不再使用工作树开发。
|
||||
+2
-1
@@ -3,7 +3,8 @@ import tsParser from '@typescript-eslint/parser'
|
||||
|
||||
/** Oxlint 检查脚本,ESLint 仅补充 Vue 模板语义检查,格式统一交给 Oxfmt。 */
|
||||
export default [
|
||||
{ ignores: ['dist/**', 'coverage/**', 'node_modules/**'] },
|
||||
/** 检查仅覆盖当前项目,不递归进入历史隔离工作树。 */
|
||||
{ ignores: ['dist/**', 'coverage/**', 'node_modules/**', '**/.worktrees/**', '**/.worktree/**'] },
|
||||
...pluginVue.configs['flat/essential'],
|
||||
{
|
||||
files: ['**/*.vue'],
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
|
||||
@@ -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 图生图仅支持直接增强。'
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* 按 260px 候选卡片计算弹窗宽度,每行最多五项,并预留列间距和内边距。
|
||||
* 按 260px 候选卡片计算弹窗宽度,每行最多五项,并预留列间距及公共弹窗左右各 20px 内边距。
|
||||
* @param count 当前候选数量
|
||||
* @returns 弹窗期望宽度,单位为像素,实际宽度由公共弹窗适配视口
|
||||
*/
|
||||
export function candidateDialogWidth(count: number): number {
|
||||
const columns = Math.max(1, Math.min(5, count))
|
||||
return columns * 260 + (columns - 1) * 12 + 48
|
||||
return columns * 260 + (columns - 1) * 12 + 40
|
||||
}
|
||||
@@ -428,7 +428,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('关闭设置时错误仍可见,详细校验与恢复在面板内,不挤占结果高度', async () => {
|
||||
it('关闭设置时保留问题入口,详细校验与恢复在面板内,不挤占结果高度', async () => {
|
||||
const record = checkpoint()
|
||||
record.state.workflowExecution!.status = 'failed'
|
||||
record.state.workflowExecution!.errorMessage = '工作流中断'
|
||||
@@ -437,11 +437,10 @@ describe('拆解页内容滚动', () => {
|
||||
issues: [{ episodeNo: 1, message: '缺少形态绑定' }]
|
||||
}
|
||||
mountPage([record])
|
||||
const feedback = wrapper!.get('.workspace-feedback')
|
||||
expect(feedback.text()).toContain('工作流中断')
|
||||
expect(feedback.text()).toContain('分镜校验未通过,共 1 项问题')
|
||||
expect(feedback.find('.breakdown-results-section').exists()).toBe(false)
|
||||
await feedback.get('button').trigger('click')
|
||||
expect(wrapper!.find('.workspace-feedback').exists()).toBe(false)
|
||||
expect(wrapper!.text()).not.toContain('缺少形态绑定')
|
||||
const action = wrapper!.findAll('button').find(item => item.text() === '查看拆解问题')!
|
||||
await action.trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawerPanel().text()).toContain('缺少形态绑定')
|
||||
expect(drawerPanel().text()).toContain('重试失败抽取')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { identityImageFixture } from '@/features/subject-identity/testing/fixtures'
|
||||
import { subjectIdentityApi } from '@/features/subject-identity/api'
|
||||
|
||||
/** 每个契约用例完成后清理网络替身。 */
|
||||
@@ -6,6 +7,22 @@ afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
/** 验证正式身份路由和付费请求没有自动重试。 */
|
||||
describe('身份正式接口契约', () => {
|
||||
it('普通生图保留任务编号和嵌套图片,选角仍使用独立图片回执', async () => {
|
||||
const image = identityImageFixture({ status: 'generating', imageUrl: null, isAnchor: false })
|
||||
const started = { executionId: 'execution-1', image }
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: started }), { status: 202 }))
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: image }), { status: 202 }))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const result = await subjectIdentityApi.generateImage('subject-1', { viewType: 'primary' })
|
||||
expect(result.executionId).toBe('execution-1')
|
||||
expect(result.image.identityId).toBe(image.identityId)
|
||||
expect(result.image.status).toBe('generating')
|
||||
expect(await subjectIdentityApi.generateCastingCandidate('subject-1', {})).toEqual(image)
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('预览与实际生成传递相同参数,并支持取消预览', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
|
||||
@@ -113,7 +113,7 @@ describe('身份图与母版契约', () => {
|
||||
expect(wrapper.emitted('regenerate')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('候选未确认时不填补母版空状态,无图片时不提供管理入口', async () => {
|
||||
it('单张候选直接显示且保持未确认,无图片时不提供管理入口', async () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
@@ -124,14 +124,13 @@ describe('身份图与母版契约', () => {
|
||||
images: [identityImageFixture({ id: 'candidate', isAnchor: false })]
|
||||
}
|
||||
})
|
||||
expect(wrapper.text()).toContain('尚未确认身份母版')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('母版候选 · 未确认')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(true)
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
expect(document.querySelector('[aria-label="身份图片 candidate"]')).not.toBeNull()
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
await wrapper.setProps({ images: [] })
|
||||
expect(wrapper.text()).toContain('尚无身份母版')
|
||||
expect(wrapper.text()).toContain('尚无身份图片')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(false)
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
})
|
||||
@@ -225,7 +224,7 @@ describe('身份图与母版契约', () => {
|
||||
]
|
||||
}
|
||||
})
|
||||
button('管理候选(1)').click()
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
await flushPromises()
|
||||
expect(document.querySelector('[aria-label="身份图片 failed-front"]')!.textContent).not.toContain(
|
||||
'图片模型超时'
|
||||
@@ -363,7 +362,7 @@ describe('身份图与母版契约', () => {
|
||||
viewType: 'three-quarter',
|
||||
referenceImageId: 'identity-image-1',
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' },
|
||||
generationOptions: { size: '2048*2048', promptExtendMode: 'direct' },
|
||||
prompt: '自定义身份提示词'
|
||||
}
|
||||
]
|
||||
@@ -391,7 +390,7 @@ describe('身份图与母版契约', () => {
|
||||
await wrapper.setProps({ images: [] })
|
||||
expect(button('确认生成身份图').disabled).toBe(true)
|
||||
await wrapper.setProps({ subjectId: 's2', subjectName: '陆川' })
|
||||
expect(selectControl(wrapper!, 'id', 'identity-reference').props('value')).toBe('')
|
||||
expect(document.querySelector('#identity-reference')).toBeNull()
|
||||
expect(document.querySelector('#identity-image-cost')!.getAttribute('aria-checked')).toBe('false')
|
||||
})
|
||||
|
||||
@@ -426,7 +425,7 @@ describe('身份图与母版契约', () => {
|
||||
images: [identityImageFixture({ viewType: 'front', isAnchor: false })]
|
||||
}
|
||||
})
|
||||
button('管理候选(1)').click()
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
await flushPromises()
|
||||
const card = wrapper.findAllComponents(IdentityImageCard)[0]!
|
||||
expect(card.findAllComponents(NButton).some(item => item.text() === '确认选角并锁定')).toBe(false)
|
||||
@@ -464,7 +463,7 @@ describe('身份图与母版契约', () => {
|
||||
images: ['first', 'second'].map(id => identityImageFixture({ id, isAnchor: false }))
|
||||
}
|
||||
})
|
||||
button('管理候选(2)').click()
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
const cards = wrapper.findAllComponents(IdentityImageCard)
|
||||
const first = cards.find(item => item.props('image').id === 'first')!
|
||||
|
||||
@@ -203,7 +203,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
})
|
||||
const card = wrapper!.findAll('.form-image-card').find(item => item.attributes('data-form-id') === first.id)!
|
||||
expect(card.get('.asset-image').classes()).not.toContain('form-image-has-source')
|
||||
expect(card.get('.asset-image-empty').text()).toContain('尚未生成主参考图')
|
||||
expect(card.get('.asset-image-empty').text()).toContain('确认并锁定身份母版后自动复用')
|
||||
expect(card.find('img').exists()).toBe(false)
|
||||
})
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('生成进度保留全栏提示,失败详情按需在浮层显示,切换后不串主体状态', async () => {
|
||||
it('生成进度只在图库显示,失败详情按需查看,切换后不串主体状态', async () => {
|
||||
/** 两个主体分别处于生成中与失败状态,所有查询均使用隔离的测试响应。 */
|
||||
const first = formFixture()
|
||||
const second = { ...formFixture(), id: 'second-form', subjectId: 'second-subject', images: [] }
|
||||
@@ -385,14 +385,10 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
)
|
||||
)
|
||||
await mountAssets('identity')
|
||||
const feedback = wrapper!.get('.identity-generation-feedback')
|
||||
const workspace = wrapper!.get('.identity-workspace')
|
||||
expect(feedback.element.closest('.identity-workspace-region')).toBe(
|
||||
wrapper!.get('.identity-workspace-region').element
|
||||
)
|
||||
expect(feedback.element.closest('.identity-detail')).toBeNull()
|
||||
expect(feedback.element.compareDocumentPosition(workspace.element) & 4).toBe(4)
|
||||
expect(feedback.text()).toContain('林知夏 的身份图片正在生成')
|
||||
expect(wrapper!.find('.identity-generation-feedback').exists()).toBe(false)
|
||||
const feedback = wrapper!.get('.identity-gallery [role="status"]')
|
||||
expect(feedback.text()).toContain('正在生成中')
|
||||
expect(feedback.element.closest('.identity-detail')).not.toBeNull()
|
||||
await wrapper!
|
||||
.findAll('.identity-subject-item')
|
||||
.find(item => item.text().includes('第二个主体'))!
|
||||
@@ -400,9 +396,8 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.identity-generation-feedback').exists()).toBe(false)
|
||||
expect(wrapper!.find('.identity-image-failure').exists()).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.identity-candidate-grid')?.textContent).not.toContain('模型暂时不可用')
|
||||
expect(wrapper!.get('.identity-gallery').text()).not.toContain('模型暂时不可用')
|
||||
expect(wrapper!.get('.identity-gallery').find('[role="status"]').exists()).toBe(false)
|
||||
expect(document.querySelector('.identity-image-failure')).toBeNull()
|
||||
button('生成失败,查看失败原因').click()
|
||||
await flushPromises()
|
||||
@@ -475,7 +470,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
button('刷新身份').click()
|
||||
await flushPromises()
|
||||
expect(wrapper!.get<HTMLInputElement>('#identity-description').element.value).toBe('')
|
||||
expect(wrapper!.text()).toContain('尚无身份母版')
|
||||
expect(wrapper!.text()).toContain('尚无身份图片')
|
||||
})
|
||||
|
||||
it('已有身份刷新保留草稿与图库,图片操作归属图库并遵守未保存限制', async () => {
|
||||
@@ -1079,8 +1074,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
})
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.identity-anchor-grid').exists()).toBe(true)
|
||||
button('设为身份母版').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'PUT')).toBe(false)
|
||||
@@ -1211,8 +1205,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
expect(wrapper!.text()).toContain('等待确认演员')
|
||||
button('管理候选并确认').click()
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.identity-anchor-grid').exists()).toBe(true)
|
||||
button('确认选角并锁定').click()
|
||||
await flushPromises()
|
||||
button('确认演员选择').click()
|
||||
|
||||
Reference in new issue
Block a user