fix: not obj type struct schema render error

This commit is contained in:
Joel 2025-08-27 18:32:04 +08:00
parent a644153e9f
commit 4e2c3bfb05
2 changed files with 31 additions and 21 deletions

View File

@ -136,23 +136,28 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
))
}
{
outputSchema.map(outputItem => (
outputSchema.map((outputItem) => {
const schemaType = getMatchedSchemaType(outputItem.value)
return (
<div key={outputItem.name}>
{outputItem.value?.type === 'object' ? (
<StructureOutputItem
rootClassName='code-sm-semibold text-text-secondary'
payload={wrapStructuredVarItem(outputItem, getMatchedSchemaType(outputItem.value))} />
payload={wrapStructuredVarItem(outputItem, schemaType)}
/>
) : (
<VarItem
name={outputItem.name}
type={outputItem.type.toLocaleLowerCase()}
// eslint-disable-next-line sonarjs/no-nested-template-literals
type={`${outputItem.type.toLocaleLowerCase()}${schemaType ? ` (${schemaType})` : ''}`}
description={outputItem.description}
isIndent={hasObjectOutput}
/>
)}
</div>
))
}
)
})}
</OutputVars>
</div>
)

View File

@ -117,22 +117,27 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
description={t(`${i18nPrefix}.outputVars.json`)}
isIndent={hasObjectOutput}
/>
{outputSchema.map(outputItem => (
<div key={outputItem.name}>
{outputItem.value?.type === 'object' ? (
<StructureOutputItem
rootClassName='code-sm-semibold text-text-secondary'
payload={wrapStructuredVarItem(outputItem, getMatchedSchemaType(outputItem.value))} />
) : (
<VarItem
name={outputItem.name}
type={outputItem.type.toLocaleLowerCase()}
description={outputItem.description}
isIndent={hasObjectOutput}
/>
)}
</div>
))}
{outputSchema.map((outputItem) => {
const schemaType = getMatchedSchemaType(outputItem.value)
return (
<div key={outputItem.name}>
{outputItem.value?.type === 'object' ? (
<StructureOutputItem
rootClassName='code-sm-semibold text-text-secondary'
payload={wrapStructuredVarItem(outputItem, schemaType)}
/>
) : (
<VarItem
name={outputItem.name}
// eslint-disable-next-line sonarjs/no-nested-template-literals
type={`${outputItem.type.toLocaleLowerCase()}${schemaType ? ` (${schemaType})` : ''}`}
description={outputItem.description}
isIndent={hasObjectOutput}
/>
)}
</div>
)
})}
</>
</OutputVars>
</div>