sailing-utils
v1.1.2
Published
``` npm i sailing-utils -S ```
Downloads
42
Readme
安装
npm i sailing-utils -S
使用
import sailing from 'sailing-utils'
sailing.auth.IdentificationCheck(id)
方法
- 身份验证类-auth
IdentificationCheck(idCardNo:String):Boolean;
//检测中国公民身份证是否规范 string
- 时间类-time
formatSeconds(seconds:Number):String;
//将秒数格式化为HH:mm:SS,61s => 00:01:01
getDateDiff(str:String)
//格式化时间
//getDateDiff('2021-06-10 18:14:02')=> 3分钟前/x小时前/x天前
formatEndTime(num:Number):String
/**
* 获取指定的时间,返回数据格式 yyyy-MM-dd HH:mm:ss 类型 String
* @param num 0代表今天,-3代表3天前,3代表3天后,以此类推
* @returns {string}
*/
formatEndTime(num:Number):String
/**
* 获取指定的时间,返回数据格式 yyyy-MM-dd HH:mm:ss 类型 String
* @param num 0代表今天,-3代表3天前,3代表3天后,以此类推 ,末尾时分秒规定是 23:59:59
* @returns {string}
*/
getWeek.run(String):Object
/**
* 获取指定年份内存在的周及明细
* @param String 2021
* @returns {Object}{1:['2021-01-01','',...],2:[],3:[]....}
*/
- 节点类-node
handleGetTreeExtent(node:Array<any>):Number
//广度遍历
handleGetTreeDeep(node:Array<any>):Number
//深度遍历
- 数据类型-dataType
cloneDeep(val):T
//深拷贝
isPrimitive(val):Boolean
//是否为基本数据类型
isObject(val):Boolean
//是否为对象
- 请求类-request
formatQuery(req:Object):Object
//格式化请求
// formatQuery({a:1,b:0,c:'',d:null,e:undefined}) => {a:1,b:0}
GetUrlQuery(urlStr:String):Object
//获取地址栏query
//GetUrlQuery('http://www.xx.com?a=1&b=2&c=3') => {a:1,b:2,c:3}
- 字符串类-str
isChineseWord(str:String):Boolean;
//检测字符串是否为全中文 string
sliceStrByDeLengh(str:String,length:Number,extra:String):String
//格式化(裁取)字符串
//sliceStrByDeLengh(abcdefg,5,'....') => abcd...
trim(String):String
//去掉开头和结尾的space, tab, form feed, and line feed (same as [\f\n\r\t\v]).
// str.replace(/(^\s*)|(\s*$)/g, "")
- 文件类-file
dataURLtoFile(base64:string,filename:string):File
//base64转文件
Blob2File(blob:Blob,filename:string):File
//Bolb转file
- 地图类-map
/坐标系转换
mapTransform:{
bd09_to_gcj02: bd09_to_gcj02,
gcj02_to_bd09: gcj02_to_bd09,
wgs84_to_gcj02: wgs84_to_gcj02,
gcj02_to_wgs84: gcj02_to_wgs84,
wgs84_to_bd09:wgs84togcj02tobd09
}
WGS84坐标系:地球坐标系,国际通用坐标系
GCJ02坐标系:火星坐标系,WGS84坐标系加密后的坐标系;Google国内地图、高德、QQ地图 使用
BD09坐标系:百度坐标系,GCJ02坐标系加密后的坐标系
例:mapTransform.bd09_to_gcj02(lng,lat):[]
- 交互类-interaction
debounce(Function, String):Function
// 防抖
_throttle(Function, String):Function
// 节流
- 浏览器-browser
getUserIP(onNewIP):String
// 获取用户IP 信息
browser():Object
// 读取浏览器内核
- 其他工具-tools
watermark(text:String,slogan?:String,options:Object):T;
// text:水印文字,必填,
// slogan:警示标语,必填,可传空字符串'',
// options:水印设置,可选,默认值:{
// watermark_txt:settings,
// watermark_x:20,//水印起始位置x轴坐标
// watermark_y:20,//水印起始位置Y轴坐标
// watermark_rows:20,//水印行数
// watermark_cols:20,//水印列数
// watermark_x_space:20,//水印x轴间隔
// watermark_y_space:60,//水印y轴间隔
// watermark_color:'#000000',//水印字体颜色
// watermark_alpha:0.1,//水印透明度
// watermark_fontsize:'15px',//水印字体大小
// watermark_font:'微软雅黑',//水印字体
// watermark_width:300,//水印宽度
// watermark_height:80,//水印长度
// watermark_angle:15//水印倾斜度数
// };