boxplay-utils
v0.0.5
Published
utils
Downloads
1
Readme
公共函数
import {
setLocalStorage,
getLocalStorage,
removeLocalStorage,
setCookie,
getCookie,
setExpLocalStorage,
getExpLocalStorage,
getFinger,
formatDateTime,
getWeekDayIndex,
judgeHttps,
getUrlToJson,
getFileSufffix,
xss,
Fingerprint2,
isMobile,
getDeviceInfo
} from '@bitget/utils'
// 自适应字体大小
import './utils/common/mateRem'
// 判断是否是移动端
console.log(isMobile(),'isMobile')
// 获取设备类型和body宽度
console.log(getDeviceInfo(),'getDeviceInfo')
// 格式化时间戳
console.log(formatDateTime(1662026281))
console.log(formatDateTime(1662026281),'years')
console.log(formatDateTime(1662026281),'month')
console.log(formatDateTime(1662026281),'day')
console.log(formatDateTime(1662026281),'hours')
console.log(formatDateTime(1662026281),'minutes')
// 打印内容: 2022-9-1 17:58
// 获取当日处于周内第几天 下标从0 开始,0 - 6
console.log(getWeekDayIndex(1662026281),'getWeekDayIndex')
// 设置localstorage
setLocalStorage('test1','aaa')
// 获取localstorage
console.log(getLocalStorage('test1'))
// 移除storage内容
removeLocalStorage('test1')
//设置cookie
setCookie('a','sss')
//获取cookie
console.log(getCookie('a'))
// 设置带过期时间的storage
setExpLocalStorage('test2',1,10);
// 获取带过期时间的storage
console.log(getExpLocalStorage('test2'))
// 判断链接是否https
console.log(judgeHttps('https://gitlab-upex.go.akamai-access.com/'))
// 获取链接中的参数 {id:1,a:'c',d:4}
console.log(getUrlToJson('https://gitlab-upex.go.akamai-access.com?id=1&a=c&d=4'))
// 获取文件后缀名
console.log(getFileSufffix('1.txt'))
// 获取指纹
console.log(Fingerprint2.x64hash128('aaaa', 31))
// 过滤xss 内容
console.log(xss('111<script>alert("xss");</script>222'))