fix(web): tool node number support variable
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { type FC, useEffect, useState } from "react";
|
import { type FC, useEffect, useState, useMemo } from "react";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Form, Select, InputNumber, Switch, Cascader, type CascaderProps, Tooltip } from 'antd'
|
import { Form, Select, InputNumber, Switch, Cascader, type CascaderProps, Tooltip } from 'antd'
|
||||||
import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
|
import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
|
||||||
@@ -163,6 +163,24 @@ const ToolConfig: FC<{ options: Suggestion[]; }> = ({
|
|||||||
|
|
||||||
form.setFieldsValue(inititalValue)
|
form.setFieldsValue(inititalValue)
|
||||||
}
|
}
|
||||||
|
const getNumberOptions = useMemo(() => {
|
||||||
|
const list: Suggestion[] = []
|
||||||
|
|
||||||
|
options.forEach(vo => {
|
||||||
|
if (vo.children && vo?.children?.length > 0) {
|
||||||
|
const filterChild = vo.children.filter(child => child.dataType === 'number')
|
||||||
|
|
||||||
|
if (filterChild.length > 0) {
|
||||||
|
list.push({ ...vo, children: filterChild })
|
||||||
|
} else {
|
||||||
|
list.push({ ...vo, children: [] })
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.push({ ...vo })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return list
|
||||||
|
}, [options])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -202,15 +220,14 @@ const ToolConfig: FC<{ options: Suggestion[]; }> = ({
|
|||||||
: parameter.type === 'boolean'
|
: parameter.type === 'boolean'
|
||||||
? <Switch size="small" />
|
? <Switch size="small" />
|
||||||
: parameter.type === 'integer' || parameter.type === 'number'
|
: parameter.type === 'integer' || parameter.type === 'number'
|
||||||
? <InputNumber
|
? <Editor
|
||||||
min={parameter.minimum}
|
variant="outlined"
|
||||||
max={parameter.maximum}
|
type="input"
|
||||||
step={parameter.type === 'integer' ? 1 : 0.01}
|
size="small"
|
||||||
placeholder={t('common.pleaseEnter')}
|
height={28}
|
||||||
className="rb:w-full!"
|
options={getNumberOptions}
|
||||||
size="small"
|
placeholder={t('common.pleaseEnter')}
|
||||||
onChange={(value) => form.setFieldValue(['tool_parameters', parameter.name], value)}
|
/>
|
||||||
/>
|
|
||||||
: <Editor
|
: <Editor
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
type="input"
|
type="input"
|
||||||
|
|||||||
Reference in New Issue
Block a user