diff --git a/web/components/flow/node-param-handler.tsx b/web/components/flow/node-param-handler.tsx index adc9181e4..5fd982470 100644 --- a/web/components/flow/node-param-handler.tsx +++ b/web/components/flow/node-param-handler.tsx @@ -5,7 +5,7 @@ import RequiredIcon from './required-icon'; import NodeHandler from './node-handler'; import { InfoCircleOutlined } from '@ant-design/icons'; import { RenderSelect, RenderSlider, RenderTreeSelect, RenderTimePicker, RenderTextArea, RenderCascader } from './node-renderer'; -import { uiAtrrtUnderlineToHump } from '@/utils/flow' +import { uiAtrrtUnderlineToHump } from '@/utils/flow'; interface NodeParamHandlerProps { node: IFlowNode; data: IFlowNodeParameter; @@ -104,25 +104,20 @@ const NodeParamHandler: React.FC = ({ node, data, label, function renderNodeWithUiParam(data: IFlowNodeParameter) { let defaultValue = data.value !== null && data.value !== undefined ? data.value : data.default; if (data?.ui?.attr) { - uiAtrrtUnderlineToHump(data.ui.attr) + uiAtrrtUnderlineToHump(data.ui.attr); } // TODO: 根据ui_type渲染不同的组件 switch (data?.ui?.ui_type) { case 'select': return ; - break case 'text_area': return ; - break case 'slider': return ; - break case 'time_picker': return ; - break case 'tree_select': return ; - break } } @@ -134,4 +129,3 @@ const NodeParamHandler: React.FC = ({ node, data, label, }; export default NodeParamHandler; - diff --git a/web/components/flow/node-renderer/index.ts b/web/components/flow/node-renderer/index.ts index 163defb9d..61341fe58 100644 --- a/web/components/flow/node-renderer/index.ts +++ b/web/components/flow/node-renderer/index.ts @@ -1,6 +1,6 @@ -export * from "./select"; -export * from "./cascader"; -export * from "./textarea"; -export * from "./slider"; -export * from "./timePicker"; -export * from "./treeSelect"; \ No newline at end of file +export * from './select'; +export * from './cascader'; +export * from './textarea'; +export * from './slider'; +export * from './timePicker'; +export * from './treeSelect'; diff --git a/web/components/flow/node-renderer/select.tsx b/web/components/flow/node-renderer/select.tsx index 897d18522..06f86777c 100644 --- a/web/components/flow/node-renderer/select.tsx +++ b/web/components/flow/node-renderer/select.tsx @@ -1,21 +1,23 @@ -import { IFlowNodeParameter } from "@/types/flow"; -import { Select } from "antd"; +import { IFlowNodeParameter } from '@/types/flow'; +import { Select } from 'antd'; type SelectProps = { data: IFlowNodeParameter; defaultValue: any; onChange: (value: any) => void; -} +}; export const RenderSelect = (params: SelectProps) => { const { data, defaultValue, onChange } = params; - return data.options?.length > 0 && ( - ({ label: item.label, value: item.value }))} + onChange={onChange} + /> + ) + ); +}; diff --git a/web/components/flow/node-renderer/slider.tsx b/web/components/flow/node-renderer/slider.tsx index 5233fdb33..8a60715bb 100644 --- a/web/components/flow/node-renderer/slider.tsx +++ b/web/components/flow/node-renderer/slider.tsx @@ -1,53 +1,38 @@ -import { IFlowNodeParameter } from "@/types/flow"; +import { IFlowNodeParameter } from '@/types/flow'; import { Col, InputNumber, Row, Slider, Space } from 'antd'; -import { uiAtrrtUnderlineToHump } from '@/utils/flow' import type { InputNumberProps } from 'antd'; import React, { useState } from 'react'; - type TextAreaProps = { data: IFlowNodeParameter; defaultValue: any; onChange: (value: any) => void; -} - - - +}; export const RenderSlider = (params: TextAreaProps) => { - const { data, defaultValue, onChange } = params; + const { data, defaultValue, onChange } = params; + + const [inputValue, setInputValue] = useState(defaultValue); - const [inputValue, setInputValue] = useState(defaultValue); + const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { + setInputValue(newValue as number); + onChange(newValue as number); + }; - const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { - setInputValue(newValue as number); - onChange(newValue as number) - }; return ( <> - {data?.ui?.show_input ? - - - - - - - : - -} + {data?.ui?.show_input ? ( + + + + + + + + + ) : ( + + )} - ) -} + ); +}; diff --git a/web/components/flow/node-renderer/sliderList.tsx b/web/components/flow/node-renderer/sliderList.tsx index 5233fdb33..6a7f72610 100644 --- a/web/components/flow/node-renderer/sliderList.tsx +++ b/web/components/flow/node-renderer/sliderList.tsx @@ -1,53 +1,36 @@ -import { IFlowNodeParameter } from "@/types/flow"; +import { IFlowNodeParameter } from '@/types/flow'; import { Col, InputNumber, Row, Slider, Space } from 'antd'; -import { uiAtrrtUnderlineToHump } from '@/utils/flow' import type { InputNumberProps } from 'antd'; import React, { useState } from 'react'; - type TextAreaProps = { data: IFlowNodeParameter; defaultValue: any; onChange: (value: any) => void; -} - - - +}; export const RenderSlider = (params: TextAreaProps) => { - const { data, defaultValue, onChange } = params; - - const [inputValue, setInputValue] = useState(defaultValue); + const { data, defaultValue, onChange } = params; + const [inputValue, setInputValue] = useState(defaultValue); - const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { - setInputValue(newValue as number); - onChange(newValue as number) - }; + const onChangeSlider: InputNumberProps['onChange'] = (newValue) => { + setInputValue(newValue as number); + onChange(newValue as number); + }; return ( <> - {data?.ui?.show_input ? - - - - - - - : - -} + {data?.ui?.show_input ? ( + + + + + + + + + ) : ( + + )} - ) -} + ); +}; diff --git a/web/components/flow/node-renderer/textarea.tsx b/web/components/flow/node-renderer/textarea.tsx index 3fcb6ff80..3ba9e082d 100644 --- a/web/components/flow/node-renderer/textarea.tsx +++ b/web/components/flow/node-renderer/textarea.tsx @@ -1,6 +1,6 @@ -import { IFlowNodeParameter } from "@/types/flow"; +import { IFlowNodeParameter } from '@/types/flow'; import { Input } from 'antd'; -import { uiAtrrtUnderlineToHump } from '@/utils/flow' +import { uiAtrrtUnderlineToHump } from '@/utils/flow'; const { TextArea } = Input; @@ -8,15 +8,11 @@ type TextAreaProps = { data: IFlowNodeParameter; defaultValue: any; onChange: (value: any) => void; -} - +}; export const RenderTextArea = (params: TextAreaProps) => { const { data, defaultValue, onChange } = params; - if(data?.ui?.autosize){ - uiAtrrtUnderlineToHump(data.ui.autosize) - } - return ( -