Feat: Switching the programming language of the code operator will switch the corresponding language template #3221 (#7770)

### What problem does this PR solve?

Feat: Switching the programming language of the code operator will
switch the corresponding language template #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-05-21 18:22:06 +08:00
committed by GitHub
parent 754a5e1cee
commit 558b252c5a
7 changed files with 133 additions and 25 deletions

View File

@ -10,8 +10,9 @@ import {
FormMessage,
} from '@/components/ui/form';
import { RAGFlowSelect } from '@/components/ui/select';
import { ProgrammingLanguage } from '@/constants/agent';
import { CodeTemplateStrMap, ProgrammingLanguage } from '@/constants/agent';
import { ICodeForm } from '@/interfaces/database/flow';
import { useEffect } from 'react';
import { DynamicInputVariable } from './next-variable';
loader.config({ paths: { vs: '/vs' } });
@ -24,15 +25,13 @@ const options = [
const CodeForm = ({ form, node }: INextOperatorForm) => {
const formData = node?.data.form as ICodeForm;
// useEffect(() => {
// setTimeout(() => {
// // TODO: Direct operation zustand is more elegant
// form?.setFieldValue(
// 'script',
// CodeTemplateStrMap[formData.lang as ProgrammingLanguage],
// );
// }, 0);
// }, [form, formData.lang]);
useEffect(() => {
// TODO: Direct operation zustand is more elegant
form?.setValue(
'script',
CodeTemplateStrMap[formData.lang as ProgrammingLanguage],
);
}, [form, formData.lang]);
return (
<Form {...form}>