From 81d6a85260249bc962f2025d48d84739f041538b Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 21 Oct 2026 16:34:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(short-drama-agent-front):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=80=89=E8=A7=92=E6=8A=BD=E5=B1=89=E4=B8=8E=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subject-identity/SubjectIdentityPage.vue | 126 +++++++++++------- src/features/subject-identity/model.ts | 14 +- tests/components/ui/layout.test.ts | 3 +- .../subject-identity/identity.test.ts | 2 +- tests/features/workflows/pages.test.ts | 26 ++-- 5 files changed, 103 insertions(+), 68 deletions(-) diff --git a/src/features/subject-identity/SubjectIdentityPage.vue b/src/features/subject-identity/SubjectIdentityPage.vue index 58492e8..5648201 100644 --- a/src/features/subject-identity/SubjectIdentityPage.vue +++ b/src/features/subject-identity/SubjectIdentityPage.vue @@ -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" > -
-
-

主体身份

-

- 为同一个人物、场景或道具固定稳定特征,再生成不同造型。 -

-
-
-

角色选角总览与批量操作

- 人物需要依次完成身份描述、选角候选、确认角色母版并锁定,之后才能用于镜头制作。未明确人物背景时,AI - 默认以中国人物作为选角基线;项目和角色的明确事实始终优先。场景和道具使用稳定身份母版流程。 + 先保存人物、场景或道具的固定特征,再生成参考图。确认并锁定的标准参考图称为“身份母版”,后续制作会以它保持外观一致。 - 先创建项目视觉风格,才能 AI 生成身份或身份图片。 +
@@ -464,30 +486,30 @@ function runNextAction() {

角色选角

- 只处理 - 人物角色。每张候选都根据当前身份描述独立生成,不复用旧母版;确认选择后才会设为角色母版并锁定身份。 + 补齐身份描述 → 生成候选图 → + 进入角色详情确认选角。候选图根据当前描述独立生成,不参考旧母版;确认后才设为母版并锁定身份。

{{ casting.ready }} / {{ casting.total }} 已完成{{ casting.ready }} / {{ casting.total }} 个角色已完成选角
-
缺身份文本
+
待补身份描述
{{ casting.missingIdentity }}
-
缺候选图
+
待生成候选图
{{ casting.missingAnchor }}
-
待确认演员
+
待确认选角
{{ casting.candidatePending }}
-
母版未锁定
+
身份未锁定
{{ casting.unlocked }}
@@ -502,9 +524,9 @@ function runNextAction() { validate-on-change >
- + - + 覆盖未锁定身份文本 + >重新生成已有的未锁定身份描述
+

+ 同时处理数量适用于所有批量生成;每批图片数量上限仅限制角色候选图、场景和道具母版的处理数量。重新生成选项仅影响身份描述,不影响图片。 +

+

+ 未注明人物背景时,AI + 默认采用中国人物特征;剧本和角色设定优先。点击下方角色可关闭此界面并查看详情,不会确认或更改选角。 +

+
-

场景与道具稳定母版

+

场景与道具母版

- 为已有身份描述但缺少有效母版的场景或道具小批量生图。成功后会自动设为身份母版并锁定。 + 为已有身份描述、尚未锁定或缺少有效母版的场景和道具生成参考图。通过质量校验后,自动设为母版并锁定;未通过的需继续处理。

@@ -598,7 +628,7 @@ function runNextAction() { !subjects.length " acknowledgement - :description="`最多处理 ${candidateLimit} 个场景,生成成功后自动设为身份母版并锁定。可能产生图片模型费用。`" + :description="`最多处理 ${candidateLimit} 个场景,可能产生图片生成与质量校验费用。通过校验后自动设为母版并锁定,可能替换尚未锁定的已有母版;已锁定且有有效母版的场景会跳过。`" @confirm="generateStableAnchors('scene')" />
- + + >

- 同时处理人物、场景和道具;角色选角建议优先使用上方专用入口。已锁定身份始终跳过。 + 按所选类型处理身份描述与提示词,不生成图片。沿用上方的同时处理数量和重新生成选项,已锁定身份会跳过,不受每批图片数量上限限制。

{{ session.receipt.title }} · 本次回执

- 导出诊断 + 导出结果

共 {{ session.receipt.result.total }} 个主体 · 目标 @@ -684,11 +715,11 @@ function runNextAction() { :show-icon="false" class="mt-3" > - 本次存在部分失败,成功结果不会回滚。请检查逐角色原因后再重试。 + 部分生成未完成,已成功的结果会保留。请查看下方原因后再重试。

  • - {{ failure.subjectRef }} · {{ failure.subjectId }}:{{ userFacingText(failure.error) }} + {{ failure.subjectRef }}:{{ userFacingText(failure.error) }}

@@ -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; } diff --git a/src/features/subject-identity/model.ts b/src/features/subject-identity/model.ts index 615e32a..edaa171 100644 --- a/src/features/subject-identity/model.ts +++ b/src/features/subject-identity/model.ts @@ -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 = { - missing_identity: '缺少身份文本', - missing_anchor: '缺少候选图', - candidate_pending: '等待确认演员', - unlocked: '演员尚未锁定', + missing_identity: '待补身份描述', + missing_anchor: '待生成候选图', + candidate_pending: '待确认选角', + unlocked: '身份未锁定', ready: '选角已完成' } return labels[status] diff --git a/tests/components/ui/layout.test.ts b/tests/components/ui/layout.test.ts index 45bcb45..ac00b31 100644 --- a/tests/components/ui/layout.test.ts +++ b/tests/components/ui/layout.test.ts @@ -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/ ) diff --git a/tests/features/subject-identity/identity.test.ts b/tests/features/subject-identity/identity.test.ts index 22f6453..5a34a49 100644 --- a/tests/features/subject-identity/identity.test.ts +++ b/tests/features/subject-identity/identity.test.ts @@ -326,7 +326,7 @@ describe('身份图与母版契约', () => { module: 'character', forms: [] }) - expect(castingStatusLabel('candidate_pending')).toBe('等待确认演员') + expect(castingStatusLabel('candidate_pending')).toBe('待确认选角') }) it('辅助视角传递明确参考图、目录尺寸和本次 Prompt,不传旧宽高字段', async () => { diff --git a/tests/features/workflows/pages.test.ts b/tests/features/workflows/pages.test.ts index 90a0e16..d2278c0 100644 --- a/tests/features/workflows/pages.test.ts +++ b/tests/features/workflows/pages.test.ts @@ -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('#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()