修复场景生成输入契约

场景请求提交前将画布参数转换为字符串契约

保留素材结果中的原始画布参数类型
This commit is contained in:
2026-08-08 11:15:18 +08:00
parent fb47002bfb
commit d5f0f6de93
2 changed files with 26 additions and 2 deletions
@@ -2,6 +2,7 @@ import {
CUSTOM_EDITOR_SCENE_STYLE_PRESET,
DEFAULT_EDITOR_SCENE_STYLE_PRESET,
} from '../../../packages/shared/src/contracts/editorScene';
import type { EditorSceneGenerationInputs } from '../../../packages/shared/src/contracts/editorScene';
import type {
EditorBackgroundMusicGenerationInput,
EditorCharacterAnimationGenerationInput,
@@ -75,6 +76,29 @@ export const EDITOR_SCENE_CUSTOM_STYLE_REQUIRED_ERROR = '请填写自定义画
export const EDITOR_GENERATED_ASSET_LABEL_MAX_CHARS = 80;
/**
* 场景生成接口的历史契约只接受字符串参数;画布配方则保留原生
* string | number | boolean 值,以便在素材元数据中无损回放。
*/
export function toEditorSceneGenerationInputs(
generationInputs: CanvasGenerationInputs,
): EditorSceneGenerationInputs {
return {
fields: generationInputs.fields.map(({ title, value }) => ({
title,
value: String(value),
})),
references: generationInputs.references.map(
({ title, label, refType, refId }) => ({
title,
label: label ?? '',
refType,
refId,
}),
),
};
}
export function resolveGenerationAssetLabel(
assetLabel: string | null | undefined,
fallback: string,
@@ -628,7 +652,7 @@ export function buildImageGenerationSubmissionPlan({
),
}
: {}),
generationInputs,
generationInputs: toEditorSceneGenerationInputs(generationInputs),
},
result: {
assetKind: 'scene',
@@ -2373,7 +2373,7 @@ export function useImageCanvasGenerationSubmissionWorkflow({
generateEditorScene({
...sceneGenerationInput,
projectId,
generationInputs: submissionPlan.result.generationInputs,
generationInputs: submissionPlan.input.generationInputs,
assetFolderId,
assetLabel: submissionPlan.result.title,
...(projectId && canvasCompletionPlaceholder