perf: is utils

(cherry picked from commit 8c18ad941e5cd308cffa16cb55a634f5d53ffa0d)
This commit is contained in:
xingyu 2023-10-16 15:09:47 +08:00 committed by shizhong
parent 5ef9a14f3a
commit 16eb97e366

View File

@ -106,3 +106,12 @@ export const isUrl = (path: string): boolean => {
export const isDark = (): boolean => {
return window.matchMedia('(prefers-color-scheme: dark)').matches
}
// 是否是图片链接
export const isImgPath = (path: string): boolean => {
return /(https?:\/\/|data:image\/).*?\.(png|jpg|jpeg|gif|svg|webp|ico)/gi.test(path)
}
export const isEmptyVal = (val: any): boolean => {
return val === '' || val === null || val === undefined
}