perf:完善readme
This commit is contained in:
42
README.md
Normal file
42
README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
## 工具包
|
||||
|
||||
### 通用方法类(Common.js)
|
||||
|
||||
```js
|
||||
import {Common} from "@tiesheng/npm-tool";
|
||||
|
||||
Common.isEmpty("tet")
|
||||
|
||||
```
|
||||
|
||||
### 网络请求类(HttpUtil)
|
||||
|
||||
```js
|
||||
import {HttpUtil} from "@tiesheng/npm-tool";
|
||||
|
||||
// 全局配置
|
||||
HttpUtil.setConfig({
|
||||
encryptBody: true, // 加密发送数据,默认加密秘钥:WmdUzPJXbngVNiaSsQrihg==(具体秘钥咨询后台开发人员)
|
||||
});
|
||||
HttpUtil.post("http://localhost:8080",{key:"111",value:"2222"}).then(console.log);
|
||||
|
||||
// 这里Promise返回的数据只有data,不在包含code等其他字段。
|
||||
// Hello World!
|
||||
|
||||
```
|
||||
|
||||
### 存储类(Storage)
|
||||
```js
|
||||
import {Storage} from "@tiesheng/npm-tool";
|
||||
|
||||
// save方法可以直接保存对象
|
||||
Storage.save("keyVal", {key: 111, val: 2222});
|
||||
|
||||
let obj = Storage.get("keyVal");
|
||||
console.log(obj);
|
||||
|
||||
// log
|
||||
// {key: 111, val: 2222}
|
||||
|
||||
```
|
||||
|
||||
4
index.js
4
index.js
@@ -1,9 +1,13 @@
|
||||
const Common = require('./src/utils/Common')
|
||||
const Storage = require('./src/utils/Storage')
|
||||
const crypto = require('./src/utils/Crypto')
|
||||
const SM4 = require('./src/utils/SM4')
|
||||
const HttpUtil = require('./src/https/HttpUtil')
|
||||
|
||||
module.exports = {
|
||||
HttpUtil,
|
||||
Common,
|
||||
Storage,
|
||||
SM4,
|
||||
crypto,
|
||||
}
|
||||
@@ -133,8 +133,6 @@ async function post(url, data = {}) {
|
||||
newData = {...data};
|
||||
}
|
||||
|
||||
console.log(newData);
|
||||
|
||||
return req(url, {method: 'POST', data: newData});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user