fix: variable input and update chat time
This commit is contained in:
@@ -10,7 +10,7 @@ import type { VariableItemType } from '@/types/app';
|
||||
import MyIcon from '@/components/Icon';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6);
|
||||
import VariableEditModal from '../../../VariableEditModal';
|
||||
import VariableEditModal, { addVariable } from '../../../VariableEditModal';
|
||||
|
||||
export const defaultVariable: VariableItemType = {
|
||||
id: nanoid(),
|
||||
@@ -105,7 +105,7 @@ const NodeUserGuide = ({ data }: NodeProps<FlowModuleItemType>) => {
|
||||
variant={'base'}
|
||||
leftIcon={<AddIcon fontSize={'10px'} />}
|
||||
onClick={() => {
|
||||
const newVariable = { ...defaultVariable, id: nanoid() };
|
||||
const newVariable = addVariable();
|
||||
updateVariables(variables.concat(newVariable));
|
||||
setEditVariable(newVariable);
|
||||
}}
|
||||
|
||||
@@ -532,6 +532,13 @@ const Settings = ({ appId }: { appId: string }) => {
|
||||
variables.map((item) => (item.id === variable.id ? variable : item))
|
||||
);
|
||||
} else {
|
||||
// auth same key
|
||||
if (variables.find((item) => item.key === variable.key)) {
|
||||
return toast({
|
||||
status: 'warning',
|
||||
title: t('app.Variable Key Repeat Tip')
|
||||
});
|
||||
}
|
||||
appendVariable(variable);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,6 @@ export const defaultVariable: VariableItemType = {
|
||||
enums: [{ value: '' }]
|
||||
};
|
||||
export const addVariable = () => {
|
||||
const newVariable = { ...defaultVariable, id: nanoid() };
|
||||
const newVariable = { ...defaultVariable, key: nanoid(), id: nanoid() };
|
||||
return newVariable;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user