CatPtain's picture
Upload 339 files
89ce340 verified
raw
history blame
524 Bytes
import { padStart } from 'lodash'
/**
* 补足数字位数
* @param digit 数字
* @param len 位数
*/
export const fillDigit = (digit: number, len: number) => {
return padStart('' + digit, len, '0')
}
/**
* 判断设备
*/
export const isPC = () => {
return !navigator.userAgent.match(/(iPhone|iPod|iPad|Android|Mobile|BlackBerry|Symbian|Windows Phone)/i)
}
/**
* 判断URL字符串
*/
export const isValidURL = (url: string) => {
return /^(https?:\/\/)([\w-]+\.)+[\w-]{2,}(\/[\w-./?%&=]*)?$/i.test(url)
}