Skip to content

getFileIcon 获取文件图标

function getFileIcon(filePath: string): string

根据文件路径提取后缀,并返回对应的图标资源路径。未匹配到图标时返回默认文件图标。

参数

参数名说明类型默认值
filePath文件路径string必填

返回值

返回值说明类型
icon图标资源路径string

示例

typescript
import { getFileIcon } from '@mingto/tools'

getFileIcon('/docs/report.pdf')
// PDF 图标路径

getFileIcon('/files/archive.zip')
// 默认图标路径