1.0.11 • Published 2 years ago
sunrise-tools v1.0.11
曦工具函数库
安装
npm install sunrise-tools
使用方法
http请求使用
import { createHttp, HttpParamsType } from 'sunrise-tools'
const data: HttpParamsType = {
baseURL: '',
json: false,
token: false,
timeout: 0,
callback: () => {}
}
const baseApi = createHttp(data)
baseApi.get('接口名称', '参数')
baseApi.post('接口名称', '参数')
baseApi.delete('接口名称', '参数')
message提示框使用
import { Success, Error, Warning, Confirm, Alert } from 'sunrise-tools'
Success('') // 参数1: 提示信息, 参数2:持续时间 默认 2000
Error('') // 参数1: 提示信息, 参数2:持续时间 默认 2000
Warning('') //参数1: 提示信息, 参数2:持续时间 默认 2000
Confirm({
message: ''
})//参数: ConfirmConfigType
Alert('') //参数: 提示信息
列表合计使用
import { countSum, countSumAll } from 'sunrise-tools'
countSum(data, 'a') // 参数1: 数据对象json, 参数2:合计属性
countSumAll(2, 5) // 参数1: 除数, 参数2:被除数
websocket搭建使用
import { closeWebSocket, createWebSocket, sendMessage, getSocket } from 'sunrise-tools'
createWebSocket('链接') //创建websocket
sendMessage('数据') //发送消息
getSocket('回调函数') //接收消息
closeWebSocket() //关闭websocket