From 8bdb35ff512fb523f36e9805f282989551fc521e Mon Sep 17 00:00:00 2001 From: heheer Date: Wed, 16 Oct 2024 13:26:51 +0800 Subject: [PATCH] fix: quote settings default value & zindex & i18n (#2931) --- .../plugins/VariableLabelPickerPlugin/index.tsx | 2 +- .../Flow/components/ButtonEdge.tsx | 7 +++---- .../WorkflowComponents/Flow/index.tsx | 1 - .../templates/SettingQuotePrompt.tsx | 17 ++++++++++++----- .../components/WorkflowComponents/utils.tsx | 1 + 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx b/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx index 6a5c8cc95..15b1b66e8 100644 --- a/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx +++ b/packages/web/components/common/Textarea/PromptEditor/plugins/VariableLabelPickerPlugin/index.tsx @@ -129,7 +129,7 @@ export default function VariableLabelPickerPlugin({ color={'myGray.600'} fontWeight={'semibold'} > - {item.label} + {t(item.label as any)} {item.children?.map((child) => ( diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/components/ButtonEdge.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/components/ButtonEdge.tsx index 680504959..78aeb76cf 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/components/ButtonEdge.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/components/ButtonEdge.tsx @@ -37,7 +37,7 @@ const ButtonEdge = (props: EdgeProps) => { }, [nodeList, source, target]); const defaultZIndex = useMemo( - () => (nodeList.find((node) => node.nodeId === source && node.parentNodeId) ? 1001 : 0), + () => (nodeList.find((node) => node.nodeId === source && node.parentNodeId) ? 2002 : 0), [nodeList, source] ); @@ -159,7 +159,7 @@ const ButtonEdge = (props: EdgeProps) => { bg={'white'} borderRadius={'17px'} cursor={'pointer'} - zIndex={9999} + zIndex={defaultZIndex + 1000} onClick={() => onDelConnect(id)} > @@ -173,8 +173,7 @@ const ButtonEdge = (props: EdgeProps) => { pointerEvents={'all'} w={highlightEdge ? '14px' : '10px'} h={highlightEdge ? '14px' : '10px'} - // bg={'white'} - zIndex={highlightEdge ? 1000 : defaultZIndex} + zIndex={highlightEdge ? defaultZIndex + 1000 : defaultZIndex} > { } : {})} onNodeDragStop={onNodeDragStop} - // deleteKeyCode={[]} > diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingQuotePrompt.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingQuotePrompt.tsx index 818e6c62e..227c6e09e 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingQuotePrompt.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/RenderInput/templates/SettingQuotePrompt.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import type { RenderInputProps } from '../type'; import { Box, BoxProps, Button, Flex, ModalFooter, useDisclosure } from '@chakra-ui/react'; import MyModal from '@fastgpt/web/components/common/MyModal'; @@ -50,16 +50,23 @@ const SettingQuotePrompt = (props: RenderInputProps) => { const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode); const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList); - const { watch, setValue, handleSubmit } = useForm({ - defaultValues: { + const defaultValues = useMemo(() => { + return { quoteTemplate: inputs.find((input) => input.key === NodeInputKeyEnum.aiChatQuoteTemplate)?.value || '', quotePrompt: inputs.find((input) => input.key === NodeInputKeyEnum.aiChatQuotePrompt)?.value || '', quoteRole: (inputs.find((input) => input.key === NodeInputKeyEnum.aiChatQuoteRole)?.value || 'system') as AiChatQuoteRoleType - } - }); + }; + }, [inputs]); + + const { watch, setValue, handleSubmit, reset } = useForm({ defaultValues }); + + useEffect(() => { + reset(defaultValues); + }, [defaultValues, reset]); + const aiChatQuoteTemplate = watch('quoteTemplate'); const aiChatQuotePrompt = watch('quotePrompt'); const aiChatQuoteRole = watch('quoteRole'); diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/utils.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/utils.tsx index 78adddbd9..941674cf9 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/utils.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/utils.tsx @@ -123,6 +123,7 @@ export const getEditorVariables = ({ const sourceNodeVariables = !sourceNodes ? [] : sourceNodes + .reverse() .map((node) => { return node.outputs .filter((output) => !!output.label)