Files
FastGPT/packages/web/components/common/Avatar/index.tsx
heheer a4787bce5c feat: get node variables in prompt editor (#2087)
* feat: get node variables in prompt editor

* fix

* fix build

* merge

* fix build

* delete default parent

* fix

* fix
2024-07-23 11:20:23 +08:00

31 lines
763 B
TypeScript

import React from 'react';
import { Box, Flex, Image } from '@chakra-ui/react';
import type { ImageProps } from '@chakra-ui/react';
import { LOGO_ICON } from '@fastgpt/global/common/system/constants';
import MyIcon from '../Icon';
import { iconPaths } from '../Icon/constants';
const Avatar = ({ w = '30px', src, ...props }: ImageProps) => {
// @ts-ignore
const isIcon = !!iconPaths[src as any];
return isIcon ? (
<Box {...props}>
<MyIcon name={src as any} w={w} borderRadius={props.borderRadius} />
</Box>
) : (
<Image
fallbackSrc={LOGO_ICON}
fallbackStrategy={'onError'}
objectFit={'contain'}
alt=""
w={w}
h={w}
src={src || LOGO_ICON}
{...props}
/>
);
};
export default Avatar;