Skip to content

Commit

Permalink
fix:修复点击切换多个条件节点,data数据更新问题
Browse files Browse the repository at this point in the history
  • Loading branch information
昔梦 committed Dec 4, 2024
1 parent 6dd7cc5 commit c1d3392
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
20 changes: 20 additions & 0 deletions docs/xflow/demo/switchNode/setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ export default [
type: 'icon-prompt',
bgColor: '#17B26A',
},
settingSchema: {
type: "object",
properties: {
input: {
title: '提示词',
type: 'string',
widget: 'textArea',
},
}
},
},
{
title: '知识库',
Expand All @@ -25,5 +35,15 @@ export default [
type: 'icon-knowledge',
bgColor: '#6172F3',
},
settingSchema: {
type: "object",
properties: {
input: {
title: '知识库',
type: 'string',
widget: 'textArea',
},
}
},
},
];
18 changes: 10 additions & 8 deletions packages/x-flow/src/nodes/node-switch/setting/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -44,16 +44,18 @@ export default memo((props: INodeSwitchSettingPorps) => {
},
};

useEffect(() => {
form.resetFields();
form.setValues(value || {});
}, [JSON.stringify(value)]);

return (
<FormRender
schema={schema}
form={form}
watch={watch}
size={'small'}
onMount={() => {
form.setValues(value || {});
}}
className='custom-node-switch-setting'
className="custom-node-switch-setting"
/>
);
});

0 comments on commit c1d3392

Please sign in to comment.