From 7082ea4c9dfd1706b1d83f73a747dc5abcec3970 Mon Sep 17 00:00:00 2001
From: archer <545436317@qq.com>
Date: Tue, 5 Mar 2024 10:03:11 +0800
Subject: [PATCH] extra module ui
---
.../module/template/system/contextExtract.ts | 2 +-
projects/app/public/locales/en/common.json | 4 +-
projects/app/public/locales/zh/common.json | 4 +-
.../Flow/components/modules/VariableEdit.tsx | 10 +-
.../nodes/NodeExtract/ExtractFieldModal.tsx | 27 ++--
.../components/nodes/NodeExtract/index.tsx | 149 ++++++++++--------
6 files changed, 116 insertions(+), 80 deletions(-)
diff --git a/packages/global/core/module/template/system/contextExtract.ts b/packages/global/core/module/template/system/contextExtract.ts
index aaa413ee1890..86a1bb7bcb2c 100644
--- a/packages/global/core/module/template/system/contextExtract.ts
+++ b/packages/global/core/module/template/system/contextExtract.ts
@@ -57,7 +57,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
{
key: ModuleInputKeyEnum.extractKeys,
type: FlowNodeInputTypeEnum.custom,
- label: '目标字段',
+ label: '',
valueType: ModuleIOValueTypeEnum.any,
description: "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
value: [], // {desc: string; key: string; required: boolean; enum: string[]}[]
diff --git a/projects/app/public/locales/en/common.json b/projects/app/public/locales/en/common.json
index ff5ccb7d3bf1..162667aac4e5 100644
--- a/projects/app/public/locales/en/common.json
+++ b/projects/app/public/locales/en/common.json
@@ -797,12 +797,14 @@
"Field Edit": "Field Edit"
},
"extract": {
+ "Add field": "Add",
"Enum Description": "Lists the possible values for the field, one per row",
"Enum Value": "Enum",
"Field Description Placeholder": "Name/age /sql statement......",
"Field Setting Title": "Extract field configuration",
"Required": "Required",
- "Required Description": "Even if the field cannot be extracted, it is returned with the default value"
+ "Required Description": "Even if the field cannot be extracted, it is returned with the default value",
+ "Target field": "Field"
},
"http": {
"Add props": "Add props",
diff --git a/projects/app/public/locales/zh/common.json b/projects/app/public/locales/zh/common.json
index 78f1ae412bed..19990533fe58 100644
--- a/projects/app/public/locales/zh/common.json
+++ b/projects/app/public/locales/zh/common.json
@@ -799,12 +799,14 @@
"Field Edit": "字段编辑"
},
"extract": {
+ "Add field": "新增字段",
"Enum Description": "列举出该字段可能的值,每行一个",
"Enum Value": "枚举值",
"Field Description Placeholder": "姓名/年龄/sql语句……",
"Field Setting Title": "提取字段配置",
"Required": "必须返回",
- "Required Description": "即使无法提取该字段,也会使用默认值进行返回"
+ "Required Description": "即使无法提取该字段,也会使用默认值进行返回",
+ "Target field": "目标字段"
},
"http": {
"Add props": "添加参数",
diff --git a/projects/app/src/components/core/module/Flow/components/modules/VariableEdit.tsx b/projects/app/src/components/core/module/Flow/components/modules/VariableEdit.tsx
index 5b9c137d90d5..933bca3beeec 100644
--- a/projects/app/src/components/core/module/Flow/components/modules/VariableEdit.tsx
+++ b/projects/app/src/components/core/module/Flow/components/modules/VariableEdit.tsx
@@ -132,11 +132,11 @@ const VariableEdit = ({
- |
- {t('core.module.variable.variable name')} |
- {t('core.module.variable.key')} |
- {t('common.Require Input')} |
- |
+ |
+ {t('core.module.variable.variable name')} |
+ {t('core.module.variable.key')} |
+ {t('common.Require Input')} |
+ |
diff --git a/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/ExtractFieldModal.tsx b/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/ExtractFieldModal.tsx
index f063640dffda..1a4868f79710 100644
--- a/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/ExtractFieldModal.tsx
+++ b/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/ExtractFieldModal.tsx
@@ -45,10 +45,11 @@ const ExtractFieldModal = ({
iconSrc="/imgs/module/extract.png"
title={t('core.module.extract.Field Setting Title')}
onClose={onClose}
+ w={['90vw', '500px']}
>
-
+
{t('core.module.extract.Required')}
@@ -58,8 +59,9 @@ const ExtractFieldModal = ({
{required && (
- {t('core.module.Default value')}
+ {t('core.module.Default value')}
@@ -67,12 +69,17 @@ const ExtractFieldModal = ({
)}
- {t('core.module.Field key')}
-
+ {t('core.module.Field key')}
+
- {t('core.module.Field Description')}
+ {t('core.module.Field Description')}
@@ -85,14 +92,16 @@ const ExtractFieldModal = ({
-
+
-
diff --git a/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/index.tsx b/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/index.tsx
index ed3e2b161f0d..f864b8283cf2 100644
--- a/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/index.tsx
+++ b/projects/app/src/components/core/module/Flow/components/nodes/NodeExtract/index.tsx
@@ -1,5 +1,16 @@
import React, { useState } from 'react';
-import { Box, Button, Table, Thead, Tbody, Tr, Th, Td, TableContainer } from '@chakra-ui/react';
+import {
+ Box,
+ Button,
+ Table,
+ Thead,
+ Tbody,
+ Tr,
+ Th,
+ Td,
+ TableContainer,
+ Flex
+} from '@chakra-ui/react';
import { NodeProps } from 'reactflow';
import { FlowModuleItemType } from '@fastgpt/global/core/module/type.d';
import { useTranslation } from 'next-i18next';
@@ -36,75 +47,87 @@ const NodeExtract = ({ data }: NodeProps) => {
}: {
value?: ContextExtractAgentItemType[];
}) => (
-
-
+
+
+ {t('core.module.extract.Target field')}
}
onClick={() => setEditExtractField(defaultField)}
>
- 新增字段
+ {t('core.module.extract.Add field')}
-
-
-
-
-
- 字段 key |
- 字段描述 |
- 必须 |
- |
-
-
-
- {extractKeys.map((item, index) => (
-
- {item.key} |
- {item.desc} |
- {item.required ? '✔' : ''} |
-
- {
- setEditExtractField(item);
- }}
- />
- {
- onChangeNode({
- moduleId,
- type: 'updateInput',
- key: ModuleInputKeyEnum.extractKeys,
- value: {
- ...props,
- value: extractKeys.filter((extract) => item.key !== extract.key)
- }
- });
-
- onChangeNode({
- moduleId,
- type: 'delOutput',
- key: item.key
- });
- }}
- />
- |
+
+
+
+
+
+
+ 字段 key |
+ 字段描述 |
+ 必须 |
+ |
- ))}
-
-
-
+
+
+ {extractKeys.map((item, index) => (
+
+ {item.key} |
+ {item.desc} |
+ {item.required ? '✔' : ''} |
+
+ {
+ setEditExtractField(item);
+ }}
+ />
+ {
+ onChangeNode({
+ moduleId,
+ type: 'updateInput',
+ key: ModuleInputKeyEnum.extractKeys,
+ value: {
+ ...props,
+ value: extractKeys.filter(
+ (extract) => item.key !== extract.key
+ )
+ }
+ });
+
+ onChangeNode({
+ moduleId,
+ type: 'delOutput',
+ key: item.key
+ });
+ }}
+ />
+ |
+
+ ))}
+
+
+
+
)
}}