add flags to help to decide file icon

This commit is contained in:
myl7
2022-01-24 16:03:35 +08:00
parent d3d69849c9
commit a53c0ab985
3 changed files with 13 additions and 5 deletions
+10 -2
View File
@@ -94,7 +94,15 @@ export function getExtension(fileName: string): string {
return fileName.slice(((fileName.lastIndexOf('.') - 1) >>> 0) + 2).toLowerCase()
}
export function getFileIcon(fileName: string): [IconPrefix, IconName] {
export function getFileIcon(fileName: string, flags?: { video?: boolean }): [IconPrefix, IconName] {
const extension = getExtension(fileName)
return hasKey(extensions, extension) ? extensions[extension] : icons.file
let icon = hasKey(extensions, extension) ? extensions[extension] : icons.file
if (extension === 'ts') {
if (flags?.video) {
icon = icons.video
}
}
return icon
}