fix: variable input and update chat time

This commit is contained in:
archer
2023-08-31 18:09:12 +08:00
parent 3420f677b6
commit b22c878cf9
15 changed files with 30 additions and 48 deletions

View File

@@ -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);
}}

View File

@@ -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);
}

View File

@@ -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;
};