|
|
@@ -7,16 +7,18 @@ import { memoize } from 'lodash'; |
|
|
|
|
|
|
|
interface FileIconProps extends ImageProps { |
|
|
|
extension: string; |
|
|
|
absolutePath?: string; |
|
|
|
} |
|
|
|
|
|
|
|
export default memo(function FileIcon(props: FileIconProps) { |
|
|
|
const { className, extension, ...restProps } = props; |
|
|
|
const { className, extension, absolutePath, ...restProps } = props; |
|
|
|
const isImg = isImgFile(extension) && !!absolutePath; |
|
|
|
return ( |
|
|
|
<div className={classNames(styles.fileIcon, className)}> |
|
|
|
<Image |
|
|
|
preview={false} |
|
|
|
{...restProps} |
|
|
|
src={fileIconSrc(extension)} |
|
|
|
src={isImg ? absolutePath : fileIconSrc(extension)} |
|
|
|
fallback={fileIconSrc('default')} |
|
|
|
/> |
|
|
|
</div> |
|
|
@@ -28,6 +30,12 @@ const fileIconSrc = memoize((extension: string) => { |
|
|
|
return `assets/file_icon/${fixedExtension}.svg`; |
|
|
|
}); |
|
|
|
|
|
|
|
const imgList: string[] = ['jpg', 'png', 'bmp', 'gif', 'jpeg']; |
|
|
|
|
|
|
|
function isImgFile(extension: string) { |
|
|
|
return imgList.includes(extension); |
|
|
|
} |
|
|
|
|
|
|
|
export function matchFileImage(extension: string) { |
|
|
|
switch (extension) { |
|
|
|
case 'ppt': |
|
|
|