mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-21 21:24:46 +08:00
feat: support basic file presenting
This commit is contained in:
25
frontend/src/core/utils/files.ts
Normal file
25
frontend/src/core/utils/files.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user