mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 06:45:58 +08:00
feat: show more than 10 deepth
This commit is contained in:
parent
d6b66aeed8
commit
8fb24bf1ca
@ -6,24 +6,40 @@ import { getFieldType } from '../../../../llm/utils'
|
|||||||
import type { Field as FieldType } from '../../../../llm/types'
|
import type { Field as FieldType } from '../../../../llm/types'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import TreeIndentLine from './tree-indent-line'
|
import TreeIndentLine from './tree-indent-line'
|
||||||
|
import { RiMoreFill } from '@remixicon/react'
|
||||||
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
const MAX_DEPTH = 10
|
||||||
|
|
||||||
type Props = { name: string, payload: FieldType, depth?: number }
|
type Props = { name: string, payload: FieldType, depth?: number }
|
||||||
|
|
||||||
const Field: FC<Props> = ({
|
const Field: FC<Props> = ({
|
||||||
name,
|
name,
|
||||||
payload,
|
payload,
|
||||||
depth = 0,
|
depth = 1,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
if (depth > MAX_DEPTH + 1)
|
||||||
|
return null
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={cn('flex pr-2 items-center justify-between rounded-md hover:bg-state-base-hover cursor-pointer')}>
|
<Tooltip popupContent={t('app.structOutput.moreFillTip')} disabled={depth !== MAX_DEPTH + 1}>
|
||||||
<div className='flex items-center h-6'>
|
<div className={cn('flex pr-2 items-center justify-between rounded-md hover:bg-state-base-hover', depth !== MAX_DEPTH + 1 && 'cursor-pointer')}>
|
||||||
<TreeIndentLine depth={depth} />
|
<div className='grow flex items-center'>
|
||||||
<div className='system-sm-medium text-text-secondary'>{name}</div>
|
<TreeIndentLine depth={depth} isMoreFill={depth === MAX_DEPTH + 1} />
|
||||||
|
{depth === MAX_DEPTH + 1 ? (
|
||||||
|
<RiMoreFill className='w-3 h-3 text-text-tertiary' />
|
||||||
|
) : (<div className='h-6 leading-6 grow w-0 truncate system-sm-medium text-text-secondary'>{name}</div>)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className='system-xs-regular text-text-tertiary'>{getFieldType(payload)}</div>
|
{depth < MAX_DEPTH + 1 && (
|
||||||
|
<div className='ml-2 shrink-0 system-xs-regular text-text-tertiary'>{getFieldType(payload)}</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{payload.type === Type.object && payload.properties && (
|
</Tooltip>
|
||||||
|
|
||||||
|
{depth <= MAX_DEPTH && payload.type === Type.object && payload.properties && (
|
||||||
<div>
|
<div>
|
||||||
{Object.keys(payload.properties).map(name => (
|
{Object.keys(payload.properties).map(name => (
|
||||||
<Field
|
<Field
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
depth?: number
|
depth?: number
|
||||||
|
isMoreFill?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const TreeIndentLine: FC<Props> = ({
|
const TreeIndentLine: FC<Props> = ({
|
||||||
depth = 0,
|
depth = 1,
|
||||||
|
isMoreFill = false,
|
||||||
}) => {
|
}) => {
|
||||||
const depthArray = Array.from({ length: depth + 1 }, (_, index) => index)
|
const depthArray = Array.from({ length: depth }, (_, index) => index)
|
||||||
return (
|
return (
|
||||||
<div className='ml-2.5 mr-2.5 flex space-x-[12px]'>
|
<div className='ml-2.5 mr-2.5 flex space-x-[12px]'>
|
||||||
{depthArray.map(d => (
|
{depthArray.map(d => (
|
||||||
<div key={d} className='h-6 w-px bg-divider-regular'></div>
|
<div key={d} className={cn('w-px bg-divider-regular', isMoreFill ? 'h-3' : 'h-6')}></div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -29,6 +29,64 @@ const data: StructuredOutput = {
|
|||||||
type: Type.boolean,
|
type: Type.boolean,
|
||||||
description: '描述可为空',
|
description: '描述可为空',
|
||||||
},
|
},
|
||||||
|
sub_item_d_2: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_3: {
|
||||||
|
type: Type.object,
|
||||||
|
// generate more than sub item 10 levels
|
||||||
|
properties: {
|
||||||
|
sub_item_4: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_5: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_6: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_7: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_8: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_9: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_10: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_11: {
|
||||||
|
type: Type.object,
|
||||||
|
properties: {
|
||||||
|
sub_item_12: {
|
||||||
|
type: Type.object,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
number_field_3: {
|
||||||
|
type: Type.number,
|
||||||
|
description: '描述可为空',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: [
|
required: [
|
||||||
'string_field_1',
|
'string_field_1',
|
||||||
|
@ -180,6 +180,9 @@ const translation = {
|
|||||||
noParams: 'No parameters needed',
|
noParams: 'No parameters needed',
|
||||||
},
|
},
|
||||||
showMyCreatedAppsOnly: 'Created by me',
|
showMyCreatedAppsOnly: 'Created by me',
|
||||||
|
structOutput: {
|
||||||
|
moreFillTip: 'Showing max 10 levels of nesting',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translation
|
export default translation
|
||||||
|
@ -181,6 +181,9 @@ const translation = {
|
|||||||
},
|
},
|
||||||
openInExplore: '在“探索”中打开',
|
openInExplore: '在“探索”中打开',
|
||||||
showMyCreatedAppsOnly: '我创建的',
|
showMyCreatedAppsOnly: '我创建的',
|
||||||
|
structOutput: {
|
||||||
|
moreFillTip: '最多显示 10 级嵌套',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translation
|
export default translation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user