From c1d339265f327bb5bf8ffca4f019c1480d66029f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E6=A2=A6?= Date: Wed, 4 Dec 2024 14:35:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=A4=9A=E4=B8=AA=E6=9D=A1=E4=BB=B6=E8=8A=82?= =?UTF-8?q?=E7=82=B9=EF=BC=8Cdata=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/xflow/demo/switchNode/setting.tsx | 20 +++++++++++++++++++ .../src/nodes/node-switch/setting/index.tsx | 18 +++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/xflow/demo/switchNode/setting.tsx b/docs/xflow/demo/switchNode/setting.tsx index 1c790f4ef..4dc9eadcb 100644 --- a/docs/xflow/demo/switchNode/setting.tsx +++ b/docs/xflow/demo/switchNode/setting.tsx @@ -16,6 +16,16 @@ export default [ type: 'icon-prompt', bgColor: '#17B26A', }, + settingSchema: { + type: "object", + properties: { + input: { + title: '提示词', + type: 'string', + widget: 'textArea', + }, + } + }, }, { title: '知识库', @@ -25,5 +35,15 @@ export default [ type: 'icon-knowledge', bgColor: '#6172F3', }, + settingSchema: { + type: "object", + properties: { + input: { + title: '知识库', + type: 'string', + widget: 'textArea', + }, + } + }, }, ]; diff --git a/packages/x-flow/src/nodes/node-switch/setting/index.tsx b/packages/x-flow/src/nodes/node-switch/setting/index.tsx index c4e3f9e01..46ee2b7a6 100644 --- a/packages/x-flow/src/nodes/node-switch/setting/index.tsx +++ b/packages/x-flow/src/nodes/node-switch/setting/index.tsx @@ -1,6 +1,6 @@ import FormRender, { Schema, useForm } from 'form-render'; -import React, { memo } from 'react'; -import '../index.less' +import React, { memo, useEffect } from 'react'; +import '../index.less'; interface INodeSwitchSettingPorps { onChange: (val: any) => void; @@ -10,12 +10,12 @@ interface INodeSwitchSettingPorps { const schema: Schema = { type: 'object', span: 24, - displayType: "row", + displayType: 'row', properties: { switchData: { type: 'array', widget: 'simpleList', - display:"block", + display: 'block', props: { hideCopy: true, hideMove: true, @@ -44,16 +44,18 @@ export default memo((props: INodeSwitchSettingPorps) => { }, }; + useEffect(() => { + form.resetFields(); + form.setValues(value || {}); + }, [JSON.stringify(value)]); + return ( { - form.setValues(value || {}); - }} - className='custom-node-switch-setting' + className="custom-node-switch-setting" /> ); });