From 8c18ad941e5cd308cffa16cb55a634f5d53ffa0d Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 16 Oct 2023 15:09:47 +0800 Subject: [PATCH] perf: is utils --- src/utils/is.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/is.ts b/src/utils/is.ts index 37529859..8ac2e50d 100644 --- a/src/utils/is.ts +++ b/src/utils/is.ts @@ -103,3 +103,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 +}