mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-07-04 10:45:10 +08:00
Fix bug large data no render (#12683)
Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com>
This commit is contained in:
parent
87763fc234
commit
03ec3513f3
@ -23,7 +23,14 @@ const OutputPanel: FC<OutputPanelProps> = ({
|
|||||||
height,
|
height,
|
||||||
}) => {
|
}) => {
|
||||||
const isTextOutput = useMemo(() => {
|
const isTextOutput = useMemo(() => {
|
||||||
return outputs && Object.keys(outputs).length === 1 && typeof outputs[Object.keys(outputs)[0]] === 'string'
|
if (!outputs || typeof outputs !== 'object')
|
||||||
|
return false
|
||||||
|
const keys = Object.keys(outputs)
|
||||||
|
const value = outputs[keys[0]]
|
||||||
|
return keys.length === 1 && (
|
||||||
|
typeof value === 'string'
|
||||||
|
|| (Array.isArray(value) && value.every(item => typeof item === 'string'))
|
||||||
|
)
|
||||||
}, [outputs])
|
}, [outputs])
|
||||||
|
|
||||||
const fileList = useMemo(() => {
|
const fileList = useMemo(() => {
|
||||||
@ -65,7 +72,13 @@ const OutputPanel: FC<OutputPanelProps> = ({
|
|||||||
)}
|
)}
|
||||||
{isTextOutput && (
|
{isTextOutput && (
|
||||||
<div className='px-4 py-2'>
|
<div className='px-4 py-2'>
|
||||||
<Markdown content={outputs[Object.keys(outputs)[0]] || ''} />
|
<Markdown
|
||||||
|
content={
|
||||||
|
Array.isArray(outputs[Object.keys(outputs)[0]])
|
||||||
|
? outputs[Object.keys(outputs)[0]].join('\n')
|
||||||
|
: (outputs[Object.keys(outputs)[0]] || '')
|
||||||
|
}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{fileList.length > 0 && (
|
{fileList.length > 0 && (
|
||||||
@ -78,14 +91,14 @@ const OutputPanel: FC<OutputPanelProps> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{outputs && Object.keys(outputs).length > 1 && height! > 0 && (
|
{!isTextOutput && outputs && Object.keys(outputs).length > 0 && height! > 0 && (
|
||||||
<div className='flex flex-col gap-2'>
|
<div className='flex flex-col gap-2'>
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
showFileList
|
showFileList
|
||||||
readOnly
|
readOnly
|
||||||
title={<div></div>}
|
title={<div tabIndex={0}>Output</div>}
|
||||||
language={CodeLanguage.json}
|
language={CodeLanguage.json}
|
||||||
value={outputs}
|
value={JSON.stringify(outputs, null, 2)}
|
||||||
isJSONStringifyBeauty
|
isJSONStringifyBeauty
|
||||||
height={height ? (height - 16) / 2 : undefined}
|
height={height ? (height - 16) / 2 : undefined}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user