perf(short-drama-agent-front): 优化制作工作台交互与移动端布局

This commit is contained in:
GJ committed 2026-10-10 19:28:47 +08:00
1 parent b5eaed3981
commit 54a381ebd3
37 files changed
+1217 -426

No files matched your search

@@ -262,7 +262,7 @@ describe('拆解页内容滚动', () => {
['人物', 'character'],
['场景', 'scene'],
['道具', 'prop']
] as const)('%s 的奇偶主体默认展示独立形态块,搜索重排不影响形态归属', async (label, module) => {
] as const)('%s 的奇偶主体默认收起形态块,展开和搜索不影响形态归属', async (label, module) => {
const record = checkpoint()
// 前两个主体各准备两种形态,覆盖奇偶条纹和默认标签,不调用模型接口。
record.state.breakdownResult!.subjectForms = [0, 1].flatMap(subjectIndex =>
@@ -281,6 +281,9 @@ describe('拆解页内容滚动', () => {
const articles = wrapper!.findAll('.subject-record-list > article')
for (const index of [0, 1]) {
const article = articles[index]!
expect(article.findAll('.subject-form-card')).toHaveLength(0)
await article.get('.n-collapse-item__header-main').trigger('click')
await flushPromises()
const cards = article.findAll('.subject-form-card')
expect(cards).toHaveLength(2)
expect(cards[0]!.get('.n-tag').text()).toBe('默认')
@@ -376,7 +379,7 @@ describe('拆解页内容滚动', () => {
it('分镜顶部无叠加操作行,选择标签保持单行且统计操作垂直居中', () => {
// 仅保护样式契约,DOM 环境不提供真实布局坐标。
const css = readAllStyles()
expect(css).toMatch(/\.breakdown-result-pad\s*\{[^}]*padding:\s*16px/)
expect(css).toMatch(/\.breakdown-result-pad\s*\{[^}]*padding:\s*0(?:px)?/)
expect(css).toMatch(/\.breakdown-episode-picker > span\s*\{[^}]*flex-shrink:\s*0;[^}]*white-space:\s*nowrap;/)
expect(css).toMatch(/\.breakdown-storyboard-summary\s*\{[^}]*align-items:\s*center;/)
})
+7 -15
View File
@@ -46,31 +46,23 @@ describe('镜头生产数据契约', () => {
expect(source).toMatch(/\.generation-input-mode-label\s*\{[^}]*mb-\[7px\][^}]*text-xs/)
})
it('主首帧、素材引用和视频使用固定上限的正方形网格,不随少量记录撑满整行', () => {
it('主首帧与主视频共用固定宽度,素材引用保留正方形网格', () => {
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
expect(source).toContain('v-if="videos.length" class="video-grid mt-4"')
expect(source).toContain('v-if="currentVideo" class="video-grid mt-4"')
expect(source).toMatch(/\.keyframe-grid,\s*\.video-grid\s*\{[^}]*max-w-\[260px\][^}]*grid-cols-1/)
expect(source).toMatch(
/\.keyframe-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/
)
expect(source).toMatch(
/\.video-input-grid,[\s\S]*?\.video-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/
/\.video-input-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/
)
expect(source).toMatch(/\.keyframe-card \.asset-image\s*\{[^}]*aspect-square/)
expect(source).toMatch(/\.production-video\s*\{[^}]*aspect-square/)
const videoCard = readFileSync('src/features/production/components/VideoCard.vue', 'utf8')
expect(videoCard).toContain('class="block aspect-square w-full bg-[#080808] object-contain"')
expect(source).toMatch(/\.video-input-card\s*\{[^}]*bg-\(--app-control\)/)
expect(source).toMatch(/\.video-input-image\s*\{[^}]*aspect-square/)
expect(source).toContain('object-fit="cover"')
expect(source).not.toContain('class="video-input-ref"')
expect(source).not.toContain('{{ reference.subjectFormName }} · {{ reference.subjectRef }}')
expect(source).toMatch(
/@media \(max-width: 760px\)[\s\S]*?\.video-grid\s*\{[^}]*grid-cols-\[repeat\(2,_minmax\(0,_1fr\)\)\]/
)
})
it('主首帧角标使用深色强调背景并在图片上保持清晰边界', () => {
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
expect(source).toMatch(
/\.primary-keyframe-mark\s*\{[^}]*color:\s*var\(--app-on-accent\)[^}]*background:\s*var\(--app-button-primary\)[^}]*box-shadow:/
/@media \(max-width: 760px\)[\s\S]*?\.video-input-grid\s*\{[^}]*grid-cols-\[repeat\(2,_minmax\(0,_1fr\)\)\]/
)
})
@@ -84,19 +84,33 @@ describe('精简公开资产回归', () => {
const wrapper = mount(ShotProductionAssets, { props: { projectId, shot, disabled: false } })
try {
await flushPromises()
expect(wrapper.find('video').exists()).toBe(true)
/** 未确认的候选不出现在主区,只在管理弹窗中播放和检查。 */
expect(wrapper.find('video').exists()).toBe(false)
expect(wrapper.text()).toContain('尚无已确认主视频')
await wrapper
.findAll('button')
.find(button => button.text() === '管理候选(1)')!
.trigger('click')
await flushPromises()
expect(document.querySelector('video')).not.toBeNull()
expect(wrapper.text()).not.toContain('自动校验中')
expect(wrapper.findAll('button').some(button => button.text() === '设为主视频')).toBe(false)
expect(
[...document.querySelectorAll('button')].some(button => button.textContent?.trim() === '设为主视频')
).toBe(false)
const session = qualitySession(
qualityKey(projectId, { kind: 'video', shotId: shot.shotId, assetId: video.id, title: '' })
)
session.videoValidation = validation
await flushPromises()
expect(wrapper.findAll('button').some(button => button.text() === '设为主视频')).toBe(true)
expect(
[...document.querySelectorAll('button')].some(button => button.textContent?.trim() === '设为主视频')
).toBe(true)
expect(sessionVideoValidation('other-project', shot.shotId, video.id)).toBeNull()
session.videoValidation = { ...validation, passed: false }
await flushPromises()
expect(wrapper.findAll('button').some(button => button.text() === '设为主视频')).toBe(false)
expect(
[...document.querySelectorAll('button')].some(button => button.textContent?.trim() === '设为主视频')
).toBe(false)
expect(fetcher.mock.calls.every(([, options]) => options?.method === 'GET')).toBe(true)
} finally {
wrapper.unmount()
@@ -170,7 +184,7 @@ describe('精简公开资产回归', () => {
try {
await flushPromises()
expect(wrapper.findAll('.keyframe-card')).toHaveLength(1)
expect(wrapper.find('.primary-keyframe-mark').attributes('aria-label')).toBe('当前主首帧')
expect(wrapper.find('.keyframe-card').text()).toContain('主首帧')
expect(wrapper.findAll('button').some(item => item.text().includes('设为主首帧'))).toBe(false)
await wrapper
@@ -0,0 +1,61 @@
import { describe, expect, it } from 'vitest'
import { videoRecordedValidation } from '@/features/production/model'
import type { ShotVideoQualityStatus } from '@/features/production/types'
/** 两条候选拥有不同检查结果,用于验证结果不能跨视频归属。 */
const qualityStatus: ShotVideoQualityStatus = {
shotId: 'shot-1',
status: 'passed',
primaryVideoId: 'video-passed',
latestVideoId: 'video-passed',
repairAttempt: 1,
maxRepairAttempts: 2,
validationPassed: true,
issues: [],
chain: [
{
videoId: 'video-failed',
providerStatus: 'completed',
isPrimary: false,
repairAttempt: 0,
maxRepairAttempts: 2,
validationPassed: false,
createdAt: '2026-10-10T00:00:00Z',
updatedAt: '2026-10-10T00:01:00Z'
},
{
videoId: 'video-passed',
providerStatus: 'completed',
isPrimary: true,
repairAttempt: 1,
maxRepairAttempts: 2,
validationPassed: true,
createdAt: '2026-10-10T00:02:00Z',
updatedAt: '2026-10-10T00:03:00Z'
}
]
}
describe('视频检查记录归属', () => {
it('流程通过时仍保留另一个候选未通过的结果', () => {
expect(videoRecordedValidation(qualityStatus, 'shot-1', 'video-failed')).toBe(false)
expect(videoRecordedValidation(qualityStatus, 'shot-1', 'video-passed')).toBe(true)
})
it('其它镜头的同名视频不能提供当前检查结论', () => {
expect(videoRecordedValidation(qualityStatus, 'shot-2', 'video-passed')).toBeNull()
})
it('没有匹配记录时不能用流程级通过结果兜底', () => {
expect(videoRecordedValidation(qualityStatus, 'shot-1', 'video-missing')).toBeNull()
expect(videoRecordedValidation(null, 'shot-1', 'video-passed')).toBeNull()
})
it('尚未检查的候选保持未知状态', () => {
const unchecked: ShotVideoQualityStatus = {
...qualityStatus,
chain: [{ ...qualityStatus.chain[0]!, validationPassed: null }]
}
expect(videoRecordedValidation(unchecked, 'shot-1', 'video-failed')).toBeNull()
})
})
+14 -1
View File
@@ -1,7 +1,20 @@
import { describe, expect, it } from 'vitest'
import { masonryRowSpan } from '@/features/subject-images/layout'
import { masonryColumnCount, masonryRowSpan } from '@/features/subject-images/layout'
describe('图库瀑布流卡片布局', () => {
it('从桌面缩窄到手机时重新按可用宽度计算列数', () => {
expect(masonryColumnCount(2164, 260, 12)).toBe(8)
expect(masonryColumnCount(363, 260, 12)).toBe(1)
expect(masonryColumnCount(240, 260, 12)).toBe(1)
expect(masonryColumnCount(531, 260, 12)).toBe(1)
expect(masonryColumnCount(532, 260, 12)).toBe(2)
})
it('容器尚未布局或尺寸无效时保留单列', () => {
expect(masonryColumnCount(0, 260, 12)).toBe(1)
expect(masonryColumnCount(363, Number.NaN, 12)).toBe(1)
expect(masonryColumnCount(363, 260, -1)).toBe(1)
})
it('按卡片实际高度计算网格跨度', () => {
expect(masonryRowSpan(420, 1, 20)).toBe(21)
expect(masonryRowSpan(421, 1, 20)).toBe(21)
+2 -2
View File
@@ -925,8 +925,8 @@ describe('工作台页面交互', () => {
const toolbar = wrapper.get('.result-toolbar')
expect(toolbar.find('[aria-label="拆解结果"]').exists()).toBe(true)
expect(toolbar.find(':scope > button').exists()).toBe(false)
expect(toolbar.get('.n-tabs-nav__suffix button').attributes('aria-label')).toBe('拆解更多操作')
await toolbar.get('.n-tabs-nav__suffix button').trigger('click')
expect(toolbar.find('.n-tabs-nav__suffix [aria-label="拆解更多操作"]').exists()).toBe(true)
await toolbar.get('.n-tabs-nav__suffix [aria-label="拆解更多操作"]').trigger('click')
await flushPromises()
const exportItem = [...document.querySelectorAll('.n-dropdown-option-body')].find(
item => item.textContent?.trim() === '导出 JSON'