mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-19 20:16:49 +08:00
feat: add file icon and add message popover content (#77)
* feat: add message popover content * feat: add file icon
This commit is contained in:
34
web/src/components/svg-icon.tsx
Normal file
34
web/src/components/svg-icon.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
import {
|
||||
UseDynamicSVGImportOptions,
|
||||
useDynamicSVGImport,
|
||||
} from '@/hooks/commonHooks';
|
||||
|
||||
interface IconProps extends React.SVGProps<SVGSVGElement> {
|
||||
name: string;
|
||||
onCompleted?: UseDynamicSVGImportOptions['onCompleted'];
|
||||
onError?: UseDynamicSVGImportOptions['onError'];
|
||||
}
|
||||
|
||||
const SvgIcon: React.FC<IconProps> = ({
|
||||
name,
|
||||
onCompleted,
|
||||
onError,
|
||||
...rest
|
||||
}): React.ReactNode | null => {
|
||||
const { error, loading, SvgIcon } = useDynamicSVGImport(name, {
|
||||
onCompleted,
|
||||
onError,
|
||||
});
|
||||
if (error) {
|
||||
return error.message;
|
||||
}
|
||||
if (loading) {
|
||||
return 'Loading...';
|
||||
}
|
||||
if (SvgIcon) {
|
||||
return <SvgIcon {...rest} />;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export default SvgIcon;
|
||||
Reference in New Issue
Block a user