初始化模版工程
This commit is contained in:
24
components/nova-sdk/task-panel/utils.ts
Normal file
24
components/nova-sdk/task-panel/utils.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 获取文件扩展名
|
||||
*/
|
||||
function getFileExtension(path: string): string {
|
||||
const parts = path.split('.')
|
||||
return parts.length > 1 ? parts[parts.length - 1].toLowerCase() : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是图片文件
|
||||
*/
|
||||
export function isImageFile(path: string): boolean {
|
||||
const ext = getFileExtension(path.replace(/\?.*$/, ''))
|
||||
return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp'].includes(ext)
|
||||
}
|
||||
|
||||
|
||||
export function safeParse(val: string) {
|
||||
try {
|
||||
return JSON.parse(val)
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user