feat: loop var support bool type

This commit is contained in:
Joel 2025-07-08 15:23:24 +08:00
parent 657d3d1dae
commit b72d977871
5 changed files with 70 additions and 60 deletions

View File

@ -18,33 +18,15 @@ import {
ValueType,
VarType,
} from '@/app/components/workflow/types'
import BoolValue from '@/app/components/workflow/panel/chat-variable-panel/components/bool-value'
const objectPlaceholder = `# example
# {
# "name": "ray",
# "age": 20
# }`
const arrayStringPlaceholder = `# example
# [
# "value1",
# "value2"
# ]`
const arrayNumberPlaceholder = `# example
# [
# 100,
# 200
# ]`
const arrayObjectPlaceholder = `# example
# [
# {
# "name": "ray",
# "age": 20
# },
# {
# "name": "lily",
# "age": 18
# }
# ]`
import {
arrayBoolPlaceholder,
arrayNumberPlaceholder,
arrayObjectPlaceholder,
arrayStringPlaceholder,
objectPlaceholder,
} from '@/app/components/workflow/panel/chat-variable-panel/utils'
type FormItemProps = {
nodeId: string
@ -83,6 +65,8 @@ const FormItem = ({
return arrayNumberPlaceholder
if (var_type === VarType.arrayObject)
return arrayObjectPlaceholder
if (var_type === VarType.arrayBoolean)
return arrayBoolPlaceholder
return objectPlaceholder
}, [var_type])
@ -120,9 +104,17 @@ const FormItem = ({
/>
)
}
{
value_type === ValueType.constant && var_type === VarType.boolean && (
<BoolValue
value={value}
onChange={handleChange}
/>
)
}
{
value_type === ValueType.constant
&& (var_type === VarType.object || var_type === VarType.arrayString || var_type === VarType.arrayNumber || var_type === VarType.arrayObject)
&& (var_type === VarType.object || var_type === VarType.arrayString || var_type === VarType.arrayNumber || var_type === VarType.arrayObject || var_type === VarType.arrayBoolean)
&& (
<div className='w-full rounded-[10px] bg-components-input-bg-normal py-2 pl-3 pr-1' style={{ height: editorMinHeight }}>
<CodeEditor

View File

@ -22,6 +22,10 @@ const VariableTypeSelect = ({
label: 'Object',
value: VarType.object,
},
{
label: 'Boolean',
value: VarType.boolean,
},
{
label: 'Array[string]',
value: VarType.arrayString,
@ -34,6 +38,10 @@ const VariableTypeSelect = ({
label: 'Array[object]',
value: VarType.arrayObject,
},
{
label: 'Array[boolean]',
value: VarType.arrayBoolean,
},
]
return (

View File

@ -19,6 +19,13 @@ import cn from '@/utils/classnames'
import { checkKeys, replaceSpaceWithUnderscreInVarNameInput } from '@/utils/var'
import BoolValue from './bool-value'
import ArrayBoolList from './array-bool-list'
import {
arrayBoolPlaceholder,
arrayNumberPlaceholder,
arrayObjectPlaceholder,
arrayStringPlaceholder,
objectPlaceholder,
} from '@/app/components/workflow/panel/chat-variable-panel/utils'
export type ModalPropsType = {
chatVar?: ConversationVariable
@ -43,39 +50,6 @@ const typeList = [
ChatVarType.ArrayObject,
]
const objectPlaceholder = `# example
# {
# "name": "ray",
# "age": 20
# }`
const arrayStringPlaceholder = `# example
# [
# "value1",
# "value2"
# ]`
const arrayNumberPlaceholder = `# example
# [
# 100,
# 200
# ]`
const arrayObjectPlaceholder = `# example
# [
# {
# "name": "ray",
# "age": 20
# },
# {
# "name": "lily",
# "age": 18
# }
# ]`
const arrayBoolPlaceholder = `# example
# [
# "True",
# "False"
# ]`
const ChatVariableModal = ({
chatVar,
onClose,

View File

@ -0,0 +1,35 @@
export const objectPlaceholder = `# example
# {
# "name": "ray",
# "age": 20
# }`
export const arrayStringPlaceholder = `# example
# [
# "value1",
# "value2"
# ]`
export const arrayNumberPlaceholder = `# example
# [
# 100,
# 200
# ]`
export const arrayObjectPlaceholder = `# example
# [
# {
# "name": "ray",
# "age": 20
# },
# {
# "name": "lily",
# "age": 18
# }
# ]`
export const arrayBoolPlaceholder = `# example
# [
# "True",
# "False"
# ]`

View File

@ -262,6 +262,7 @@ export enum VarType {
arrayString = 'array[string]',
arrayNumber = 'array[number]',
arrayObject = 'array[object]',
arrayBoolean = 'array[boolean]',
arrayFile = 'array[file]',
any = 'any',
arrayAny = 'array[any]',