@hzab/data-model 2.0.2 → 2.0.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/README.md +17 -0
- package/package.json +2 -3
- package/src/ArrayUtils.ts +712 -712
- package/src/RequestCache.ts +202 -0
- package/src/array-data-model.ts +1 -1
- package/src/axios.ts +245 -210
- package/src/data-model.ts +16 -16
- package/src/hooks.ts +38 -38
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -127,6 +127,23 @@ function Demo({ orgId }) {
|
|
|
127
127
|
}
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
|
|
131
|
+
#### 重复请求拦截
|
|
132
|
+
```tsx
|
|
133
|
+
import RequestCache from "@hzab/data-model/RequestCache";
|
|
134
|
+
import { AxiosRequestConfigWithCache, setAxRequest } from "@hzab/data-model";
|
|
135
|
+
|
|
136
|
+
const requestCache = new RequestCache({ options: { cacheTTL: 2000 } });
|
|
137
|
+
|
|
138
|
+
setAxRequest((config: AxiosRequestConfigWithCache) => {
|
|
139
|
+
// 拦截 get 请求
|
|
140
|
+
if (config.method.toLowerCase() === "get") {
|
|
141
|
+
return requestCache.handleAxRequest(config);
|
|
142
|
+
}
|
|
143
|
+
return config;
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
130
147
|
## DataModel
|
|
131
148
|
|
|
132
149
|
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/data-model",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3-alpha.1",
|
|
4
4
|
"description": "data model",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"scripts": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"eslint": "^8.30.0",
|
|
35
35
|
"js-cookie": "^3.0.5",
|
|
36
36
|
"less": "^4.1.3",
|
|
37
|
+
"lodash-es": "^4.18.1",
|
|
37
38
|
"mobx": "^6.7.0",
|
|
38
39
|
"mobx-react": "^7.6.0",
|
|
39
40
|
"react": "^17.0.2",
|
|
@@ -48,8 +49,6 @@
|
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
51
|
"dayjs": "^1.11.7",
|
|
51
|
-
"axios": ">=1.6.2",
|
|
52
|
-
"js-cookie": ">=3.0.5",
|
|
53
52
|
"nanoid": "^3.3.7"
|
|
54
53
|
},
|
|
55
54
|
"directories": {
|