1.0.54 • Published 1 year ago

lkm-tool v1.0.54

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

如何使用 MD5 ?

//引入
import {md5} from "lkm-tool";
//使用(注意这里的值必须是字符串)
md5("nbxng123456");

如何使用Mock ?

//引入自动生成模拟接口的Mock服务器
import {config,mockServerMsg,postAction} from "lkm-tool";
//导入配置文件
//config("Debug是否开启","开发环境接口前缀","调试环境接口前缀","正式环境接口前缀","自动生成接口分页列表数组集","自动生成接口增删改查数组集")
config(true,"/api","","",["lkm"],["lkm"]);
//启动服务器
mockServerMsg();
//看到控制台输出
// Api列表/api/lkm/query
// Api列表/api/lkm/save
// Api列表/api/lkm/remove
// Api列表/api/lkm/save
// mock服务器启动成功
//访问接口
postAction("/lkm/query",{page:1,pageSize:10}).then(res=>{
	console.log(res)
})
//也可以直接使用Mockjs原生,直接导入即可使用
import {Mock} from "lkm-tool";
Mock.mock("/api/lkm/login","post",{code:200,message:"successs"})

如何使用axios发起http请求 ?

import {getAction,postAction,requestInterceptors,editRequestHeaders,editStatusList} from "lkm-tool";

//请求头部加入参数(例如加入token和作者)
editRequestHeaders({accessToken:"******************",author:"lkm"})
//请求头拦截(如加入加载动画)
requestInterceptors(()=>{console.log("我在头部加了个加载动画")})
//响应状态拦截
editStatusList({
	200:()=>{console.log("响应回调,状态码为200")}
	401:()=>{console.log("响应回调,状态码为401,可以做退出登录或者其他处理")}
	6666:()=>{console.log("统一处理,不管回调啥都会执行,这里可以隐藏加载动画")}
});
postAction("/lkm/query",{page:1,pageSize:10}).then(res=>{
	console.log(res)
})
getAction("/lkm/query",{page:1,pageSize:10}).then(res=>{
	console.log(res)
})

如何在uni-app框架发起http请求 ?

import {uniAppHttp as http} from "lkm-tool";
http.request("/user/query",{page:1,pageSize:10},"post").then(res=>{
	console.log(res)
})
//或者同时发起多个请求
http.all(uniAppHttp.request('/user/query', {page: 1, pageSize: 10}),uniAppHttp.request('/user/save', {page: 1, pageSize: 10},"post")).then(res => {
console.log(res);
});

如何在使用字符串处理方法 ?

import {
	validatorIdCard,
	social_uni_code,
	validatorPhone,
	validatorBirth,
	validatorEmail,
	validatePassword,
	isRequired,
	isInteger,
	isIp,
	isPort,
	isInRange,
	stringHandleOne,
	stringHandleTwo
} from "lkm-tool";
//身份证校验
let id_card=validatorIdCard('111');
console.log(id_card)
//{code:false,data:false,message:"身份证长度错误"}
   
//通一社会信用代码校验
let social_uni_code=validatorSocialUniCode('111');
console.log(social_uni_code)
//{code:false,data:false,message:"统一社会信用代码为18位"}

//手机号校验
console.log(validatorPhone("18059662278"));
//true

//生日校验
console.log(validatorBirth("19900805"));
//true

//邮箱校验
console.log(validatorEmail("lkm@163.com"));
//true

//密码校验
console.log(validatePassword("Lkm668226214."));
//{code:true,data:false,message:"密码通过校验"}

//判断是否为空
console.log(isRequired(""));
//false

//判断是否整数
console.log(isInteger(1));
//true

//判断是否为IP
console.log(isIp(1));
//false

//判断是否是端口
console.log(isPort(1001));
//true

//判断字符串是否在整数范围内(value: number, max: number = 20, min: number = -10)
console.log(isInRange(1,20,1));
//true

//字符串超出多少位后变成...(value: string, num: number = 4, str: string = "...")
console.log(stringHandleOne("adfdfdfsdfsdfdsfsd57575665568",5,"********"));  
//adfdf********

//字符串中间变成...(value: string, start: number = 4, end: number = 4, str: string = "...")
console.log(stringHandleTwo("1805df8952333331df",4,2,"---"));
// 1805---31df

如何在使用日期处理 ?

import { getDate } from 'lkm-tool'
//转换为Date类型
console.log(getDate('2021-8-5'))
//Thu Aug 05 2021 00:00:00 GMT+0800 (中国标准时间)

//获得两个日期区间所有的日期(start: 开始时间, end: 结束时间, Spacer = '/')
console.log(getDiffDate("2023/2/21","2023/2/23","-"))
1.0.19

1 year ago

1.0.2

1 year ago

1.0.18

1 year ago

1.0.1

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.22

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.49

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.11

1 year ago

1.0.54

1 year ago

1.0.10

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.0

5 years ago