fix(frontend): show media icons for APNG, AVIF and WebM (#6089)

This commit is contained in:
xihongshichaojidan8 2026-09-30 15:58:45 +08:00 committed by GitHub
parent c714629faf
commit d0e4d3525c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -234,6 +234,8 @@ export function getFileIcon(filepath: string, className?: string) {
case "jpg":
case "jpeg":
case "png":
case "apng":
case "avif":
case "gif":
case "bmp":
case "tiff":
@ -254,6 +256,7 @@ export function getFileIcon(filepath: string, className?: string) {
case "mp4":
case "mov":
case "m4v":
case "webm":
return <FilePlayIcon className={className} />;
default:
if (isCodeFile) {

View File

@ -0,0 +1,17 @@
import { expect, test } from "@rstest/core";
import { FilePlayIcon, FileTextIcon, ImageIcon } from "lucide-react";
import { canBrowserPreviewFile, getFileIcon } from "@/core/utils/files";
test.each([
["animation.apng", ImageIcon],
["photo.avif", ImageIcon],
["clip.webm", FilePlayIcon],
])("uses a media icon for previewable %s", (filepath, icon) => {
expect(canBrowserPreviewFile(filepath)).toBe(true);
expect(getFileIcon(filepath).type).toBe(icon);
});
test("keeps the document icon for an unknown extension", () => {
expect(getFileIcon("data.unknown").type).toBe(FileTextIcon);
});