mirror of https://github.com/langgenius/dify.git
fix: http nodes update error and support json
This commit is contained in:
parent
9839b5cb53
commit
8a906e2959
|
|
@ -15,6 +15,12 @@ type Props = {
|
|||
readOnly?: boolean
|
||||
}
|
||||
|
||||
const languageMap = {
|
||||
[CodeLanguage.javascript]: 'javascript',
|
||||
[CodeLanguage.python3]: 'python',
|
||||
[CodeLanguage.json]: 'json',
|
||||
}
|
||||
|
||||
const CodeEditor: FC<Props> = ({
|
||||
value,
|
||||
onChange,
|
||||
|
|
@ -70,7 +76,8 @@ const CodeEditor: FC<Props> = ({
|
|||
{/* https://www.npmjs.com/package/@monaco-editor/react */}
|
||||
<Editor
|
||||
className='h-full'
|
||||
defaultLanguage={language === CodeLanguage.javascript ? 'javascript' : 'python'}
|
||||
// language={language === CodeLanguage.javascript ? 'javascript' : 'python'}
|
||||
language={languageMap[language] || 'javascript'}
|
||||
theme={isFocus ? 'focus-theme' : 'blur-theme'}
|
||||
value={value}
|
||||
onChange={handleEditorChange}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
|
|||
/>
|
||||
</Field>
|
||||
<Split />
|
||||
{inputs.code_language}
|
||||
<CodeEditor
|
||||
readOnly={readOnly}
|
||||
title={
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import type { CommonNodeType, Variable } from '@/app/components/workflow/types'
|
|||
export enum CodeLanguage {
|
||||
python3 = 'python3',
|
||||
javascript = 'javascript',
|
||||
json = 'json',
|
||||
}
|
||||
|
||||
export type OutputVar = {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ const EditBody: FC<Props> = ({
|
|||
})
|
||||
onChange(newBody)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [body, isCurrentKeyValue])
|
||||
}, [isCurrentKeyValue])
|
||||
|
||||
const handleBodyValueChange = useCallback((value: string) => {
|
||||
const newBody = produce(payload, (draft: Body) => {
|
||||
|
|
@ -127,7 +127,7 @@ const EditBody: FC<Props> = ({
|
|||
readOnly={readonly}
|
||||
title={<div className='uppercase'>JSON</div>}
|
||||
value={payload.data} onChange={handleBodyValueChange}
|
||||
language={CodeLanguage.javascript}
|
||||
language={CodeLanguage.json}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue