mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
add flags to help to decide file icon
This commit is contained in:
@@ -58,7 +58,7 @@ const queryToPath = (query?: ParsedUrlQuery) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FileListItem: FC<{
|
const FileListItem: FC<{
|
||||||
fileContent: { id: string; name: string; size: number; file: Object; lastModifiedDateTime: string }
|
fileContent: { id: string; name: string; size: number; file: Object; lastModifiedDateTime: string, video: any }
|
||||||
}> = ({ fileContent: c }) => {
|
}> = ({ fileContent: c }) => {
|
||||||
const emojiIcon = emojiRegex().exec(c.name)
|
const emojiIcon = emojiRegex().exec(c.name)
|
||||||
const renderEmoji = emojiIcon && !emojiIcon.index
|
const renderEmoji = emojiIcon && !emojiIcon.index
|
||||||
@@ -71,7 +71,7 @@ const FileListItem: FC<{
|
|||||||
{renderEmoji ? (
|
{renderEmoji ? (
|
||||||
<span>{emojiIcon ? emojiIcon[0] : '📁'}</span>
|
<span>{emojiIcon ? emojiIcon[0] : '📁'}</span>
|
||||||
) : (
|
) : (
|
||||||
<FontAwesomeIcon icon={c.file ? getFileIcon(c.name) : ['far', 'folder']} />
|
<FontAwesomeIcon icon={c.file ? getFileIcon(c.name, { video: Boolean(c.video) }) : ['far', 'folder']} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="truncate">
|
<div className="truncate">
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const DefaultPreview: FC<{ file: OdFileObject }> = ({ file }) => {
|
|||||||
<PreviewContainer>
|
<PreviewContainer>
|
||||||
<div className="md:flex px-5 py-4 md:space-x-8 items-center">
|
<div className="md:flex px-5 py-4 md:space-x-8 items-center">
|
||||||
<div className="text-center border rounded-lg px-10 py-20 border-gray-900/10 dark:border-gray-500/30">
|
<div className="text-center border rounded-lg px-10 py-20 border-gray-900/10 dark:border-gray-500/30">
|
||||||
<FontAwesomeIcon icon={getFileIcon(file.name)} />
|
<FontAwesomeIcon icon={getFileIcon(file.name, { video: Boolean(file.video) })} />
|
||||||
<div className="font-medium text-sm mt-6">{file.name}</div>
|
<div className="font-medium text-sm mt-6">{file.name}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -94,7 +94,15 @@ export function getExtension(fileName: string): string {
|
|||||||
return fileName.slice(((fileName.lastIndexOf('.') - 1) >>> 0) + 2).toLowerCase()
|
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)
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user