49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
![]() |
import {
|
||
|
FilePdfOutlined,
|
||
|
FileWordOutlined,
|
||
|
FileExcelOutlined,
|
||
|
FilePptOutlined,
|
||
|
FileTextOutlined,
|
||
|
FileZipOutlined,
|
||
|
FileImageOutlined,
|
||
|
FileUnknownOutlined,
|
||
|
} from "@ant-design/icons";
|
||
|
|
||
|
export const isContentEmpty = (html: string) => {
|
||
|
// 创建一个临时 div 来解析 HTML 内容
|
||
|
const temp = document.createElement("div");
|
||
|
temp.innerHTML = html;
|
||
|
// 获取纯文本内容并检查是否为空
|
||
|
return !temp.textContent?.trim();
|
||
|
};
|
||
|
export const getFileIcon = (filename: string) => {
|
||
|
const extension = filename.split(".").pop()?.toLowerCase();
|
||
|
switch (extension) {
|
||
|
case "pdf":
|
||
|
return <FilePdfOutlined className="text-red-500" />;
|
||
|
case "doc":
|
||
|
case "docx":
|
||
|
return <FileWordOutlined className="text-blue-500" />;
|
||
|
case "xls":
|
||
|
case "xlsx":
|
||
|
return <FileExcelOutlined className="text-green-600" />;
|
||
|
case "ppt":
|
||
|
case "pptx":
|
||
|
return <FilePptOutlined className="text-orange-500" />;
|
||
|
case "txt":
|
||
|
return <FileTextOutlined className="text-gray-600" />;
|
||
|
case "zip":
|
||
|
case "rar":
|
||
|
case "7z":
|
||
|
return <FileZipOutlined className="text-purple-500" />;
|
||
|
case "png":
|
||
|
case "jpg":
|
||
|
case "jpeg":
|
||
|
case "gif":
|
||
|
case "webp":
|
||
|
return <FileImageOutlined className="text-pink-400" />;
|
||
|
default:
|
||
|
return <FileUnknownOutlined className="text-gray-500" />;
|
||
|
}
|
||
|
};
|