fix: 完善工作流图片参数流转

- 图片参数使用 Object 类型并过滤上游图片引用

- 试运行支持上传、URL 和素材库图片输入

- 将模型图片能力映射到运行配置
This commit is contained in:
2026-07-31 14:51:07 +08:00
parent fb08424cef
commit 4a0efe8879
18 changed files with 924 additions and 50 deletions

View File

@@ -84,6 +84,7 @@ describe('workflow node fields', () => {
key: 'file_field',
label: '文件字段',
type: 'file',
contentType: 'file',
placeholder: '请选择文件',
});
expect((updated.parameters as any[]).find((item) => item.name === 'file_field'))
@@ -110,6 +111,7 @@ describe('workflow node fields', () => {
expect(updated.startFormSchema?.find((item: any) => item.key === 'attachments'))
.toMatchObject({
type: 'file',
contentType: 'file',
placeholder: '请选择文件',
});
expect((updated.parameters as any[]).find((item) => item.name === 'attachments'))
@@ -149,6 +151,99 @@ describe('workflow node fields', () => {
expect(nextParameter?.id).toBe(previousParameter?.id);
});
it('preserves resource content type independently from input type', () => {
for (const contentType of ['image', 'video', 'audio', 'other'] as const) {
const key = `preview_${contentType}`;
const initial = createInitialWorkflowData();
const appended = appendStartFormField(
initial.nodes[0]?.data as Record<string, any>,
{
key,
label: `资源-${contentType}`,
type: 'text',
},
);
const updated = updateStartFormField(appended, key, {
contentType,
});
expect(
updated.startFormSchema?.find((item: any) => item.key === key),
).toMatchObject({
type: 'text',
contentType,
});
expect(
(updated.parameters as any[]).find((item) => item.name === key),
).toMatchObject({
dataType: contentType === 'image' ? 'Object' : 'String',
contentType,
formType: 'input',
});
}
});
it('reconciles a legacy text schema with its image parameter', () => {
const initial = createInitialWorkflowData();
const startData = initial.nodes[0]?.data as Record<string, any>;
const appended = appendStartFormField(startData, {
key: 'legacy_image',
label: '图片',
type: 'text',
});
const imageParameterData = {
...appended,
parameters: (appended.parameters as any[]).map((parameter) =>
parameter.name === 'legacy_image'
? {
...parameter,
contentType: 'image',
dataType: 'Object',
}
: parameter,
),
};
const normalized = normalizeStartNodeData(imageParameterData);
expect(
normalized.startFormSchema?.find(
(field: any) => field.key === 'legacy_image',
),
).toMatchObject({
contentType: 'image',
type: 'text',
});
expect(
(normalized.parameters as any[]).find(
(parameter) => parameter.name === 'legacy_image',
),
).toMatchObject({
contentType: 'image',
dataType: 'Object',
});
const changedToText = updateStartFormField(normalized, 'legacy_image', {
contentType: 'text',
});
expect(
changedToText.startFormSchema?.find(
(field: any) => field.key === 'legacy_image',
),
).toMatchObject({
contentType: 'text',
});
expect(
(changedToText.parameters as any[]).find(
(parameter) => parameter.name === 'legacy_image',
),
).toMatchObject({
contentType: 'text',
dataType: 'String',
});
});
it('keeps start fields unchanged when renaming to an existing key', () => {
const initial = createInitialWorkflowData();
const withTopic = appendStartFormField(