fix(short-drama-agent-front): 优化选角抽屉与操作文案

This commit is contained in:
GJ committed 2026-10-21 16:34:25 +08:00
1 parent a8ecf37e78
commit 81d6a85260
5 files changed
+103 -68

No files matched your search

@@ -100,7 +100,12 @@ const initialLoading = computed(() => catalog.loading.value && !catalog.data.val
const detailInitialLoading = computed(() => detail.loading.value && !detail.data.value)
const search = ref('')
const module = ref('all')
/** 高级身份描述批量生成的真实主体类型范围。 */
const identityBatchModule = ref<'all' | 'character' | 'scene' | 'prop'>('all')
/** 高级批量操作的按钮和确认说明使用同一范围名称,避免筛选后仍显示“全部”。 */
const identityBatchScopeLabel = computed(
() => ({ all: '全部主体', character: '人物', scene: '场景', prop: '道具' })[identityBatchModule.value]
)
/** 单主体稳定母版质量生成弹窗开关。 */
const qualityOpen = ref(false)
const imageOpen = ref(false)
@@ -195,7 +200,10 @@ watch(
{ flush: 'post' }
)
/** 切换主体前确认放弃当前草稿,避免误丢尚未保存的文本。 */
/**
* 切换主体前确认放弃当前草稿,避免误丢尚未保存的文本。
* @param id 目标主体编号
*/
function select(id: string) {
if (id === selectedId.value) return
if (dirty.value) pendingSelection.value = id
@@ -284,8 +292,27 @@ function retryIdentityImage(imageId: string) {
imageOpen.value = true
}
}
/** 新回执自动展开,避免折叠区隐藏部分失败诊断。 */
/** 批量操作抽屉显隐状态,新回执到达时自动打开以展示结果。 */
const toolsOpen = ref(false)
/** 角色卡片的切换目标,等抽屉离场后再交给详情页处理草稿确认。 */
const overviewSelection = ref('')
/**
* 点击角色卡片时先关闭抽屉,点击当前角色也会关闭。
* @param id 需要查看的角色主体编号
*/
function selectFromOverview(id: string) {
overviewSelection.value = id
toolsOpen.value = false
}
/** 抽屉关闭后显示目标角色,清除可能隐藏该角色的目录筛选并保留草稿确认。 */
function finishOverviewSelection() {
const id = overviewSelection.value
overviewSelection.value = ''
if (!subjects.value.some(item => item.id === id && item.module === 'character')) return
module.value = 'character'
search.value = ''
select(id)
}
watch(
() => session.value.receipt,
receipt => {
@@ -294,8 +321,10 @@ watch(
}
}
)
/** 批量表单只校验同时处理数量与每批图片处理数量,不改变真实请求字段。 */
const formModel = computed(() => ({ concurrency: concurrency.value, candidateLimit: candidateLimit.value }))
const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRule('本批上限') }
/** 校验提示与批量参数的可见名称保持一致。 */
const rules = { concurrency: integerRule('同时处理数量'), candidateLimit: integerRule('每批图片数量上限') }
type IdentityFlowAction = 'style' | 'profile' | 'identity' | 'candidate' | 'confirm' | 'lock' | 'forms'
const primaryCandidate = computed(() =>
@@ -435,28 +464,21 @@ function runNextAction() {
:pending="operation.pending"
:pending-label="operation.label"
v-model:open="toolsOpen"
title="角色选角总览与批量操作"
title="角色选角与批量生成"
fullscreen
:has-receipt="!!session.receipt"
@closed="finishOverviewSelection"
>
<!-- 以下是主体身份说明与选角批量操作模块 -->
<div class="identity-tools-intro flex flex-wrap items-end justify-between gap-4">
<div>
<h2 class="text-lg font-semibold">主体身份</h2>
<p class="mt-2 text-sm text-muted">
为同一个人物、场景或道具固定稳定特征,再生成不同造型。
</p>
</div>
</div>
<div class="workspace-overview-panel">
<div class="overview-content workspace-section-stack dialog-flat-stack">
<h3 class="text-sm font-semibold">角色选角总览与批量操作</h3>
<ContextNotice type="info" :show-icon="false" class="text-xs">
人物需要依次完成身份描述、选角候选、确认角色母版并锁定,之后才能用于镜头制作。未明确人物背景时,AI
默认以中国人物作为选角基线;项目和角色的明确事实始终优先。场景和道具使用稳定身份母版流程。
先保存人物、场景或道具的固定特征,再生成参考图。确认并锁定的标准参考图称为“身份母版”,后续制作会以它保持外观一致。
</ContextNotice>
<ContextNotice v-if="styleQuery.data.value && !hasStyle" type="info" :show-icon="false">
先创建项目视觉风格,才能 AI 生成身份或身份图片。</ContextNotice
请先在“视觉风格”页面保存项目风格,再生成身份描述或参考图。</ContextNotice
>
<!-- 以下是人物选角进度、批量参数与角色详情入口模块 -->
<section v-if="casting" class="workspace-panel" aria-label="角色选角流程">
<div class="flex flex-wrap items-start justify-between gap-4">
<div class="flex items-start gap-3">
@@ -464,30 +486,30 @@ function runNextAction() {
<div>
<h3 class="text-sm font-semibold">角色选角</h3>
<p class="mt-2 text-xs leading-6 text-muted">
只处理
人物角色。每张候选都根据当前身份描述独立生成,不复用旧母版;确认选择后才会设为角色母版并锁定身份。
补齐身份描述 → 生成候选图 →
进入角色详情确认选角。候选图根据当前描述独立生成,不参考旧母版;确认后才设为母版并锁定身份。
</p>
</div>
</div>
<span class="font-mono text-xs text-muted"
>{{ casting.ready }} / {{ casting.total }} 已完成</span
>{{ casting.ready }} / {{ casting.total }} 个角色已完成选角</span
>
</div>
<dl class="casting-stats mt-4">
<div>
<dt>缺身份文本</dt>
<dt>待补身份描述</dt>
<dd>{{ casting.missingIdentity }}</dd>
</div>
<div>
<dt>缺候选图</dt>
<dt>待生成候选图</dt>
<dd>{{ casting.missingAnchor }}</dd>
</div>
<div>
<dt>待确认演员</dt>
<dt>待确认选角</dt>
<dd>{{ casting.candidatePending }}</dd>
</div>
<div>
<dt>母版未锁定</dt>
<dt>身份未锁定</dt>
<dd>{{ casting.unlocked }}</dd>
</div>
<div>
@@ -502,9 +524,9 @@ function runNextAction() {
validate-on-change
>
<div class="form-controls mt-5 flex flex-wrap gap-4 pt-4">
<NFormItem class="w-28" path="concurrency" label="并发数">
<NFormItem class="w-36" path="concurrency" label="同时处理数量">
<NInputNumber
:input-props="{ 'aria-label': '并发数' }"
:input-props="{ 'aria-label': '同时处理数量' }"
:disabled="operation.pending"
:value="typeof concurrency === 'number' ? concurrency : null"
@update:value="concurrency = $event ?? 0"
@@ -512,9 +534,9 @@ function runNextAction() {
:step="1"
></NInputNumber>
</NFormItem>
<NFormItem class="w-28" path="candidateLimit" label="本批上限">
<NFormItem class="w-36" path="candidateLimit" label="每批图片数量上限">
<NInputNumber
:input-props="{ 'aria-label': '本批上限' }"
:input-props="{ 'aria-label': '每批图片数量上限' }"
:disabled="operation.pending"
:value="typeof candidateLimit === 'number' ? candidateLimit : null"
@update:value="candidateLimit = $event ?? 0"
@@ -526,11 +548,11 @@ function runNextAction() {
v-model:checked="force"
:disabled="operation.pending"
class="control-row-checkbox text-xs"
>覆盖未锁定身份文本
>重新生成已有的未锁定身份描述
</NCheckbox>
<ConfirmAction
:loading="isOperationRunning(operation, '批量生成角色身份文本')"
:label="force ? '重生成角色身份文本' : '补齐角色身份文本'"
:label="force ? '重新生成角色身份描述' : '补齐角色身份描述'"
:disabled="
blocked ||
!hasStyle ||
@@ -540,12 +562,12 @@ function runNextAction() {
!casting.total
"
acknowledgement
description="只整理人物的角色特征,不生成图片。已锁定角色始终跳过;覆盖文本不会自动更新已有候选图。"
description="处理本项目的人物身份描述与提示词,不生成图片,也不受每批图片数量上限限制。已锁定角色会跳过;勾选重新生成后会覆盖未锁定角色的已有描述,但不会更新已有图片。可能产生 AI 生成费用。"
@confirm="generateProject(true)"
/>
<ConfirmAction
:loading="isOperationRunning(operation, '批量生成角色选角候选')"
label="AI 批量生成角色候选图"
label="批量生成角色候选图"
:disabled="
castingBlocked ||
!hasStyle ||
@@ -554,16 +576,23 @@ function runNextAction() {
!casting.missingAnchor
"
acknowledgement
description="按本批上限,为缺少标准参考图的人物角色各生成一张新候选图,可能产生费用。已有候选、标准参考图或已选定外观的角色会跳过;生成后仍需手动选择和确认。"
:description="`最多为 ${candidateLimit} 个缺少候选图的人物角色各生成一张候选图,可能产生费用。已有候选图或母版的角色会跳过;生成后仍需进入角色详情确认选角。`"
@confirm="generateCastingCandidates"
/>
</div>
</AppForm>
<p class="mt-2 text-xs leading-6 text-muted">
同时处理数量适用于所有批量生成;每批图片数量上限仅限制角色候选图、场景和道具母版的处理数量。重新生成选项仅影响身份描述,不影响图片。
</p>
<p class="mt-2 text-xs leading-6 text-muted">
未注明人物背景时,AI
默认采用中国人物特征;剧本和角色设定优先。点击下方角色可关闭此界面并查看详情,不会确认或更改选角。
</p>
<div class="casting-list" role="group" aria-label="角色选角进度">
<NButton
v-for="item in casting.items"
:key="item.subjectId"
@click="select(item.subjectId)"
@click="selectFromOverview(item.subjectId)"
class="casting-item"
:class="{ selected: selectedId === item.subjectId }"
:aria-pressed="selectedId === item.subjectId"
@@ -577,12 +606,13 @@ function runNextAction() {
/></NButton>
</div>
</section>
<!-- 以下是场景和道具标准参考图的批量生成模块 -->
<section class="workspace-panel" aria-label="场景与道具身份母版">
<div class="flex flex-wrap items-start justify-between gap-4">
<div>
<h3 class="text-sm font-semibold">场景与道具稳定母版</h3>
<h3 class="text-sm font-semibold">场景与道具母版</h3>
<p class="mt-2 text-xs leading-6 text-muted">
为已有身份描述但缺少有效母版的场景或道具小批量生图。成功后会自动设为身份母版并锁定。
为已有身份描述、尚未锁定或缺少有效母版的场景和道具生成参考图。通过质量校验后,自动设为母版并锁定;未通过的需继续处理。
</p>
</div>
<div class="flex flex-wrap gap-3">
@@ -598,7 +628,7 @@ function runNextAction() {
!subjects.length
"
acknowledgement
:description="`最多处理 ${candidateLimit} 个场景,生成成功后自动设为身份母版并锁定。可能产生图片模型费用。`"
:description="`最多处理 ${candidateLimit} 个场景,可能产生图片生成与质量校验费用。通过校验后自动设为母版并锁定,可能替换尚未锁定的已有母版;已锁定且有有效母版的场景会跳过。`"
@confirm="generateStableAnchors('scene')"
/>
<ConfirmAction
@@ -608,22 +638,23 @@ function runNextAction() {
blocked || !hasStyle || !batchValid || dirty || !subjects.length
"
acknowledgement
:description="`最多处理 ${candidateLimit} 个道具,生成成功后自动设为身份母版并锁定。可能产生图片模型费用。`"
:description="`最多处理 ${candidateLimit} 个道具,可能产生图片生成与质量校验费用。通过校验后自动设为母版并锁定,可能替换尚未锁定的已有母版;已锁定且有有效母版的道具会跳过。`"
@confirm="generateStableAnchors('prop')"
/>
</div>
</div>
</section>
<NCollapse class="workspace-panel" :default-expanded-names="['details']"
<!-- 以下是默认收起、按所选类型生成身份描述的高级模块 -->
<NCollapse class="workspace-panel"
><NCollapseItem name="details"
><template #header>高级:全部主体身份文本</template>
><template #header>高级:按类型批量生成身份描述</template>
<p class="mt-3 text-xs leading-6 text-muted">
同时处理人物、场景和道具;角色选角建议优先使用上方专用入口。已锁定身份始终跳过。
按所选类型处理身份描述与提示词,不生成图片。沿用上方的同时处理数量和重新生成选项,已锁定身份会跳过,不受每批图片数量上限限制。
</p>
<NSelect
v-model:value="identityBatchModule"
class="mt-4 w-48"
aria-label="身份文本批处理范围"
aria-label="身份描述生成范围"
:options="[
{ label: String('全部类型'), value: 'all' },
{ label: String('仅人物'), value: 'character' },
@@ -632,10 +663,10 @@ function runNextAction() {
]" />
<ConfirmAction
class="mt-4"
:label="force ? '重生成全部未锁定身份' : '补齐全部主体身份文本'"
:label="`${force ? '重新生成' : '补齐'}${identityBatchScopeLabel}身份描述`"
:disabled="blocked || !hasStyle || !batchValid || dirty || !subjects.length"
acknowledgement
description="生成全项目主体身份描述与提示词,不生成图片。覆盖不会自动更新旧身份图、形态图、首帧或视频。"
:description="`处理本项目的${identityBatchScopeLabel}身份描述与提示词,不生成图片,已锁定身份会跳过。${force ? '将覆盖未锁定主体的已有描述' : '仅补齐缺失的描述或提示词'},不会自动更新已有身份图、形态图、首帧或视频。可能产生 AI 生成费用。`"
@confirm="
identityBatchModule === 'character'
? generateProject(true)
@@ -651,7 +682,7 @@ function runNextAction() {
<section v-if="session.receipt" class="workspace-panel" aria-label="身份文本批量回执">
<div class="flex justify-between gap-3">
<h3 class="text-sm font-medium">{{ session.receipt.title }} · 本次回执</h3>
<NButton @click="exportReceipt" text size="small">导出诊断</NButton>
<NButton @click="exportReceipt" text size="small">导出结果</NButton>
</div>
<p v-if="session.receipt.kind === 'identities'" class="mt-3 text-xs text-muted">
共 {{ session.receipt.result.total }} 个主体 · 目标
@@ -684,11 +715,11 @@ function runNextAction() {
:show-icon="false"
class="mt-3"
>
本次存在部分失败,成功结果不会回滚。请检查逐角色原因后再重试。
部分生成未完成,已成功的结果会保留。请查看下方原因后再重试。
</ContextNotice>
<ul class="mt-3 space-y-2 text-xs text-danger">
<li v-for="failure in session.receipt.result.failures" :key="failure.subjectId">
{{ failure.subjectRef }} · {{ failure.subjectId }}:{{ userFacingText(failure.error) }}
{{ failure.subjectRef }}:{{ userFacingText(failure.error) }}
</li>
</ul>
<p class="mt-3 text-[11px] text-muted">
@@ -1083,9 +1114,6 @@ function runNextAction() {
.toolbar-type-filter .n-select {
@apply w-full min-w-0;
}
.identity-tools-intro {
@apply mb-6;
}
.directory-filters {
@apply grid gap-3 p-3 shrink-0;
}
+9 -5
View File
@@ -50,13 +50,17 @@ export function mergeCastingSubjects(
return [...rows.values()].toSorted((a, b) => a.ref.localeCompare(b.ref))
}
/** 角色选角状态中文标签。 */
/**
* 将角色选角状态转换为统一的中文操作提示。
* @param status 服务返回的角色选角状态
* @returns 角色列表与选角总览共用的中文状态
*/
export function castingStatusLabel(status: CharacterCastingStatus): string {
const labels: Record<CharacterCastingStatus, string> = {
missing_identity: '缺少身份文本',
missing_anchor: '缺少候选图',
candidate_pending: '等待确认演员',
unlocked: '演员尚未锁定',
missing_identity: '待补身份描述',
missing_anchor: '待生成候选图',
candidate_pending: '待确认选角',
unlocked: '身份未锁定',
ready: '选角已完成'
}
return labels[status]
+1 -2
View File
@@ -77,10 +77,9 @@ describe('管理后台组件边界', () => {
expect(all).toMatch(/\.image-history\.n-scrollbar\s*\{[^}]*max-width:\s*100%;[^}]*min-width:\s*0/)
expect(all).toMatch(/\.image-history-content\s*\{[^}]*display:\s*flex;[^}]*width:\s*max-content/)
})
it('选角面板保留说明间距,卡片按可用宽度排列并覆盖按钮默认高度', () => {
it('选角卡片按可用宽度排列并覆盖按钮默认高度', () => {
// 保护间距与换行契约,真实宽高和暗色效果仍需浏览器验收。
const css = readAllStyles()
expect(css).toMatch(/\.identity-tools-intro\s*\{[^}]*margin-bottom:\s*24px/)
expect(css).toMatch(
/\.casting-list\s*\{[^}]*repeat\(auto-fit, minmax\(min\(100%, 260px\), 1fr\)\);[^}]*gap:\s*12px;[^}]*margin-top:\s*24px/
)
@@ -326,7 +326,7 @@ describe('身份图与母版契约', () => {
module: 'character',
forms: []
})
expect(castingStatusLabel('candidate_pending')).toBe('等待确认演员')
expect(castingStatusLabel('candidate_pending')).toBe('待确认选角')
})
it('辅助视角传递明确参考图、目录尺寸和本次 Prompt,不传旧宽高字段', async () => {
+15 -11
View File
@@ -2,7 +2,7 @@ import { preparationFixture } from '../storyboard-preparation/fixtures'
import { generationProfile, imageCatalog } from '../../fixtures/generation'
import { routerLinkStubs } from '../../fixtures/router'
import { computed, ref } from 'vue'
import { NImage, NRadioGroup, NScrollbar } from 'naive-ui'
import { NDrawer, NImage, NRadioGroup, NScrollbar } from 'naive-ui'
import { createMemoryHistory, createRouter, type RouteRecordRaw } from 'vue-router'
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi, type Mock } from 'vitest'
@@ -732,7 +732,7 @@ describe('视觉风格与主体身份工作区', () => {
})
stubFetch(fetcher)
await mountAssets('identity')
await drawerPanel().get('.n-card-header__close').trigger('click')
await drawerPanel().get('.n-drawer-header__close').trigger('click')
await flushPromises()
const items = wrapper!.findAll('.identity-subject-item')
expect(items).toHaveLength(3)
@@ -1073,11 +1073,11 @@ describe('视觉风格与主体身份工作区', () => {
})
stubFetch(fetcher)
await mountAssets('identity')
await confirmGeneration('补齐全部主体身份文本')
await confirmGeneration('补齐全部主体身份描述')
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
expect(post[0]).toBe('/api/projects/page-test-project/subject-identities/generate')
expect(JSON.parse(post[1]!.body as string)).toEqual({ force: false, concurrency: 3 })
expect(drawerPanel().text()).toContain('本次存在部分失败')
expect(drawerPanel().text()).toContain('部分生成未完成')
expect(drawerPanel().text()).toContain('含锁定 1')
expect(drawerPanel().text()).toContain('文本模型超时')
})
@@ -1167,7 +1167,7 @@ describe('视觉风格与主体身份工作区', () => {
expect(anchorImage.props()).toMatchObject({ objectFit: 'cover', previewDisabled: false })
})
it('选角进度卡片分层显示长姓名、编号和状态,点击仍按正式 ID 切换主体', async () => {
it('全屏选角卡片显示长姓名、编号和状态,关闭动画结束后按正式 ID 切换主体', async () => {
const longName = '来自记忆当铺的另一条时间线中尚未丢失记忆的林默'
const items = [
{
@@ -1211,7 +1211,8 @@ describe('视觉风格与主体身份工作区', () => {
})
stubFetch(fetcher)
await mountAssets('identity')
expect(drawerPanel().get('.identity-tools-intro').text()).toContain('为同一个人物、场景或道具固定稳定特征')
expect(drawerPanel().text()).toContain('先保存人物、场景或道具的固定特征')
expect(wrapper!.getComponent(NDrawer).props('width')).toBe('100vw')
const cards = drawerPanel().get('[aria-label="角色选角进度"]').findAll('.casting-item')
expect(cards).toHaveLength(2)
expect(cards[0]!.get('.casting-item-name').text()).toBe(longName)
@@ -1219,12 +1220,15 @@ describe('视觉风格与主体身份工作区', () => {
expect(cards[0]!.get('.casting-item-status').text()).toBe('选角已完成')
expect(cards[0]!.find('.truncate').exists()).toBe(false)
expect(cards[0]!.attributes('aria-pressed')).toBe('true')
expect(cards[1]!.get('.casting-item-status').text()).toBe('等待确认演员')
expect(cards[1]!.get('.casting-item-status').text()).toBe('待确认选角')
await cards[1]!.trigger('click')
await flushPromises()
expect(cards[0]!.attributes('aria-pressed')).toBe('false')
expect(cards[1]!.attributes('aria-pressed')).toBe('true')
expect(cards[1]!.classes()).toContain('selected')
expect(wrapper!.getComponent(NDrawer).props('show')).toBe(false)
expect(wrapper!.findAll('.identity-subject-item')[0]!.attributes('aria-pressed')).toBe('true')
/** DOM 环境不播放离场动画,显式交接公共抽屉的关闭完成事件。 */
wrapper!.getComponent(NDrawer).vm.$emit('after-leave')
await flushPromises()
expect(wrapper!.findAll('.identity-subject-item')[1]!.attributes('aria-pressed')).toBe('true')
expect(new DOMWrapper(document.body).get<HTMLTextAreaElement>('#identity-description').element.value).toBe(
'老周的稳定身份'
)
@@ -1278,7 +1282,7 @@ describe('视觉风格与主体身份工作区', () => {
})
stubFetch(fetcher)
await mountAssets('identity')
expect(wrapper!.text()).toContain('等待确认演员')
expect(wrapper!.text()).toContain('待确认选角')
expect(wrapper!.find('.identity-anchor-grid').exists()).toBe(true)
button('确认选角并锁定').click()
await flushPromises()