保存进度!
This commit is contained in:
@@ -2,9 +2,55 @@
|
||||
* @Author: Kane Wang <wangkane@qq.com>
|
||||
* @Date: 2025-10-23 16:52:10
|
||||
* @LastEditors: Kane Wang
|
||||
* @LastModified: 2025-10-23 17:04:54
|
||||
* @LastModified: 2025-11-21 11:17:40
|
||||
* @FilePath: src/utils/utils.ts
|
||||
* @Description:
|
||||
* @Description: 提供 一些功能性的函数
|
||||
*
|
||||
* Copyright (c) 2025 by Kane All rights reserved
|
||||
*/
|
||||
|
||||
/**
|
||||
* 取文件路径末尾的扩展名作为文件类型
|
||||
* @param filePath 文件路径
|
||||
* @returns 文件类型字符串
|
||||
*/
|
||||
function getFileType( filePath: string ): string
|
||||
{
|
||||
let type = "未知类型";
|
||||
|
||||
if ( filePath == null || filePath.length == 0 )
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
const startIndex = filePath.lastIndexOf( "." );
|
||||
const fileType = filePath.slice( startIndex + 1 ).toUpperCase();
|
||||
|
||||
// ignore-eslint-next-line
|
||||
switch( fileType )
|
||||
{
|
||||
case "DOCX":
|
||||
type = "WPS文档";
|
||||
break;
|
||||
case "XLSX":
|
||||
type = "WPS表格";
|
||||
break;
|
||||
case "PDF":
|
||||
type = "PDF文档";
|
||||
break;
|
||||
case "JPG":
|
||||
case "PNG":
|
||||
case "BMP":
|
||||
case "GIF":
|
||||
type = "图片文件";
|
||||
break;
|
||||
default:
|
||||
type = "未知文件类型";
|
||||
}
|
||||
|
||||
// type = fileType.length != 0 ? fileType + "文件" : "未知类型";
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
export { getFileType };
|
||||
Reference in New Issue
Block a user