You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.0 KiB
79 lines
2.0 KiB
export { isArray, isBoolean, isDate, isObject, isFunction, isString, isNumber, isNull } from 'lodash-es' |
|
import { isObject } from 'lodash-es' |
|
/** |
|
* @description 是否是http,邮件,电话号码 |
|
*/ |
|
export function isExternal(path: string) { |
|
return /^(https?:|mailto:|tel:)/.test(path) |
|
} |
|
|
|
/** |
|
* @description 是否是http |
|
*/ |
|
export const isLinkHttp = (link: string): boolean => /^(https?:)?\/\//.test(link) |
|
|
|
/** |
|
* @description 是否是电话号码 |
|
*/ |
|
export const isLinkTel = (link: string): boolean => /^tel:/.test(link) |
|
|
|
/** |
|
* @description 是否是手机号码 |
|
*/ |
|
export const isPhone = (link: string): boolean => /^1[3|5|6|7|8|9][0-9]{9}$/.test(link) |
|
|
|
/** |
|
* @description 是否是邮件 |
|
*/ |
|
export const isLinkMailto = (link: string): boolean => /^mailto:/.test(link) |
|
|
|
/** |
|
* @description 是否为空 |
|
* @param {unknown} value |
|
* @return {Boolean} |
|
*/ |
|
export const isEmpty = (value: unknown) => { |
|
return value !== null && value !== '' && typeof value !== 'undefined' |
|
} |
|
|
|
/** |
|
* @description 是否为空对象 |
|
* @param {Object} value |
|
* @return {Boolean} |
|
*/ |
|
export const isEmptyObject = (target: object) => { |
|
return isObject(target) && !Object.keys(target).length |
|
} |
|
|
|
/** |
|
* 手机号码验证 |
|
*/ |
|
export const PhoneReg = /^1[3|5|6|7|8|9][0-9]{9}$/ |
|
|
|
export function hidePhoneNumber(phoneNumber:string) { |
|
// 确保输入的是字符串 |
|
phoneNumber = phoneNumber.toString(); |
|
|
|
// 使用正则表达式替换中间七位数字为* |
|
const hiddenNumber = phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'); |
|
17634529379 |
|
return hiddenNumber; |
|
} |
|
export function hideQQ(qqNumber:string) { |
|
// 确保输入的是字符串 |
|
qqNumber = qqNumber.toString(); |
|
|
|
// 使用正则表达式替换中间的数字为* |
|
var hiddenQQ = qqNumber.replace(/(\d{3})\d+(\d{2})/, '$1****$2'); |
|
|
|
return hiddenQQ; |
|
} |
|
// 去除图片url前缀 |
|
export function urlSplit(url:any) { |
|
if (url.indexOf("hjbimage") !== -1) { |
|
return 'hjbimage' + url.split('hjbimage')[1] |
|
}else{ |
|
return url |
|
} |
|
|
|
}
|
|
|