feat: 首帧生成支持手动选择图片模型参数
This commit is contained in:
1 parent
fd23e1f613
commit
92f32e50b9
1 file changed
+45
-1
@@ -4,6 +4,9 @@ import { NFormItem } from 'naive-ui'
|
|||||||
import { sizeRules } from '../../../lib/form-rules'
|
import { sizeRules } from '../../../lib/form-rules'
|
||||||
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber, NTag } from 'naive-ui'
|
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber, NTag } from 'naive-ui'
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { generationConfigApi } from '../../generation-config/api'
|
||||||
|
import type { CreativeProfileAspectRatio, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||||
|
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||||
import { AppDialog } from '../../../components/ui'
|
import { AppDialog } from '../../../components/ui'
|
||||||
import { errorMessage } from '../../../lib/http'
|
import { errorMessage } from '../../../lib/http'
|
||||||
import { productionApi } from '../api'
|
import { productionApi } from '../api'
|
||||||
@@ -14,6 +17,7 @@ import type { GenerateKeyframeInput, KeyframeGenerationPreview } from '../types'
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
shotId: string
|
shotId: string
|
||||||
shotTitle: string
|
shotTitle: string
|
||||||
|
projectId: string
|
||||||
disabled: boolean
|
disabled: boolean
|
||||||
replacePrimary?: boolean
|
replacePrimary?: boolean
|
||||||
}>()
|
}>()
|
||||||
@@ -25,17 +29,37 @@ const confirmed = ref(false)
|
|||||||
const preview = ref<KeyframeGenerationPreview | null>(null)
|
const preview = ref<KeyframeGenerationPreview | null>(null)
|
||||||
const previewError = ref('')
|
const previewError = ref('')
|
||||||
const previewPending = ref(false)
|
const previewPending = ref(false)
|
||||||
|
const generationCatalog = ref<GenerationModelCatalog | null>(null)
|
||||||
|
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 sizeValid = computed(() => validOptionalSize(width.value, height.value))
|
||||||
const canSubmit = computed(() => !props.disabled && sizeValid.value && confirmed.value)
|
const canSubmit = computed(() => !props.disabled && sizeValid.value && confirmed.value)
|
||||||
|
|
||||||
/** 切换镜头或重新打开时清空费用确认;新图一律先作为候选。 */
|
/** 切换镜头或重新打开时清空费用确认;新图一律先作为候选。 */
|
||||||
function reset() {
|
async function reset() {
|
||||||
width.value = ''
|
width.value = ''
|
||||||
height.value = ''
|
height.value = ''
|
||||||
confirmed.value = false
|
confirmed.value = false
|
||||||
preview.value = null
|
preview.value = null
|
||||||
previewError.value = ''
|
previewError.value = ''
|
||||||
previewPending.value = false
|
previewPending.value = false
|
||||||
|
generationCatalogError.value = ''
|
||||||
|
if (!open.value) return
|
||||||
|
try {
|
||||||
|
const [catalog, profile] = await Promise.all([
|
||||||
|
generationConfigApi.catalog(),
|
||||||
|
generationConfigApi.profile(props.projectId)
|
||||||
|
])
|
||||||
|
generationCatalog.value = catalog
|
||||||
|
projectAspectRatio.value = profile?.aspectRatio ?? '9:16'
|
||||||
|
imageProvider.value = profile?.imageProvider || catalog.defaults.imageProvider
|
||||||
|
const selected = catalog.images.find(item => item.provider === imageProvider.value)
|
||||||
|
imageGenerationOptions.value = { ...selected?.defaults, ...profile?.imageOptions }
|
||||||
|
} catch (cause) {
|
||||||
|
generationCatalogError.value = errorMessage(cause)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
watch([() => props.shotId, open], reset, { immediate: true })
|
watch([() => props.shotId, open], reset, { immediate: true })
|
||||||
|
|
||||||
@@ -44,6 +68,8 @@ function submit() {
|
|||||||
if (!canSubmit.value) return
|
if (!canSubmit.value) return
|
||||||
emit('generate', {
|
emit('generate', {
|
||||||
...(width.value === '' ? {} : { width: width.value, height: height.value as number }),
|
...(width.value === '' ? {} : { width: width.value, height: height.value as number }),
|
||||||
|
provider: imageProvider.value || undefined,
|
||||||
|
generationOptions: imageGenerationOptions.value,
|
||||||
setPrimary: false
|
setPrimary: false
|
||||||
})
|
})
|
||||||
open.value = false
|
open.value = false
|
||||||
@@ -87,6 +113,24 @@ async function loadPreview() {
|
|||||||
<NAlert v-if="replacePrimary" type="info" :show-icon="false" class="mt-5 text-xs">
|
<NAlert v-if="replacePrimary" type="info" :show-icon="false" class="mt-5 text-xs">
|
||||||
当前主首帧使用的主体参考资产已经变化。新图成功后应设为主首帧,旧图会继续保留为历史候选。
|
当前主首帧使用的主体参考资产已经变化。新图成功后应设为主首帧,旧图会继续保留为历史候选。
|
||||||
</NAlert>
|
</NAlert>
|
||||||
|
<section v-if="generationCatalog" class="surface-inset mt-5 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="image"
|
||||||
|
:catalog="generationCatalog"
|
||||||
|
:provider="imageProvider"
|
||||||
|
:options="imageGenerationOptions"
|
||||||
|
:aspect-ratio="projectAspectRatio"
|
||||||
|
:disabled="disabled"
|
||||||
|
@update:provider="imageProvider = $event"
|
||||||
|
@update:options="imageGenerationOptions = $event"
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
<NAlert v-else-if="generationCatalogError" type="warning" :show-icon="false" class="mt-5 text-xs">
|
||||||
|
生成模型目录读取失败:{{ generationCatalogError }}
|
||||||
|
</NAlert>
|
||||||
<div class="mt-5 flex flex-wrap items-center gap-3">
|
<div class="mt-5 flex flex-wrap items-center gap-3">
|
||||||
<NButton :loading="previewPending" @click="loadPreview">预览实际生成输入</NButton>
|
<NButton :loading="previewPending" @click="loadPreview">预览实际生成输入</NButton>
|
||||||
<span class="text-xs text-muted">只读取参考图规划与最终 Prompt,不调用图片模型。</span>
|
<span class="text-xs text-muted">只读取参考图规划与最终 Prompt,不调用图片模型。</span>
|
||||||
|
|||||||
Reference in new issue
Block a user