diff --git a/src/features/generation-config/components/CreativeProfileSettings.vue b/src/features/generation-config/components/CreativeProfileSettings.vue index 3371d3f..e33155d 100644 --- a/src/features/generation-config/components/CreativeProfileSettings.vue +++ b/src/features/generation-config/components/CreativeProfileSettings.vue @@ -75,6 +75,22 @@ function defaultOptions(item: GenerationModelItem): GenerationOptions { ) } +/** 把历史 Profile 中已不属于当前模型 Schema 的参数收敛为当前模型默认值。 */ +function normalizeSavedOptions(item: GenerationModelItem | undefined, saved: GenerationOptions): GenerationOptions { + if (!item) return { ...saved } + const defaults = defaultOptions(item) + const normalized = { ...saved } + for (const schema of item.generationOptions) { + const value = normalized[schema.key] + if (schema.type !== 'size' || typeof value !== 'string' || !schema.options?.length) continue + if (schema.options.some(option => option.value === value)) continue + const fallback = defaults[schema.key] + if (fallback !== undefined) normalized[schema.key] = fallback + else delete normalized[schema.key] + } + return normalized +} + function selectModel(type: 'image' | 'video', value: string) { if (!profile.value) return const items = type === 'image' ? enabledImages.value : enabledVideos.value @@ -122,15 +138,25 @@ async function load() { generationConfigApi.profile(props.projectId, controller.signal) ]) catalog.value = nextCatalog + const savedImageModel = saved + ? nextCatalog.images.find( + item => item.provider === saved.imageProvider && item.model === saved.imageModel + ) + : undefined + const savedVideoModel = saved + ? nextCatalog.videos.find( + item => item.provider === saved.videoProvider && item.model === saved.videoModel + ) + : undefined profile.value = saved ? { aspectRatio: saved.aspectRatio, imageProvider: saved.imageProvider, imageModel: saved.imageModel, - imageOptions: { ...saved.imageOptions }, + imageOptions: normalizeSavedOptions(savedImageModel, saved.imageOptions), videoProvider: saved.videoProvider, videoModel: saved.videoModel, - videoOptions: { ...saved.videoOptions } + videoOptions: normalizeSavedOptions(savedVideoModel, saved.videoOptions) } : createInitial(nextCatalog) } catch (cause) {