mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 08:26:27 +08:00
feat: filed and var
This commit is contained in:
parent
1a4c2e77c4
commit
ace04b3ef4
22
web/app/components/base/button/add-button.tsx
Normal file
22
web/app/components/base/button/add-button.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
'use client'
|
||||||
|
import type { FC } from 'react'
|
||||||
|
import React from 'react'
|
||||||
|
import cn from 'classnames'
|
||||||
|
import { Plus } from '../icons/src/vender/line/general'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
className?: string
|
||||||
|
onClick: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const AddButton: FC<Props> = ({
|
||||||
|
className,
|
||||||
|
onClick,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div className={cn(className, 'p-1 rounded-md cursor-pointer hover:bg-gray-200 select-none')} onClick={onClick}>
|
||||||
|
<Plus className='w-4 h-4 text-gray-500' />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(AddButton)
|
||||||
26
web/app/components/workflow/nodes/_base/components/field.tsx
Normal file
26
web/app/components/workflow/nodes/_base/components/field.tsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
'use client'
|
||||||
|
import type { FC } from 'react'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
title: string
|
||||||
|
children: JSX.Element | string
|
||||||
|
operations?: JSX.Element
|
||||||
|
}
|
||||||
|
|
||||||
|
const Filed: FC<Props> = ({
|
||||||
|
title,
|
||||||
|
children,
|
||||||
|
operations,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className='flex justify-between items-center'>
|
||||||
|
<div className='leading-[18px] text-xs font-medium text-gray-500 uppercase'>{title}</div>
|
||||||
|
{operations && <div>{operations}</div>}
|
||||||
|
</div>
|
||||||
|
<div>{children}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(Filed)
|
||||||
@ -1,10 +1,32 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import BaseNode from '../_base/node'
|
import BaseNode from '../_base/node'
|
||||||
|
import Field from '@/app/components/workflow/nodes/_base/components/field'
|
||||||
|
import AddButton from '@/app/components/base/button/add-button'
|
||||||
|
const i18nPrefix = 'workflow.nodes.llm'
|
||||||
|
|
||||||
const Node: FC = () => {
|
const Node: FC = () => {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const handleAddVariable = () => {
|
||||||
|
console.log('add variable')
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<BaseNode>
|
<BaseNode>
|
||||||
<div>llm</div>
|
<div>
|
||||||
|
<Field
|
||||||
|
title={t(`${i18nPrefix}.model`)}
|
||||||
|
>
|
||||||
|
Model Selector
|
||||||
|
</Field>
|
||||||
|
<Field
|
||||||
|
title={t(`${i18nPrefix}.variables`)}
|
||||||
|
operations={
|
||||||
|
<AddButton onClick={handleAddVariable} />
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Var Selector
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
</BaseNode>
|
</BaseNode>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,9 @@ import customPt from './lang/custom.pt' // Portuguese import
|
|||||||
import toolsEn from './lang/tools.en'
|
import toolsEn from './lang/tools.en'
|
||||||
import toolsZh from './lang/tools.zh'
|
import toolsZh from './lang/tools.zh'
|
||||||
import toolsPt from './lang/tools.pt' // Portuguese import
|
import toolsPt from './lang/tools.pt' // Portuguese import
|
||||||
|
import workflowEn from './lang/workflow.en'
|
||||||
|
import workflowZh from './lang/workflow.zh'
|
||||||
|
import workflowPt from './lang/workflow.pt' // Portuguese import
|
||||||
|
|
||||||
const resources = {
|
const resources = {
|
||||||
'en-US': {
|
'en-US': {
|
||||||
@ -89,6 +92,7 @@ const resources = {
|
|||||||
custom: customEn,
|
custom: customEn,
|
||||||
// tools
|
// tools
|
||||||
tools: toolsEn,
|
tools: toolsEn,
|
||||||
|
workflow: workflowEn,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'zh-Hans': {
|
'zh-Hans': {
|
||||||
@ -116,6 +120,7 @@ const resources = {
|
|||||||
custom: customZh,
|
custom: customZh,
|
||||||
// tools
|
// tools
|
||||||
tools: toolsZh,
|
tools: toolsZh,
|
||||||
|
workflow: workflowZh,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'pt-BR': {
|
'pt-BR': {
|
||||||
@ -142,6 +147,7 @@ const resources = {
|
|||||||
billing: billingPt,
|
billing: billingPt,
|
||||||
custom: customPt,
|
custom: customPt,
|
||||||
tools: toolsPt,
|
tools: toolsPt,
|
||||||
|
workflow: workflowPt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
10
web/i18n/lang/workflow.en.ts
Normal file
10
web/i18n/lang/workflow.en.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const translation = {
|
||||||
|
nodes: {
|
||||||
|
llm: {
|
||||||
|
model: 'model',
|
||||||
|
variables: 'variables',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translation
|
||||||
9
web/i18n/lang/workflow.pt.ts
Normal file
9
web/i18n/lang/workflow.pt.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
const translation = {
|
||||||
|
nodes: {
|
||||||
|
llm: {
|
||||||
|
model: 'model',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translation
|
||||||
10
web/i18n/lang/workflow.zh.ts
Normal file
10
web/i18n/lang/workflow.zh.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const translation = {
|
||||||
|
nodes: {
|
||||||
|
llm: {
|
||||||
|
model: '模型',
|
||||||
|
variables: '变量',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translation
|
||||||
Loading…
Reference in New Issue
Block a user