mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-26 02:07:28 +08:00
fix: deal with undefined valueType (#6684)
* fix: deal with undefined valueType * fix * fix * fix key
This commit is contained in:
@@ -232,6 +232,16 @@ export const FlowValueTypeMap: Record<
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getFlowValueTypeMeta = (
|
||||||
|
valueType?: WorkflowIOValueTypeEnum | string | null
|
||||||
|
): (typeof FlowValueTypeMap)[WorkflowIOValueTypeEnum] => {
|
||||||
|
if (valueType == null || valueType === '') {
|
||||||
|
return FlowValueTypeMap[WorkflowIOValueTypeEnum.any];
|
||||||
|
}
|
||||||
|
const meta = FlowValueTypeMap[valueType as WorkflowIOValueTypeEnum];
|
||||||
|
return meta ?? FlowValueTypeMap[WorkflowIOValueTypeEnum.any];
|
||||||
|
};
|
||||||
|
|
||||||
export const EDGE_TYPE = 'default';
|
export const EDGE_TYPE = 'default';
|
||||||
|
|
||||||
export const chatHistoryValueDesc = `{
|
export const chatHistoryValueDesc = `{
|
||||||
|
|||||||
+2
-2
@@ -14,7 +14,7 @@ import MyIconButton from '@fastgpt/web/components/common/Icon/button';
|
|||||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||||
import {
|
import {
|
||||||
FlowNodeInputTypeEnum,
|
FlowNodeInputTypeEnum,
|
||||||
FlowValueTypeMap
|
getFlowValueTypeMeta
|
||||||
} from '@fastgpt/global/core/workflow/node/constant';
|
} from '@fastgpt/global/core/workflow/node/constant';
|
||||||
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||||
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
|
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
|
||||||
@@ -255,7 +255,7 @@ const Reference = ({
|
|||||||
fontSize={'sm'}
|
fontSize={'sm'}
|
||||||
fontWeight={'medium'}
|
fontWeight={'medium'}
|
||||||
>
|
>
|
||||||
{t(FlowValueTypeMap[inputChildren.valueType || WorkflowIOValueTypeEnum.any].label)}
|
{t(getFlowValueTypeMeta(inputChildren.valueType).label)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
{!isEmptyItem && (
|
{!isEmptyItem && (
|
||||||
|
|||||||
+6
-4
@@ -3,7 +3,7 @@ import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/
|
|||||||
import { Box, Flex, Input, HStack } from '@chakra-ui/react';
|
import { Box, Flex, Input, HStack } from '@chakra-ui/react';
|
||||||
import {
|
import {
|
||||||
FlowNodeOutputTypeEnum,
|
FlowNodeOutputTypeEnum,
|
||||||
FlowValueTypeMap
|
getFlowValueTypeMeta
|
||||||
} from '@fastgpt/global/core/workflow/node/constant';
|
} from '@fastgpt/global/core/workflow/node/constant';
|
||||||
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
@@ -90,7 +90,7 @@ const DynamicOutputs = ({ nodeId, outputs, addOutput }: DynamicOutputsProps) =>
|
|||||||
{outputs.length > 0 && <Box w={6} />}
|
{outputs.length > 0 && <Box w={6} />}
|
||||||
</Flex>
|
</Flex>
|
||||||
{[...outputs, defaultOutput].map((output, index) => (
|
{[...outputs, defaultOutput].map((output, index) => (
|
||||||
<Box key={output.key} _notLast={{ mb: 1.5 }}>
|
<Box key={output.key || index} _notLast={{ mb: 1.5 }}>
|
||||||
<DynamicOutputItem
|
<DynamicOutputItem
|
||||||
output={output}
|
output={output}
|
||||||
outputs={outputs}
|
outputs={outputs}
|
||||||
@@ -135,7 +135,7 @@ const DynamicOutputItem = ({
|
|||||||
type !== WorkflowIOValueTypeEnum.selectApp && type !== WorkflowIOValueTypeEnum.dynamic
|
type !== WorkflowIOValueTypeEnum.selectApp && type !== WorkflowIOValueTypeEnum.dynamic
|
||||||
)
|
)
|
||||||
.map((item) => ({
|
.map((item) => ({
|
||||||
label: t(FlowValueTypeMap[item].label),
|
label: t(getFlowValueTypeMeta(item).label),
|
||||||
value: item
|
value: item
|
||||||
}));
|
}));
|
||||||
}, [t]);
|
}, [t]);
|
||||||
@@ -178,6 +178,8 @@ const DynamicOutputItem = ({
|
|||||||
[output, onUpdate, onAdd, isEmptyItem, outputs]
|
[output, onUpdate, onAdd, isEmptyItem, outputs]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selectValueType = getFlowValueTypeMeta(output?.valueType).value;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex alignItems={'center'} mb={1} gap={2}>
|
<Flex alignItems={'center'} mb={1} gap={2}>
|
||||||
<Flex flex={'1'} bg={'white'} rounded={'md'}>
|
<Flex flex={'1'} bg={'white'} rounded={'md'}>
|
||||||
@@ -198,7 +200,7 @@ const DynamicOutputItem = ({
|
|||||||
h={10}
|
h={10}
|
||||||
borderLeftRadius={'none'}
|
borderLeftRadius={'none'}
|
||||||
borderColor={'myGray.200'}
|
borderColor={'myGray.200'}
|
||||||
value={output?.valueType}
|
value={selectValueType}
|
||||||
list={valueTypeList}
|
list={valueTypeList}
|
||||||
onChange={onChangeValueType}
|
onChange={onChangeValueType}
|
||||||
isDisabled={isEmptyItem}
|
isDisabled={isEmptyItem}
|
||||||
|
|||||||
+2
-3
@@ -1,4 +1,4 @@
|
|||||||
import { FlowValueTypeMap } from '@fastgpt/global/core/workflow/node/constant';
|
import { getFlowValueTypeMeta } from '@fastgpt/global/core/workflow/node/constant';
|
||||||
import type { BoxProps } from '@chakra-ui/react';
|
import type { BoxProps } from '@chakra-ui/react';
|
||||||
import { Box } from '@chakra-ui/react';
|
import { Box } from '@chakra-ui/react';
|
||||||
import type { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
import type { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||||
@@ -14,9 +14,8 @@ const ValueTypeLabel = ({
|
|||||||
valueType?: WorkflowIOValueTypeEnum;
|
valueType?: WorkflowIOValueTypeEnum;
|
||||||
valueDesc?: string;
|
valueDesc?: string;
|
||||||
} & BoxProps) => {
|
} & BoxProps) => {
|
||||||
const valueTypeData = valueType ? FlowValueTypeMap[valueType] : undefined;
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const label = valueTypeData?.label || '';
|
const label = valueType ? getFlowValueTypeMeta(valueType).label : '';
|
||||||
|
|
||||||
return !!label ? (
|
return !!label ? (
|
||||||
<MyTooltip label={valueDesc}>
|
<MyTooltip label={valueDesc}>
|
||||||
|
|||||||
Reference in New Issue
Block a user