Files
FastGPT/packages/web/components/common/Avatar/index.tsx
T
Archer 005fbf8cdb fix: vector ts (#6166)
* stop design doc

* remove invalid doc

* rename

* fix: ts

* perf: auto fit

* perf: comment menu

* remove invalid checker

* save button colorschema

* fix: icon

* perf: color schema

* fix: icon

* perf: icon

* perf: icon

* perf: icon

* perf: icon
2025-12-31 00:54:04 +08:00

42 lines
947 B
TypeScript

import React from 'react';
import { Box } 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';
import MyImage from '../Image/MyImage';
const Avatar = ({
w = '30px',
src,
fill,
...props
}: Omit<ImageProps, 'src'> & { src?: string | null }) => {
// @ts-ignore
const isIcon = !!iconPaths[src as any];
return isIcon ? (
<Box display={'inline-flex'} {...props}>
<MyIcon
name={src as any}
w={w}
borderRadius={props.borderRadius}
{...(fill ? { fill } : {})}
/>
</Box>
) : (
<MyImage
fallbackSrc={LOGO_ICON}
fallbackStrategy={'onError'}
objectFit={'contain'}
alt=""
w={w}
h={w}
src={src || LOGO_ICON}
{...props}
/>
);
};
export default React.memo(Avatar);