style: 优化单次生成设置布局

This commit is contained in:
GouJ committed 2026-09-24 19:31:52 +08:00
1 parent 7691346132
commit 90c67e1aa8
5 files changed
+244 -95

No files matched your search

+56 -12
View File
@@ -33,17 +33,29 @@ describe('镜头生产数据契约', () => {
it('三个生产阶段使用统一的块级操作区,保证卡片、按钮和下一阶段之间有稳定间距', () => {
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
expect(source.match(/class="production-stage-actions"/g)).toHaveLength(3)
expect(source).toMatch(
/\.production-stage-actions\s*\{[^}]*mt-4[^}]*min-h-\[34px\][^}]*items-center[^}]*gap-3/
)
expect(source).toMatch(/\.production-stage-actions\s*\{[^}]*mt-4[^}]*min-h-\[34px\][^}]*items-center[^}]*gap-3/)
})
it('本次视频生成设置限制内容宽度,并统一标题、字段和说明文字间距', () => {
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
expect(source).toContain('class="generation-settings-panel surface-inset mt-4"')
expect(source).toContain('class="generation-settings-content"')
expect(source).toContain('class="generation-input-mode"')
expect(source).toMatch(/\.generation-settings-panel\s*\{[^}]*p-5/)
expect(source).toMatch(/\.generation-settings-content\s*\{[^}]*max-w-\[1120px\]/)
expect(source).toMatch(/\.generation-input-mode-label\s*\{[^}]*mb-\[7px\][^}]*text-xs/)
})
it('首帧、素材引用和视频使用固定上限的正方形网格,不随少量记录撑满整行', () => {
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
expect(source).toContain('v-if="keyframeCandidates.length" class="keyframe-grid mt-4"')
expect(source).toContain('v-if="videos.length" class="video-grid mt-4"')
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\)\)/)
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\)\)/
)
expect(source).toMatch(/\.keyframe-card \.asset-image\s*\{[^}]*aspect-square/)
expect(source).toMatch(/\.production-video\s*\{[^}]*aspect-square/)
expect(source).toMatch(/\.video-input-card\s*\{[^}]*bg-\(--app-control\)/)
@@ -199,7 +211,9 @@ describe('镜头生产数据契约', () => {
await flushPromises()
button('确认生成首帧').click()
await flushPromises()
expect(wrapper.emitted('generate')).toEqual([[{ setPrimary: false }]])
expect(wrapper.emitted('generate')).toEqual([
[{ provider: undefined, generationOptions: {}, setPrimary: false }]
])
await wrapper.setProps({ open: false })
await flushPromises()
@@ -210,12 +224,41 @@ describe('镜头生产数据契约', () => {
await flushPromises()
button('确认生成首帧').click()
await flushPromises()
expect(wrapper.emitted('generate')?.at(-1)).toEqual([{ setPrimary: false }])
expect(wrapper.emitted('generate')?.at(-1)).toEqual([
{ provider: undefined, generationOptions: {}, setPrimary: false }
])
})
it('首帧生成前可预览后端最终选图规划和 Prompt', async () => {
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
new Response(
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
const path = String(url)
if (path.endsWith('/generation-models'))
return new Response(
JSON.stringify({
data: {
defaults: { imageProvider: 'seedream', videoProvider: 'seedance' },
images: [
{
type: 'image',
provider: 'seedream',
providerLabel: 'Seedream',
model: 'image-model',
modelLabel: 'Image Model',
supported: true,
enabled: true,
isDefault: true,
capabilities: {},
generationOptions: [],
defaults: {},
projectConstraints: []
}
],
videos: []
}
})
)
if (path.includes('/creative-profile')) return new Response(JSON.stringify({ data: null }))
return new Response(
JSON.stringify({
data: {
shotId: 'shot-1',
@@ -252,7 +295,7 @@ describe('镜头生产数据契约', () => {
}
})
)
)
})
vi.stubGlobal('fetch', fetcher)
wrapper = mount(KeyframeDialog, {
attachTo: document.body,
@@ -261,8 +304,9 @@ describe('镜头生产数据契约', () => {
await flushPromises()
button('预览实际生成输入').click()
await flushPromises()
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/storyboard-shots/shot-1/keyframe/preview')
expect(JSON.parse(String(fetcher.mock.calls[0]?.[1]?.body))).toMatchObject({
const previewCall = fetcher.mock.calls.find(([url]) => String(url).includes('/keyframe/preview'))
expect(previewCall?.[0]).toBe('/api/storyboard-shots/shot-1/keyframe/preview')
expect(JSON.parse(String(previewCall?.[1]?.body))).toMatchObject({
provider: 'seedream',
generationOptions: {}
})