optimize editor default value code (#4794)
Some checks are pending
Deploy doc image to cf / deploy-production (push) Waiting to run
Deploy doc image by kubeconfig / build-fastgpt-docs-images (push) Waiting to run
Deploy doc image by kubeconfig / update-docs-image (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / build-fastgpt-images (push) Waiting to run

This commit is contained in:
heheer 2025-05-12 23:52:22 +08:00 committed by GitHub
parent cac4b1d435
commit bdb1221d94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 11 deletions

View File

@ -178,12 +178,11 @@ const JSONEditor = ({
return '';
}
try {
if (typeof value === 'object') {
return JSON.stringify(value, null, 2);
} catch (error) {
console.error('JSON stringify error:', error);
return String(value) || '';
}
return String(value);
}, [value]);
const onBlur = useCallback(() => {

View File

@ -140,20 +140,15 @@ const ChatItemContextProvider = ({
(props?: { variables?: Record<string, any>; variableList?: VariableItemType[] }) => {
const { variables, variableList = [] } = props || {};
let newVariableValue: Record<string, any> = {};
if (variables) {
variableList.forEach((item) => {
newVariableValue[item.key] = variables[item.key];
variablesForm.setValue(`variables.${item.key}`, variables[item.key]);
});
} else {
variableList.forEach((item) => {
newVariableValue[item.key] = item.defaultValue;
variablesForm.setValue(`variables.${item.key}`, item.defaultValue);
});
}
Object.entries(newVariableValue).forEach(([key, value]) => {
variablesForm.setValue(`variables.${key}`, value);
});
},
[variablesForm]
);