From 57f178902ff0d93ac768943fbdb8b304b35a857b Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 13 Aug 2024 14:14:38 +0800 Subject: [PATCH] feat: if node select value --- .../if-else/components/condition-value.tsx | 22 +++++++++++++++++-- web/i18n/zh-Hans/workflow.ts | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/web/app/components/workflow/nodes/if-else/components/condition-value.tsx b/web/app/components/workflow/nodes/if-else/components/condition-value.tsx index eea3c583e5..51d2ba8353 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-value.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-value.tsx @@ -3,11 +3,12 @@ import { useMemo, } from 'react' import { useTranslation } from 'react-i18next' -import type { ComparisonOperator } from '../types' +import { ComparisonOperator } from '../types' import { comparisonOperatorNotRequireValue, isComparisonOperatorNeedTranslate, } from '../utils' +import { FILE_TYPE_OPTIONS, TRANSFER_METHOD } from '../default' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { Env } from '@/app/components/base/icons/src/vender/line/others' import cn from '@/utils/classnames' @@ -41,6 +42,23 @@ const ConditionValue = ({ }) }, [notHasValue, value]) + const isSelect = operator === ComparisonOperator.in || operator === ComparisonOperator.notIn + const selectName = useMemo(() => { + if (isSelect) { + const name = [...FILE_TYPE_OPTIONS, ...TRANSFER_METHOD].filter(item => item.value === value)[0] + return name + ? t(`workflow.nodes.ifElse.optionName.${name.i18nKey}`).replace(/{{#([^#]*)#}}/g, (a, b) => { + const arr: string[] = b.split('.') + if (isSystemVar(arr)) + return `{{${b}}}` + + return `{{${arr.slice(1).join('.')}}}` + }) + : '' + } + return '' + }, [isSelect, t, value]) + return (
{!isENV(variableSelector) && } @@ -62,7 +80,7 @@ const ConditionValue = ({
{ !notHasValue && ( -
{formatValue}
+
{isSelect ? selectName : formatValue}
) } diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 98c5fc1dd0..88f47805fb 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -387,8 +387,8 @@ const translation = { 'not empty': '不为空', 'null': '空', 'not null': '不为空', - 'in': '在', - 'not in': '不在', + 'in': '是', + 'not in': '不是', }, optionName: { image: '图片',