mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: The key for the begin operator can only contain alphanumeric characters and underscores. #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import { FileIconMap } from '@/constants/file';
|
|
import { cn } from '@/lib/utils';
|
|
import { getExtension } from '@/utils/document-util';
|
|
import { CSSProperties } from 'react';
|
|
|
|
type IconFontType = {
|
|
name: string;
|
|
className?: string;
|
|
style?: CSSProperties;
|
|
};
|
|
|
|
export const IconFont = ({ name, className, style }: IconFontType) => (
|
|
<svg className={cn('size-4', className)} style={style}>
|
|
<use xlinkHref={`#icon-${name}`} />
|
|
</svg>
|
|
);
|
|
|
|
export function IconFontFill({
|
|
name,
|
|
className,
|
|
isFill = true,
|
|
}: IconFontType & { isFill?: boolean }) {
|
|
return (
|
|
<span className={cn('size-4', className)}>
|
|
<svg
|
|
className={cn('size-4', className)}
|
|
style={{ fill: isFill ? 'currentColor' : '' }}
|
|
>
|
|
<use xlinkHref={`#icon-${name}`} />
|
|
</svg>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export function FileIcon({
|
|
name,
|
|
className,
|
|
type,
|
|
}: IconFontType & { type?: string }) {
|
|
const isFolder = type === 'folder';
|
|
return (
|
|
<span className={cn('size-4', className)}>
|
|
<IconFont
|
|
name={isFolder ? 'file-sub' : FileIconMap[getExtension(name)]}
|
|
></IconFont>
|
|
</span>
|
|
);
|
|
}
|