feat: support basic file presenting

This commit is contained in:
Henry Li
2026-01-16 22:35:20 +08:00
parent 4b69aed47b
commit f9853f037c
4 changed files with 102 additions and 4 deletions

View File

@@ -0,0 +1,25 @@
export function getFileName(filepath: string) {
return filepath.split("/").pop()!;
}
export function getFileExtension(filepath: string) {
const fileName = getFileName(filepath);
const extension = fileName.split(".").pop()!.toLocaleLowerCase();
switch (extension) {
case "doc":
case "docx":
return "Word";
case "md":
return "Markdown";
case "txt":
return "Text";
case "ppt":
case "pptx":
return "PowerPoint";
case "xls":
case "xlsx":
return "Excel";
default:
return extension.toUpperCase();
}
}