Download frontend/src/utils/common.ts from CatPtain/web_ppt: direct link, hf CLI and curl.
- Browser
- Download file 524 Bytes
-
https://huggingface.co/spaces/CatPtain/web_ppt/resolve/main/frontend/src/utils/common.ts
- Command line
-
hf download hf://spaces/CatPtain/web_ppt/frontend/src/utils/common.ts
-
curl -L -o common.ts https://huggingface.co/spaces/CatPtain/web_ppt/resolve/main/frontend/src/utils/common.ts
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) | |
| } |