style: 优化单次生成设置布局
This commit is contained in:
1 parent
7691346132
commit
90c67e1aa8
5 files changed
+244
-95
No files matched your search
@@ -2,7 +2,12 @@
|
||||
import { computed } from 'vue'
|
||||
import { NFormItem, NInputNumber, NSelect, NSwitch, NTag } from 'naive-ui'
|
||||
import type { SelectOption } from 'naive-ui'
|
||||
import type { CreativeProfileAspectRatio, GenerationModelCatalog, GenerationModelItem, GenerationOptions } from '../types'
|
||||
import type {
|
||||
CreativeProfileAspectRatio,
|
||||
GenerationModelCatalog,
|
||||
GenerationModelItem,
|
||||
GenerationOptions
|
||||
} from '../types'
|
||||
|
||||
const props = defineProps<{
|
||||
type: 'image' | 'video'
|
||||
@@ -17,7 +22,9 @@ const emit = defineEmits<{
|
||||
'update:options': [value: GenerationOptions]
|
||||
}>()
|
||||
|
||||
const models = computed(() => (props.type === 'image' ? props.catalog.images : props.catalog.videos).filter(item => item.enabled))
|
||||
const models = computed(() =>
|
||||
(props.type === 'image' ? props.catalog.images : props.catalog.videos).filter(item => item.enabled)
|
||||
)
|
||||
const model = computed(() => models.value.find(item => item.provider === props.provider) ?? models.value[0])
|
||||
const modelOptions = computed(() =>
|
||||
models.value.map(item => ({
|
||||
@@ -54,47 +61,102 @@ function selectValue(key: string): string | number | null {
|
||||
|
||||
<template>
|
||||
<div class="generation-model-controls">
|
||||
<NFormItem label="模型">
|
||||
<NSelect
|
||||
:value="model?.provider"
|
||||
:options="modelOptions"
|
||||
:disabled="disabled || !modelOptions.length"
|
||||
@update:value="selectProvider"
|
||||
/>
|
||||
<NFormItem class="generation-model-field generation-model-field-wide" label="模型">
|
||||
<div class="generation-model-field-control">
|
||||
<NSelect
|
||||
:value="model?.provider"
|
||||
:options="modelOptions"
|
||||
:disabled="disabled || !modelOptions.length"
|
||||
@update:value="selectProvider"
|
||||
/>
|
||||
</div>
|
||||
</NFormItem>
|
||||
|
||||
<template v-if="model">
|
||||
<NFormItem v-for="item in model.generationOptions" :key="item.key" :label="item.label">
|
||||
<NSwitch
|
||||
v-if="item.type === 'boolean'"
|
||||
:value="Boolean(options[item.key])"
|
||||
:disabled="disabled || item.userEditable === false"
|
||||
@update:value="updateOption(item.key, $event)"
|
||||
/>
|
||||
<NInputNumber
|
||||
v-else-if="item.type === 'integer' || item.type === 'number'"
|
||||
:value="typeof options[item.key] === 'number' ? Number(options[item.key]) : null"
|
||||
:min="item.min"
|
||||
:max="item.max"
|
||||
:disabled="disabled || item.userEditable === false"
|
||||
@update:value="updateOption(item.key, $event)"
|
||||
/>
|
||||
<NSelect
|
||||
v-else
|
||||
:value="selectValue(item.key)"
|
||||
:options="choices(item)"
|
||||
:disabled="disabled || item.userEditable === false"
|
||||
@update:value="updateOption(item.key, $event)"
|
||||
/>
|
||||
<p v-if="item.description" class="mt-1 text-xs text-muted">{{ item.description }}</p>
|
||||
<NFormItem
|
||||
v-for="item in model.generationOptions"
|
||||
:key="item.key"
|
||||
class="generation-model-field"
|
||||
:label="item.label"
|
||||
>
|
||||
<div class="generation-model-field-control">
|
||||
<div v-if="item.type === 'boolean'" class="generation-model-toggle">
|
||||
<NSwitch
|
||||
:value="Boolean(options[item.key])"
|
||||
:disabled="disabled || item.userEditable === false"
|
||||
@update:value="updateOption(item.key, $event)"
|
||||
/>
|
||||
<span class="text-xs">{{ options[item.key] ? '已启用' : '未启用' }}</span>
|
||||
</div>
|
||||
<NInputNumber
|
||||
v-else-if="item.type === 'integer' || item.type === 'number'"
|
||||
:value="typeof options[item.key] === 'number' ? Number(options[item.key]) : null"
|
||||
:min="item.min"
|
||||
:max="item.max"
|
||||
:disabled="disabled || item.userEditable === false"
|
||||
@update:value="updateOption(item.key, $event)"
|
||||
/>
|
||||
<NSelect
|
||||
v-else
|
||||
:value="selectValue(item.key)"
|
||||
:options="choices(item)"
|
||||
:disabled="disabled || item.userEditable === false"
|
||||
@update:value="updateOption(item.key, $event)"
|
||||
/>
|
||||
<p v-if="item.description" class="generation-model-description">{{ item.description }}</p>
|
||||
</div>
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem label="画幅比例">
|
||||
<div class="flex items-center gap-2">
|
||||
<NFormItem class="generation-model-field" label="画幅比例">
|
||||
<div class="generation-model-static">
|
||||
<NTag size="small">{{ aspectRatio }}</NTag>
|
||||
<span class="text-xs text-muted">项目画幅 · 单次生成不可覆盖</span>
|
||||
<span class="generation-model-description">项目画幅 · 单次生成不可覆盖</span>
|
||||
</div>
|
||||
</NFormItem>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../../styles/styles.css";
|
||||
.generation-model-controls {
|
||||
@apply grid grid-cols-[repeat(2,_minmax(0,_1fr))] items-start gap-x-5 gap-y-5;
|
||||
}
|
||||
.generation-model-field {
|
||||
@apply min-w-0 mb-0;
|
||||
}
|
||||
.generation-model-field-wide {
|
||||
@apply col-span-2;
|
||||
}
|
||||
.generation-model-field :deep(.n-form-item-label) {
|
||||
min-height: 27px;
|
||||
padding: 0 0 7px;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.generation-model-field :deep(.n-form-item-blank) {
|
||||
@apply min-h-[34px] min-w-0;
|
||||
}
|
||||
.generation-model-field-control {
|
||||
@apply flex w-full min-w-0 flex-col items-stretch gap-1.5;
|
||||
}
|
||||
.generation-model-field-control :deep(.n-input-number),
|
||||
.generation-model-field-control :deep(.n-select) {
|
||||
@apply w-full;
|
||||
}
|
||||
.generation-model-toggle,
|
||||
.generation-model-static {
|
||||
@apply flex min-h-[34px] min-w-0 items-center gap-2.5;
|
||||
}
|
||||
.generation-model-description {
|
||||
@apply m-0 text-[11px] leading-5 text-muted;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.generation-model-controls {
|
||||
@apply grid-cols-[minmax(0,_1fr)] gap-y-4;
|
||||
}
|
||||
.generation-model-field-wide {
|
||||
@apply col-span-1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import ProviderInputInspector from './ProviderInputInspector.vue'
|
||||
import { NAlert, NButton, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import { NAlert, NButton, NCollapse, NCollapseItem, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { ExternalLink, ImagePlus, RefreshCw } from '@lucide/vue'
|
||||
import { AssetImage, StatusBadge } from '../../../components/ui'
|
||||
@@ -38,7 +38,11 @@ import ModelCapabilities from './ModelCapabilities.vue'
|
||||
import type { QualityTarget } from '../quality.types'
|
||||
import { sessionKeyframePassed, sessionVideoValidation } from '../quality'
|
||||
import { generationConfigApi } from '../../generation-config/api'
|
||||
import type { CreativeProfileAspectRatio, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
import type {
|
||||
CreativeProfileAspectRatio,
|
||||
GenerationModelCatalog,
|
||||
GenerationOptions
|
||||
} from '../../generation-config/types'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
|
||||
/** 单镜头生产面板只负责正式资产,不修改上游导演设计与即时状态。 */
|
||||
@@ -86,9 +90,7 @@ const query = usePolling(
|
||||
)
|
||||
/** 单独读取已保存的提示词,查询失败不影响首帧和视频资产展示。 */
|
||||
const promptQuery = usePolling(key, (shotId, signal) => storyboardApi.videoPrompt(shotId, signal), false)
|
||||
const savedPrompt = computed(() =>
|
||||
promptQuery.data.value?.shotId === key.value ? promptQuery.data.value : null
|
||||
)
|
||||
const savedPrompt = computed(() => (promptQuery.data.value?.shotId === key.value ? promptQuery.data.value : null))
|
||||
/** 当前视频生成规格的首帧和主体参考图,独立查询避免影响资产列表。 */
|
||||
const videoInputQuery = usePolling(key, (shotId, signal) => productionApi.videoGenerationSpec(shotId, signal), false)
|
||||
const currentVideoInput = computed(() =>
|
||||
@@ -178,9 +180,7 @@ const canGenerateVideo = computed(
|
||||
(!currentKeyframe.value || keyframePassed(currentKeyframe.value.id) !== false)
|
||||
)
|
||||
const keyframeStale = computed(() => !!props.keyframeReadiness?.primaryKeyframeStale)
|
||||
const keyframeCandidates = computed(() =>
|
||||
keyframes.value.filter(item => item.id !== currentKeyframe.value?.id)
|
||||
)
|
||||
const keyframeCandidates = computed(() => keyframes.value.filter(item => item.id !== currentKeyframe.value?.id))
|
||||
/** 质量历史尚无 GET;只消费当前会话中该候选的真实校验结果。 */
|
||||
function keyframePassed(assetId: string) {
|
||||
return sessionKeyframePassed(props.projectId, props.shot.shotId, assetId)
|
||||
@@ -389,9 +389,7 @@ async function inspectSpecs() {
|
||||
<p v-else-if="promptQuery.loading.value" role="status" class="mt-4 text-xs text-muted">
|
||||
正在读取视频提示词…
|
||||
</p>
|
||||
<p v-else-if="!promptQuery.error.value" class="mt-4 text-xs text-muted">
|
||||
尚未生成本镜视频提示词。
|
||||
</p>
|
||||
<p v-else-if="!promptQuery.error.value" class="mt-4 text-xs text-muted">尚未生成本镜视频提示词。</p>
|
||||
<NAlert v-if="promptQuery.error.value" role="alert" type="warning" :show-icon="false" class="mt-4 text-xs">
|
||||
提示词读取失败:{{ promptQuery.error.value }}
|
||||
<NButton text size="small" @click="promptQuery.refresh">重试</NButton>
|
||||
@@ -441,9 +439,7 @@ async function inspectSpecs() {
|
||||
@quality="openQuality('keyframe', currentKeyframe.id)"
|
||||
/>
|
||||
</div>
|
||||
<p v-else class="mt-4 text-xs text-muted">
|
||||
尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。
|
||||
</p>
|
||||
<p v-else class="mt-4 text-xs text-muted">尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。</p>
|
||||
<NAlert
|
||||
v-if="currentKeyframe && keyframePassed(currentKeyframe.id) === false"
|
||||
type="error"
|
||||
@@ -516,7 +512,11 @@ async function inspectSpecs() {
|
||||
<div class="min-w-0 p-2 text-center text-xs">
|
||||
<p class="font-medium">视频输入首帧</p>
|
||||
<p class="mt-1 text-[11px] text-muted">
|
||||
{{ currentVideoInput.providerInputKeyframe.source === 'provider_variant' ? '模型专用变体' : '当前主首帧' }}
|
||||
{{
|
||||
currentVideoInput.providerInputKeyframe.source === 'provider_variant'
|
||||
? '模型专用变体'
|
||||
: '当前主首帧'
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
@@ -534,7 +534,9 @@ async function inspectSpecs() {
|
||||
/>
|
||||
</div>
|
||||
<div class="min-w-0 p-2 text-center text-xs">
|
||||
<p class="truncate font-medium" :title="reference.subjectName">{{ reference.subjectName }}</p>
|
||||
<p class="truncate font-medium" :title="reference.subjectName">
|
||||
{{ reference.subjectName }}
|
||||
</p>
|
||||
<p class="mt-1 truncate text-[11px] text-muted" :title="reference.subjectFormName">
|
||||
{{ reference.subjectFormName }}
|
||||
</p>
|
||||
@@ -547,8 +549,14 @@ async function inspectSpecs() {
|
||||
<div v-else class="mt-4 text-xs text-muted">
|
||||
<p>当前生成规格尚未就绪,请检查视频提示词、主首帧与主体参考图。</p>
|
||||
<p v-if="videoInputQuery.error.value" class="mt-2 break-words">{{ videoInputQuery.error.value }}</p>
|
||||
<NButton v-if="videoInputQuery.error.value" text size="small" class="mt-2"
|
||||
@click="videoInputQuery.refresh">重新读取</NButton>
|
||||
<NButton
|
||||
v-if="videoInputQuery.error.value"
|
||||
text
|
||||
size="small"
|
||||
class="mt-2"
|
||||
@click="videoInputQuery.refresh"
|
||||
>重新读取</NButton
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
<NAlert
|
||||
@@ -648,36 +656,48 @@ async function inspectSpecs() {
|
||||
<p v-if="videos.some(item => !item.isPrimary)" class="mt-3 text-xs text-muted">
|
||||
质量链状态来自后端持久化记录;手动晋升候选仍需在当前页面完成一次视觉校验。自动质量任务通过后会直接更新主视频。
|
||||
</p>
|
||||
<section v-if="generationCatalog" class="surface-inset mt-4 p-4" aria-label="本次视频生成模型设置">
|
||||
<p class="text-xs font-medium">本次生成设置</p>
|
||||
<p class="mt-1 text-xs text-muted">仅覆盖当前镜头本次生成,不修改项目默认模型。</p>
|
||||
<GenerationModelControls
|
||||
class="mt-4"
|
||||
type="video"
|
||||
:catalog="generationCatalog"
|
||||
:provider="videoProvider"
|
||||
:options="videoGenerationOptions"
|
||||
:aspect-ratio="projectAspectRatio"
|
||||
:disabled="assetBlocked"
|
||||
@update:provider="videoProvider = $event"
|
||||
@update:options="videoGenerationOptions = $event"
|
||||
/>
|
||||
<div class="mt-3">
|
||||
<p class="mb-2 text-xs font-medium">输入模式</p>
|
||||
<NSelect
|
||||
:value="videoInputModeOverride"
|
||||
<section
|
||||
v-if="generationCatalog"
|
||||
class="generation-settings-panel surface-inset mt-4"
|
||||
aria-label="本次视频生成模型设置"
|
||||
>
|
||||
<div class="generation-settings-content">
|
||||
<div>
|
||||
<h6 class="text-sm font-medium">本次生成设置</h6>
|
||||
<p class="mt-1 text-[11px] leading-5 text-muted">
|
||||
仅覆盖当前镜头本次生成,不修改项目默认模型。
|
||||
</p>
|
||||
</div>
|
||||
<GenerationModelControls
|
||||
class="mt-5"
|
||||
type="video"
|
||||
:catalog="generationCatalog"
|
||||
:provider="videoProvider"
|
||||
:options="videoGenerationOptions"
|
||||
:aspect-ratio="projectAspectRatio"
|
||||
:disabled="assetBlocked"
|
||||
:options="[
|
||||
{
|
||||
label: `自动(推荐:${videoInputPlan?.inputMode === 'omni_reference' ? '全模态参考' : '首帧模式'})`,
|
||||
value: 'auto'
|
||||
},
|
||||
{ label: '首帧模式', value: 'first_frame' },
|
||||
{ label: '全模态参考', value: 'omni_reference' }
|
||||
]"
|
||||
@update:value="videoInputModeOverride = $event"
|
||||
@update:provider="videoProvider = $event"
|
||||
@update:options="videoGenerationOptions = $event"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-muted">自动模式遵循后端 Planner;手动选择只影响当前镜头本次生成。</p>
|
||||
<div class="generation-input-mode">
|
||||
<p class="generation-input-mode-label">输入模式</p>
|
||||
<NSelect
|
||||
:value="videoInputModeOverride"
|
||||
:disabled="assetBlocked"
|
||||
:options="[
|
||||
{
|
||||
label: `自动(推荐:${videoInputPlan?.inputMode === 'omni_reference' ? '全模态参考' : '首帧模式'})`,
|
||||
value: 'auto'
|
||||
},
|
||||
{ label: '首帧模式', value: 'first_frame' },
|
||||
{ label: '全模态参考', value: 'omni_reference' }
|
||||
]"
|
||||
@update:value="videoInputModeOverride = $event"
|
||||
/>
|
||||
<p class="mt-1.5 text-[11px] leading-5 text-muted">
|
||||
自动模式遵循后端 Planner;手动选择只影响当前镜头本次生成。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<NAlert v-else-if="generationCatalogError" type="warning" :show-icon="false" class="mt-4 text-xs">
|
||||
@@ -853,11 +873,26 @@ async function inspectSpecs() {
|
||||
.production-video {
|
||||
@apply block w-full aspect-square bg-[#080808] object-contain;
|
||||
}
|
||||
.generation-settings-panel {
|
||||
@apply p-5;
|
||||
}
|
||||
.generation-settings-content {
|
||||
@apply w-full max-w-[1120px];
|
||||
}
|
||||
.generation-input-mode {
|
||||
@apply mt-5 w-full max-w-[550px];
|
||||
}
|
||||
.generation-input-mode-label {
|
||||
@apply mb-[7px] text-xs font-medium leading-5;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.keyframe-grid,
|
||||
.video-input-grid,
|
||||
.video-grid {
|
||||
@apply grid-cols-[repeat(2,_minmax(0,_1fr))];
|
||||
}
|
||||
.generation-settings-panel {
|
||||
@apply p-4;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,6 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import GenerationModelControls from '../../../src/features/generation-config/components/GenerationModelControls.vue'
|
||||
import type { GenerationModelCatalog } from '../../../src/features/generation-config/types'
|
||||
@@ -40,6 +41,14 @@ const catalog: GenerationModelCatalog = {
|
||||
}
|
||||
|
||||
describe('单次生成模型控件', () => {
|
||||
it('字段采用双列栅格,控件与说明文字纵向排列并在移动端回落单列', () => {
|
||||
const source = readFileSync('src/features/generation-config/components/GenerationModelControls.vue', 'utf8')
|
||||
expect(source).toContain('class="generation-model-field-control"')
|
||||
expect(source).toMatch(/\.generation-model-controls\s*\{[^}]*grid-cols-\[repeat\(2,_minmax\(0,_1fr\)\)\]/)
|
||||
expect(source).toMatch(/\.generation-model-field-control\s*\{[^}]*flex-col[^}]*gap-1\.5/)
|
||||
expect(source).toMatch(/@media \(max-width: 760px\)[\s\S]*?grid-cols-\[minmax\(0,_1fr\)\]/)
|
||||
})
|
||||
|
||||
it('切换图片模型时只使用目标模型 defaults,不保留上一个模型参数', async () => {
|
||||
const wrapper = mount(GenerationModelControls, {
|
||||
props: {
|
||||
|
||||
@@ -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: {}
|
||||
})
|
||||
|
||||
@@ -135,12 +135,11 @@ describe('后端 API 契约', () => {
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
expect(await projectsApi.list()).toEqual([{ id: 'p1' }])
|
||||
expect(await projectsApi.create({ title: '测试项目', topic: '故事', style: '悬疑', episodeCount: 3 })).toEqual({
|
||||
expect(await projectsApi.create({ topic: '故事', style: '悬疑', episodeCount: 3 })).toEqual({
|
||||
projectId: 'p2',
|
||||
status: 'generating'
|
||||
})
|
||||
expect(JSON.parse(fetcher.mock.calls[1]![1].body as string)).toEqual({
|
||||
title: '测试项目',
|
||||
topic: '故事',
|
||||
style: '悬疑',
|
||||
episodeCount: 3
|
||||
|
||||
Reference in new issue
Block a user