This commit is contained in:
zxhlyh
2025-08-26 18:29:58 +08:00
parent 158da1ce6e
commit 01f0ee339e
11 changed files with 469 additions and 13 deletions

View File

@ -1,6 +1,7 @@
import React, { useCallback, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { useContext } from 'use-context-selector'
import { v4 as uuid4 } from 'uuid'
import {
useForm as useTanstackForm,
useStore as useTanstackStore,
@ -63,26 +64,27 @@ const ChatVariableModal = ({
}) || { isCheckValidated: false, values: {} }
const {
name,
type,
value_type,
value,
editInJSON,
...rest
} = values
console.log(values, 'xxx')
if (!isCheckValidated)
return
if (!checkVariableName(name))
return
if (!chatVar && varList.some(chatVar => chatVar.name === name))
return notify({ type: 'error', message: 'name is existed' })
if (type === ChatVarType.Object && value.some((item: any) => !item.key && !!item.value))
if (value_type === ChatVarType.Object && value.some((item: any) => !item.key && !!item.value))
return notify({ type: 'error', message: 'object key can not be empty' })
// onSave({
// id: chatVar ? chatVar.id : uuid4(),
// name,
// value_type: type,
// value: values,
// description,
// })
onSave({
id: chatVar ? chatVar.id : uuid4(),
name,
value_type,
value: editInJSON ? JSON.parse(value) : value,
...rest,
})
onClose()
}, [onClose, notify, t, varList, chatVar, checkVariableName])