Appearance
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')
// 默认图标路径