feat(short-drama-agent-front): 完善镜头定位与项目配置

This commit is contained in:
GJ committed 2026-10-08 19:45:26 +08:00
1 parent 470b52e26d
commit 5b134207b8
66 files changed
+2042 -984

No files matched your search

@@ -4,6 +4,11 @@ import { describe, expect, it } from 'vitest'
import GenerationOptionFields from '../../../src/features/generation-config/components/GenerationOptionFields.vue'
import type { GenerationOptionSchema } from '../../../src/features/generation-config/types'
/**
* 挂载实际模型参数组件以核对下拉枚举与当前值。
* @param schemas 后端参数目录
* @returns 挂载后的组件
*/
function mountFields(schemas: GenerationOptionSchema[]) {
return mount(GenerationOptionFields, {
props: { schemas, modelValue: { size: '2K', durationSeconds: 4, seed: 1 } }
@@ -11,20 +16,24 @@ function mountFields(schemas: GenerationOptionSchema[]) {
}
describe('生成模型参数字段', () => {
it('图片尺寸使用下拉框并保留标准尺寸与当前值', () => {
it('图片尺寸只保留当前 Provider 枚举、默认值与当前值', () => {
const wrapper = mountFields([
{ key: 'size', label: '图片尺寸', type: 'size', required: true, providerDefault: 'auto' }
{
key: 'size',
label: '图片尺寸',
type: 'size',
required: true,
providerDefault: 'auto',
options: [{ label: '目录支持尺寸', value: '2048*2048' }]
}
])
const select = wrapper.getComponent(NSelect)
expect(select.props('clearable')).toBe(false)
expect(select.props('options')).toEqual(
expect.arrayContaining([
expect.objectContaining({ value: '1K' }),
expect.objectContaining({ value: '1.5K' }),
expect.objectContaining({ value: '2K' }),
expect.objectContaining({ value: 'auto' })
])
)
expect(select.props('options')).toEqual([
{ label: '目录支持尺寸', value: '2048*2048' },
{ label: 'auto', value: 'auto' },
{ label: '2K', value: '2K' }
])
expect(wrapper.findComponent(NInputNumber).exists()).toBe(false)
})
@@ -0,0 +1,113 @@
import { describe, expect, it } from 'vitest'
import { creativeProfileDraft, creativeProfileIssues } from '../../../src/features/generation-config/profile-draft'
import type { CreativeProfileInput, GenerationModelCatalog } from '../../../src/features/generation-config/types'
/** 后端已保存的竖屏自定义尺寸,不限于目录的尺寸预设。 */
const saved: CreativeProfileInput = {
aspectRatio: '9:16',
imageProvider: 'qwen-image',
imageModel: 'qwen-image-3.0-pro',
imageOptions: { size: '1080*1920', count: 1, promptExtend: false },
videoProvider: 'wan',
videoModel: 'wan3.0-video',
videoOptions: { aspectRatio: 'adaptive', resolution: '1080P', duration: 5, audio: false }
}
describe('项目配置编辑草稿', () => {
it('读取与保存草稿保留真实自定义尺寸和未显示的供应方参数', () => {
const draft = creativeProfileDraft(saved)
expect(draft.imageOptions).toEqual({ size: '1080*1920', count: 1, promptExtend: false })
expect(draft.videoOptions).toEqual({ aspectRatio: 'adaptive', resolution: '1080P', duration: 5, audio: false })
})
it('未保存的图片和视频参数修改不会污染实际已保存对象', () => {
const draft = creativeProfileDraft(saved)
draft.imageOptions.size = '2048*2048'
draft.videoOptions.duration = 10
expect(saved.imageOptions.size).toBe('1080*1920')
expect(saved.videoOptions.duration).toBe(5)
})
})
/** 模型目录枚举与数字限制以真实后端 schema 规则为准。 */
const catalog: GenerationModelCatalog = {
defaults: { imageProvider: 'qwen-image', videoProvider: 'wan' },
images: [
{
type: 'image',
provider: 'qwen-image',
providerLabel: 'Qwen',
model: 'qwen-image-3.0-pro',
modelLabel: 'Qwen',
supported: true,
enabled: true,
isDefault: true,
capabilities: {},
defaults: {},
projectConstraints: [],
generationOptions: [
{
key: 'size',
label: '图片尺寸',
type: 'size',
required: true,
options: [{ label: '竖屏', value: '1536*2688' }]
},
{ key: 'count', label: '数量', type: 'integer', required: true, min: 1, max: 1 }
]
}
],
videos: [
{
type: 'video',
provider: 'wan',
providerLabel: 'Wan',
model: 'wan3.0-video',
modelLabel: 'Wan',
supported: true,
enabled: true,
isDefault: true,
capabilities: {},
defaults: {},
projectConstraints: [],
generationOptions: [
{
key: 'duration',
label: '时长',
type: 'integer',
required: true,
min: 2,
max: 30,
specialValues: [{ label: '自动', value: -1 }]
},
{ key: 'audio', label: '音轨', type: 'boolean', required: true }
]
}
]
}
describe('项目配置保存前校验', () => {
it('保留但提示不再支持的历史尺寸,选择有效尺寸后可保存', () => {
const draft = creativeProfileDraft(saved)
expect(creativeProfileIssues(draft, catalog)).toHaveLength(1)
expect(draft.imageOptions.size).toBe('1080*1920')
draft.imageOptions.size = '1536*2688'
expect(creativeProfileIssues(draft, catalog)).toEqual([])
})
it('拒绝无效数值与缺失必填参数,允许后端支持的特殊时长', () => {
const draft = creativeProfileDraft(saved)
draft.imageOptions.size = '1536*2688'
draft.imageOptions.count = 2
delete draft.videoOptions.audio
draft.videoOptions.duration = -1
expect(creativeProfileIssues(draft, catalog)).toHaveLength(2)
draft.imageOptions.count = 1
draft.videoOptions.audio = false
expect(creativeProfileIssues(draft, catalog)).toEqual([])
})
it('模型更新后拒绝目录中已不存在的旧模型', () => {
const draft = creativeProfileDraft(saved)
draft.imageOptions.size = '1536*2688'
draft.imageModel = 'removed-image-model'
expect(creativeProfileIssues(draft, catalog)).toHaveLength(1)
})
})