From 8fb24bf1ca50de2d0e59ab074be8a4481a8d7abd Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 10 Mar 2025 13:55:18 +0800 Subject: [PATCH] feat: show more than 10 deepth --- .../object-child-tree-panel/field.tsx | 32 +++++++--- .../tree-indent-line.tsx | 9 ++- .../workflow/nodes/llm/mock-struct-data.ts | 58 +++++++++++++++++++ web/i18n/en-US/app.ts | 3 + web/i18n/zh-Hans/app.ts | 3 + 5 files changed, 94 insertions(+), 11 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/field.tsx b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/field.tsx index dd891f3bef..48c25ffe1e 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/field.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/field.tsx @@ -6,24 +6,40 @@ import { getFieldType } from '../../../../llm/utils' import type { Field as FieldType } from '../../../../llm/types' import cn from '@/utils/classnames' 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 } const Field: FC = ({ name, payload, - depth = 0, + depth = 1, }) => { + const { t } = useTranslation() + if (depth > MAX_DEPTH + 1) + return null return (
-
-
- -
{name}
+ +
+
+ + {depth === MAX_DEPTH + 1 ? ( + + ) : (
{name}
)} + +
+ {depth < MAX_DEPTH + 1 && ( +
{getFieldType(payload)}
+ )}
-
{getFieldType(payload)}
-
- {payload.type === Type.object && payload.properties && ( + + + {depth <= MAX_DEPTH && payload.type === Type.object && payload.properties && (
{Object.keys(payload.properties).map(name => ( = ({ - depth = 0, + depth = 1, + isMoreFill = false, }) => { - const depthArray = Array.from({ length: depth + 1 }, (_, index) => index) + const depthArray = Array.from({ length: depth }, (_, index) => index) return (
{depthArray.map(d => ( -
+
))}
) diff --git a/web/app/components/workflow/nodes/llm/mock-struct-data.ts b/web/app/components/workflow/nodes/llm/mock-struct-data.ts index f9c4f2e4cc..d5476ff768 100644 --- a/web/app/components/workflow/nodes/llm/mock-struct-data.ts +++ b/web/app/components/workflow/nodes/llm/mock-struct-data.ts @@ -29,6 +29,64 @@ const data: StructuredOutput = { type: Type.boolean, 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: [ 'string_field_1', diff --git a/web/i18n/en-US/app.ts b/web/i18n/en-US/app.ts index 27279130b1..3598a32279 100644 --- a/web/i18n/en-US/app.ts +++ b/web/i18n/en-US/app.ts @@ -180,6 +180,9 @@ const translation = { noParams: 'No parameters needed', }, showMyCreatedAppsOnly: 'Created by me', + structOutput: { + moreFillTip: 'Showing max 10 levels of nesting', + }, } export default translation diff --git a/web/i18n/zh-Hans/app.ts b/web/i18n/zh-Hans/app.ts index ba44d4db31..8ddc4d8b1a 100644 --- a/web/i18n/zh-Hans/app.ts +++ b/web/i18n/zh-Hans/app.ts @@ -181,6 +181,9 @@ const translation = { }, openInExplore: '在“探索”中打开', showMyCreatedAppsOnly: '我创建的', + structOutput: { + moreFillTip: '最多显示 10 级嵌套', + }, } export default translation