style: 优化单次生成设置布局
This commit is contained in:
1 parent
7691346132
commit
90c67e1aa8
5 files changed
+197
-48
No files matched your search
@@ -2,7 +2,12 @@
|
|||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { NFormItem, NInputNumber, NSelect, NSwitch, NTag } from 'naive-ui'
|
import { NFormItem, NInputNumber, NSelect, NSwitch, NTag } from 'naive-ui'
|
||||||
import type { SelectOption } 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<{
|
const props = defineProps<{
|
||||||
type: 'image' | 'video'
|
type: 'image' | 'video'
|
||||||
@@ -17,7 +22,9 @@ const emit = defineEmits<{
|
|||||||
'update:options': [value: GenerationOptions]
|
'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 model = computed(() => models.value.find(item => item.provider === props.provider) ?? models.value[0])
|
||||||
const modelOptions = computed(() =>
|
const modelOptions = computed(() =>
|
||||||
models.value.map(item => ({
|
models.value.map(item => ({
|
||||||
@@ -54,23 +61,33 @@ function selectValue(key: string): string | number | null {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="generation-model-controls">
|
<div class="generation-model-controls">
|
||||||
<NFormItem label="模型">
|
<NFormItem class="generation-model-field generation-model-field-wide" label="模型">
|
||||||
|
<div class="generation-model-field-control">
|
||||||
<NSelect
|
<NSelect
|
||||||
:value="model?.provider"
|
:value="model?.provider"
|
||||||
:options="modelOptions"
|
:options="modelOptions"
|
||||||
:disabled="disabled || !modelOptions.length"
|
:disabled="disabled || !modelOptions.length"
|
||||||
@update:value="selectProvider"
|
@update:value="selectProvider"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
|
|
||||||
<template v-if="model">
|
<template v-if="model">
|
||||||
<NFormItem v-for="item in model.generationOptions" :key="item.key" :label="item.label">
|
<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
|
<NSwitch
|
||||||
v-if="item.type === 'boolean'"
|
|
||||||
:value="Boolean(options[item.key])"
|
:value="Boolean(options[item.key])"
|
||||||
:disabled="disabled || item.userEditable === false"
|
:disabled="disabled || item.userEditable === false"
|
||||||
@update:value="updateOption(item.key, $event)"
|
@update:value="updateOption(item.key, $event)"
|
||||||
/>
|
/>
|
||||||
|
<span class="text-xs">{{ options[item.key] ? '已启用' : '未启用' }}</span>
|
||||||
|
</div>
|
||||||
<NInputNumber
|
<NInputNumber
|
||||||
v-else-if="item.type === 'integer' || item.type === 'number'"
|
v-else-if="item.type === 'integer' || item.type === 'number'"
|
||||||
:value="typeof options[item.key] === 'number' ? Number(options[item.key]) : null"
|
:value="typeof options[item.key] === 'number' ? Number(options[item.key]) : null"
|
||||||
@@ -86,15 +103,60 @@ function selectValue(key: string): string | number | null {
|
|||||||
:disabled="disabled || item.userEditable === false"
|
:disabled="disabled || item.userEditable === false"
|
||||||
@update:value="updateOption(item.key, $event)"
|
@update:value="updateOption(item.key, $event)"
|
||||||
/>
|
/>
|
||||||
<p v-if="item.description" class="mt-1 text-xs text-muted">{{ item.description }}</p>
|
<p v-if="item.description" class="generation-model-description">{{ item.description }}</p>
|
||||||
|
</div>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
|
|
||||||
<NFormItem label="画幅比例">
|
<NFormItem class="generation-model-field" label="画幅比例">
|
||||||
<div class="flex items-center gap-2">
|
<div class="generation-model-static">
|
||||||
<NTag size="small">{{ aspectRatio }}</NTag>
|
<NTag size="small">{{ aspectRatio }}</NTag>
|
||||||
<span class="text-xs text-muted">项目画幅 · 单次生成不可覆盖</span>
|
<span class="generation-model-description">项目画幅 · 单次生成不可覆盖</span>
|
||||||
</div>
|
</div>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</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">
|
<script setup lang="ts">
|
||||||
import ProviderInputInspector from './ProviderInputInspector.vue'
|
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 { computed, onMounted, ref, watch } from 'vue'
|
||||||
import { ExternalLink, ImagePlus, RefreshCw } from '@lucide/vue'
|
import { ExternalLink, ImagePlus, RefreshCw } from '@lucide/vue'
|
||||||
import { AssetImage, StatusBadge } from '../../../components/ui'
|
import { AssetImage, StatusBadge } from '../../../components/ui'
|
||||||
@@ -38,7 +38,11 @@ import ModelCapabilities from './ModelCapabilities.vue'
|
|||||||
import type { QualityTarget } from '../quality.types'
|
import type { QualityTarget } from '../quality.types'
|
||||||
import { sessionKeyframePassed, sessionVideoValidation } from '../quality'
|
import { sessionKeyframePassed, sessionVideoValidation } from '../quality'
|
||||||
import { generationConfigApi } from '../../generation-config/api'
|
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'
|
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 promptQuery = usePolling(key, (shotId, signal) => storyboardApi.videoPrompt(shotId, signal), false)
|
||||||
const savedPrompt = computed(() =>
|
const savedPrompt = computed(() => (promptQuery.data.value?.shotId === key.value ? promptQuery.data.value : null))
|
||||||
promptQuery.data.value?.shotId === key.value ? promptQuery.data.value : null
|
|
||||||
)
|
|
||||||
/** 当前视频生成规格的首帧和主体参考图,独立查询避免影响资产列表。 */
|
/** 当前视频生成规格的首帧和主体参考图,独立查询避免影响资产列表。 */
|
||||||
const videoInputQuery = usePolling(key, (shotId, signal) => productionApi.videoGenerationSpec(shotId, signal), false)
|
const videoInputQuery = usePolling(key, (shotId, signal) => productionApi.videoGenerationSpec(shotId, signal), false)
|
||||||
const currentVideoInput = computed(() =>
|
const currentVideoInput = computed(() =>
|
||||||
@@ -178,9 +180,7 @@ const canGenerateVideo = computed(
|
|||||||
(!currentKeyframe.value || keyframePassed(currentKeyframe.value.id) !== false)
|
(!currentKeyframe.value || keyframePassed(currentKeyframe.value.id) !== false)
|
||||||
)
|
)
|
||||||
const keyframeStale = computed(() => !!props.keyframeReadiness?.primaryKeyframeStale)
|
const keyframeStale = computed(() => !!props.keyframeReadiness?.primaryKeyframeStale)
|
||||||
const keyframeCandidates = computed(() =>
|
const keyframeCandidates = computed(() => keyframes.value.filter(item => item.id !== currentKeyframe.value?.id))
|
||||||
keyframes.value.filter(item => item.id !== currentKeyframe.value?.id)
|
|
||||||
)
|
|
||||||
/** 质量历史尚无 GET;只消费当前会话中该候选的真实校验结果。 */
|
/** 质量历史尚无 GET;只消费当前会话中该候选的真实校验结果。 */
|
||||||
function keyframePassed(assetId: string) {
|
function keyframePassed(assetId: string) {
|
||||||
return sessionKeyframePassed(props.projectId, props.shot.shotId, assetId)
|
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 v-else-if="promptQuery.loading.value" role="status" class="mt-4 text-xs text-muted">
|
||||||
正在读取视频提示词…
|
正在读取视频提示词…
|
||||||
</p>
|
</p>
|
||||||
<p v-else-if="!promptQuery.error.value" class="mt-4 text-xs text-muted">
|
<p v-else-if="!promptQuery.error.value" class="mt-4 text-xs text-muted">尚未生成本镜视频提示词。</p>
|
||||||
尚未生成本镜视频提示词。
|
|
||||||
</p>
|
|
||||||
<NAlert v-if="promptQuery.error.value" role="alert" type="warning" :show-icon="false" class="mt-4 text-xs">
|
<NAlert v-if="promptQuery.error.value" role="alert" type="warning" :show-icon="false" class="mt-4 text-xs">
|
||||||
提示词读取失败:{{ promptQuery.error.value }}
|
提示词读取失败:{{ promptQuery.error.value }}
|
||||||
<NButton text size="small" @click="promptQuery.refresh">重试</NButton>
|
<NButton text size="small" @click="promptQuery.refresh">重试</NButton>
|
||||||
@@ -441,9 +439,7 @@ async function inspectSpecs() {
|
|||||||
@quality="openQuality('keyframe', currentKeyframe.id)"
|
@quality="openQuality('keyframe', currentKeyframe.id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p v-else class="mt-4 text-xs text-muted">
|
<p v-else class="mt-4 text-xs text-muted">尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。</p>
|
||||||
尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。
|
|
||||||
</p>
|
|
||||||
<NAlert
|
<NAlert
|
||||||
v-if="currentKeyframe && keyframePassed(currentKeyframe.id) === false"
|
v-if="currentKeyframe && keyframePassed(currentKeyframe.id) === false"
|
||||||
type="error"
|
type="error"
|
||||||
@@ -516,7 +512,11 @@ async function inspectSpecs() {
|
|||||||
<div class="min-w-0 p-2 text-center text-xs">
|
<div class="min-w-0 p-2 text-center text-xs">
|
||||||
<p class="font-medium">视频输入首帧</p>
|
<p class="font-medium">视频输入首帧</p>
|
||||||
<p class="mt-1 text-[11px] text-muted">
|
<p class="mt-1 text-[11px] text-muted">
|
||||||
{{ currentVideoInput.providerInputKeyframe.source === 'provider_variant' ? '模型专用变体' : '当前主首帧' }}
|
{{
|
||||||
|
currentVideoInput.providerInputKeyframe.source === 'provider_variant'
|
||||||
|
? '模型专用变体'
|
||||||
|
: '当前主首帧'
|
||||||
|
}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
@@ -534,7 +534,9 @@ async function inspectSpecs() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="min-w-0 p-2 text-center text-xs">
|
<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">
|
<p class="mt-1 truncate text-[11px] text-muted" :title="reference.subjectFormName">
|
||||||
{{ reference.subjectFormName }}
|
{{ reference.subjectFormName }}
|
||||||
</p>
|
</p>
|
||||||
@@ -547,8 +549,14 @@ async function inspectSpecs() {
|
|||||||
<div v-else class="mt-4 text-xs text-muted">
|
<div v-else class="mt-4 text-xs text-muted">
|
||||||
<p>当前生成规格尚未就绪,请检查视频提示词、主首帧与主体参考图。</p>
|
<p>当前生成规格尚未就绪,请检查视频提示词、主首帧与主体参考图。</p>
|
||||||
<p v-if="videoInputQuery.error.value" class="mt-2 break-words">{{ videoInputQuery.error.value }}</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"
|
<NButton
|
||||||
@click="videoInputQuery.refresh">重新读取</NButton>
|
v-if="videoInputQuery.error.value"
|
||||||
|
text
|
||||||
|
size="small"
|
||||||
|
class="mt-2"
|
||||||
|
@click="videoInputQuery.refresh"
|
||||||
|
>重新读取</NButton
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<NAlert
|
<NAlert
|
||||||
@@ -648,11 +656,20 @@ async function inspectSpecs() {
|
|||||||
<p v-if="videos.some(item => !item.isPrimary)" class="mt-3 text-xs text-muted">
|
<p v-if="videos.some(item => !item.isPrimary)" class="mt-3 text-xs text-muted">
|
||||||
质量链状态来自后端持久化记录;手动晋升候选仍需在当前页面完成一次视觉校验。自动质量任务通过后会直接更新主视频。
|
质量链状态来自后端持久化记录;手动晋升候选仍需在当前页面完成一次视觉校验。自动质量任务通过后会直接更新主视频。
|
||||||
</p>
|
</p>
|
||||||
<section v-if="generationCatalog" class="surface-inset mt-4 p-4" aria-label="本次视频生成模型设置">
|
<section
|
||||||
<p class="text-xs font-medium">本次生成设置</p>
|
v-if="generationCatalog"
|
||||||
<p class="mt-1 text-xs text-muted">仅覆盖当前镜头本次生成,不修改项目默认模型。</p>
|
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
|
<GenerationModelControls
|
||||||
class="mt-4"
|
class="mt-5"
|
||||||
type="video"
|
type="video"
|
||||||
:catalog="generationCatalog"
|
:catalog="generationCatalog"
|
||||||
:provider="videoProvider"
|
:provider="videoProvider"
|
||||||
@@ -662,8 +679,8 @@ async function inspectSpecs() {
|
|||||||
@update:provider="videoProvider = $event"
|
@update:provider="videoProvider = $event"
|
||||||
@update:options="videoGenerationOptions = $event"
|
@update:options="videoGenerationOptions = $event"
|
||||||
/>
|
/>
|
||||||
<div class="mt-3">
|
<div class="generation-input-mode">
|
||||||
<p class="mb-2 text-xs font-medium">输入模式</p>
|
<p class="generation-input-mode-label">输入模式</p>
|
||||||
<NSelect
|
<NSelect
|
||||||
:value="videoInputModeOverride"
|
:value="videoInputModeOverride"
|
||||||
:disabled="assetBlocked"
|
:disabled="assetBlocked"
|
||||||
@@ -677,7 +694,10 @@ async function inspectSpecs() {
|
|||||||
]"
|
]"
|
||||||
@update:value="videoInputModeOverride = $event"
|
@update:value="videoInputModeOverride = $event"
|
||||||
/>
|
/>
|
||||||
<p class="mt-1 text-xs text-muted">自动模式遵循后端 Planner;手动选择只影响当前镜头本次生成。</p>
|
<p class="mt-1.5 text-[11px] leading-5 text-muted">
|
||||||
|
自动模式遵循后端 Planner;手动选择只影响当前镜头本次生成。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<NAlert v-else-if="generationCatalogError" type="warning" :show-icon="false" class="mt-4 text-xs">
|
<NAlert v-else-if="generationCatalogError" type="warning" :show-icon="false" class="mt-4 text-xs">
|
||||||
@@ -853,11 +873,26 @@ async function inspectSpecs() {
|
|||||||
.production-video {
|
.production-video {
|
||||||
@apply block w-full aspect-square bg-[#080808] object-contain;
|
@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) {
|
@media (max-width: 760px) {
|
||||||
.keyframe-grid,
|
.keyframe-grid,
|
||||||
.video-input-grid,
|
.video-input-grid,
|
||||||
.video-grid {
|
.video-grid {
|
||||||
@apply grid-cols-[repeat(2,_minmax(0,_1fr))];
|
@apply grid-cols-[repeat(2,_minmax(0,_1fr))];
|
||||||
}
|
}
|
||||||
|
.generation-settings-panel {
|
||||||
|
@apply p-4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import { NSelect } from 'naive-ui'
|
import { NSelect } from 'naive-ui'
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import GenerationModelControls from '../../../src/features/generation-config/components/GenerationModelControls.vue'
|
import GenerationModelControls from '../../../src/features/generation-config/components/GenerationModelControls.vue'
|
||||||
import type { GenerationModelCatalog } from '../../../src/features/generation-config/types'
|
import type { GenerationModelCatalog } from '../../../src/features/generation-config/types'
|
||||||
@@ -40,6 +41,14 @@ const catalog: GenerationModelCatalog = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('单次生成模型控件', () => {
|
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 () => {
|
it('切换图片模型时只使用目标模型 defaults,不保留上一个模型参数', async () => {
|
||||||
const wrapper = mount(GenerationModelControls, {
|
const wrapper = mount(GenerationModelControls, {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -33,17 +33,29 @@ describe('镜头生产数据契约', () => {
|
|||||||
it('三个生产阶段使用统一的块级操作区,保证卡片、按钮和下一阶段之间有稳定间距', () => {
|
it('三个生产阶段使用统一的块级操作区,保证卡片、按钮和下一阶段之间有稳定间距', () => {
|
||||||
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
|
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
|
||||||
expect(source.match(/class="production-stage-actions"/g)).toHaveLength(3)
|
expect(source.match(/class="production-stage-actions"/g)).toHaveLength(3)
|
||||||
expect(source).toMatch(
|
expect(source).toMatch(/\.production-stage-actions\s*\{[^}]*mt-4[^}]*min-h-\[34px\][^}]*items-center[^}]*gap-3/)
|
||||||
/\.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('首帧、素材引用和视频使用固定上限的正方形网格,不随少量记录撑满整行', () => {
|
it('首帧、素材引用和视频使用固定上限的正方形网格,不随少量记录撑满整行', () => {
|
||||||
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
|
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="keyframeCandidates.length" class="keyframe-grid mt-4"')
|
||||||
expect(source).toContain('v-if="videos.length" class="video-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(
|
||||||
expect(source).toMatch(/\.video-input-grid,[\s\S]*?\.video-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/)
|
/\.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(/\.keyframe-card \.asset-image\s*\{[^}]*aspect-square/)
|
||||||
expect(source).toMatch(/\.production-video\s*\{[^}]*aspect-square/)
|
expect(source).toMatch(/\.production-video\s*\{[^}]*aspect-square/)
|
||||||
expect(source).toMatch(/\.video-input-card\s*\{[^}]*bg-\(--app-control\)/)
|
expect(source).toMatch(/\.video-input-card\s*\{[^}]*bg-\(--app-control\)/)
|
||||||
@@ -199,7 +211,9 @@ describe('镜头生产数据契约', () => {
|
|||||||
await flushPromises()
|
await flushPromises()
|
||||||
button('确认生成首帧').click()
|
button('确认生成首帧').click()
|
||||||
await flushPromises()
|
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 wrapper.setProps({ open: false })
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
@@ -210,12 +224,41 @@ describe('镜头生产数据契约', () => {
|
|||||||
await flushPromises()
|
await flushPromises()
|
||||||
button('确认生成首帧').click()
|
button('确认生成首帧').click()
|
||||||
await flushPromises()
|
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 () => {
|
it('首帧生成前可预览后端最终选图规划和 Prompt', async () => {
|
||||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
|
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||||
new Response(
|
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({
|
JSON.stringify({
|
||||||
data: {
|
data: {
|
||||||
shotId: 'shot-1',
|
shotId: 'shot-1',
|
||||||
@@ -252,7 +295,7 @@ describe('镜头生产数据契约', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
})
|
||||||
vi.stubGlobal('fetch', fetcher)
|
vi.stubGlobal('fetch', fetcher)
|
||||||
wrapper = mount(KeyframeDialog, {
|
wrapper = mount(KeyframeDialog, {
|
||||||
attachTo: document.body,
|
attachTo: document.body,
|
||||||
@@ -261,8 +304,9 @@ describe('镜头生产数据契约', () => {
|
|||||||
await flushPromises()
|
await flushPromises()
|
||||||
button('预览实际生成输入').click()
|
button('预览实际生成输入').click()
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/storyboard-shots/shot-1/keyframe/preview')
|
const previewCall = fetcher.mock.calls.find(([url]) => String(url).includes('/keyframe/preview'))
|
||||||
expect(JSON.parse(String(fetcher.mock.calls[0]?.[1]?.body))).toMatchObject({
|
expect(previewCall?.[0]).toBe('/api/storyboard-shots/shot-1/keyframe/preview')
|
||||||
|
expect(JSON.parse(String(previewCall?.[1]?.body))).toMatchObject({
|
||||||
provider: 'seedream',
|
provider: 'seedream',
|
||||||
generationOptions: {}
|
generationOptions: {}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -135,12 +135,11 @@ describe('后端 API 契约', () => {
|
|||||||
)
|
)
|
||||||
vi.stubGlobal('fetch', fetcher)
|
vi.stubGlobal('fetch', fetcher)
|
||||||
expect(await projectsApi.list()).toEqual([{ id: 'p1' }])
|
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',
|
projectId: 'p2',
|
||||||
status: 'generating'
|
status: 'generating'
|
||||||
})
|
})
|
||||||
expect(JSON.parse(fetcher.mock.calls[1]![1].body as string)).toEqual({
|
expect(JSON.parse(fetcher.mock.calls[1]![1].body as string)).toEqual({
|
||||||
title: '测试项目',
|
|
||||||
topic: '故事',
|
topic: '故事',
|
||||||
style: '悬疑',
|
style: '悬疑',
|
||||||
episodeCount: 3
|
episodeCount: 3
|
||||||
|
|||||||
Reference in new issue
Block a user