refactor: 统一首帧图片尺寸参数
This commit is contained in:
1 parent
55af8f90d3
commit
079317fb31
1 file changed
+4
-34
@@ -1,8 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { sizeRules } from '../../../lib/form-rules'
|
||||
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber, NTag } from 'naive-ui'
|
||||
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { generationConfigApi } from '../../generation-config/api'
|
||||
import type { CreativeProfileAspectRatio, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
@@ -10,7 +8,6 @@ import GenerationModelControls from '../../generation-config/components/Generati
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { productionApi } from '../api'
|
||||
import { validOptionalSize } from '../model'
|
||||
import type { GenerateKeyframeInput, KeyframeGenerationPreview } from '../types'
|
||||
|
||||
/** 单镜头首帧表单;所有新图先生成候选,通过质量检查后再人工晋升。 */
|
||||
@@ -23,8 +20,6 @@ const props = defineProps<{
|
||||
}>()
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
const emit = defineEmits<{ generate: [input: GenerateKeyframeInput] }>()
|
||||
const width = ref<number | ''>('')
|
||||
const height = ref<number | ''>('')
|
||||
const confirmed = ref(false)
|
||||
const preview = ref<KeyframeGenerationPreview | null>(null)
|
||||
const previewError = ref('')
|
||||
@@ -34,13 +29,10 @@ const generationCatalogError = ref('')
|
||||
const imageProvider = ref('')
|
||||
const imageGenerationOptions = ref<GenerationOptions>({})
|
||||
const projectAspectRatio = ref<CreativeProfileAspectRatio>('9:16')
|
||||
const sizeValid = computed(() => validOptionalSize(width.value, height.value))
|
||||
const canSubmit = computed(() => !props.disabled && sizeValid.value && confirmed.value)
|
||||
const canSubmit = computed(() => !props.disabled && confirmed.value)
|
||||
|
||||
/** 切换镜头或重新打开时清空费用确认;新图一律先作为候选。 */
|
||||
async function reset() {
|
||||
width.value = ''
|
||||
height.value = ''
|
||||
confirmed.value = false
|
||||
preview.value = null
|
||||
previewError.value = ''
|
||||
@@ -63,11 +55,10 @@ async function reset() {
|
||||
}
|
||||
watch([() => props.shotId, open], reset, { immediate: true })
|
||||
|
||||
/** 只发送后端允许的字段,未填写尺寸时使用 Provider 默认值。 */
|
||||
/** 发送当前模型与动态生成参数;图片尺寸统一由 generationOptions.size 管理。 */
|
||||
function submit() {
|
||||
if (!canSubmit.value) return
|
||||
emit('generate', {
|
||||
...(width.value === '' ? {} : { width: width.value, height: height.value as number }),
|
||||
provider: imageProvider.value || undefined,
|
||||
generationOptions: imageGenerationOptions.value,
|
||||
setPrimary: false
|
||||
@@ -75,8 +66,6 @@ function submit() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
const formModel = computed(() => ({ width: width.value, height: height.value }))
|
||||
const rules = sizeRules(() => formModel.value)
|
||||
|
||||
/** 读取后端最终参考图选择与 Prompt,不创建首帧候选。 */
|
||||
async function loadPreview() {
|
||||
@@ -106,8 +95,7 @@ async function loadPreview() {
|
||||
description="新图先作为候选;完成质量检查并通过后,才能设为主首帧。"
|
||||
>
|
||||
<AppForm
|
||||
:model="formModel"
|
||||
:rules="rules"
|
||||
:model="imageGenerationOptions"
|
||||
:disabled="disabled"
|
||||
:reset-key="`${open}:${shotId}`"
|
||||
validate-on-change
|
||||
@@ -177,24 +165,6 @@ async function loadPreview() {
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</div>
|
||||
<div class="mt-5 grid grid-cols-2 gap-4">
|
||||
<NFormItem path="width" label="宽度(可选)"
|
||||
><NInputNumber
|
||||
:input-props="{ 'aria-label': '宽度(可选)' }"
|
||||
:value="typeof width === 'number' ? width : null"
|
||||
@update:value="width = $event ?? ''"
|
||||
:min="1"
|
||||
></NInputNumber
|
||||
></NFormItem>
|
||||
<NFormItem path="height" label="高度(可选)"
|
||||
><NInputNumber
|
||||
:input-props="{ 'aria-label': '高度(可选)' }"
|
||||
:value="typeof height === 'number' ? height : null"
|
||||
@update:value="height = $event ?? ''"
|
||||
:min="1"
|
||||
></NInputNumber
|
||||
></NFormItem>
|
||||
</div>
|
||||
<NCheckbox
|
||||
id="confirm-keyframe-cost"
|
||||
v-model:checked="confirmed"
|
||||
|
||||
Reference in new issue
Block a user