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}> <div key={outputItem.name}>
{outputItem.value?.type === 'object' ? ( {outputItem.value?.type === 'object' ? (
<StructureOutputItem <StructureOutputItem
rootClassName='code-sm-semibold text-text-secondary' rootClassName='code-sm-semibold text-text-secondary'
payload={wrapStructuredVarItem(outputItem, getMatchedSchemaType(outputItem.value))} /> payload={wrapStructuredVarItem(outputItem, schemaType)}
/>
) : ( ) : (
<VarItem <VarItem
name={outputItem.name} 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} description={outputItem.description}
isIndent={hasObjectOutput} isIndent={hasObjectOutput}
/> />
)} )}
</div> </div>
)) )
} })}
</OutputVars> </OutputVars>
</div> </div>
) )

View File

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