kn-hooks 0.0.35 → 0.0.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-hooks",
3
- "version": "0.0.35",
3
+ "version": "0.0.39",
4
4
  "scripts": {
5
5
  "dev": "cross-env env_api=dev env_package=dev webpack-dev-server --progress",
6
6
  "build": "cross-env env_api=prod env_package=prod webpack --config webpack.config.js",
@@ -145,14 +145,18 @@ const usePagination=(props)=>{
145
145
  console.log('[usePagination] response',req)
146
146
  let response={};
147
147
  if(req?.code==0){
148
- let {page:{current,pageSize,total},data:reqData} = req;
148
+ let {page:{current,total},data:reqData} = req;
149
+ let _pageSize=pageSize;
150
+ // 兼容没数据的时候如果pageSize为0会导致接下来刷新的时候也按0的pageSize来写入
151
+ if(req?.page?.pageSize){
152
+ _pageSize=+req?.page?.pageSize;
153
+ }
149
154
  current=+current;
150
- pageSize=+pageSize;
151
155
  total=+total;
152
- const startIdx= (current-1)*pageSize;
153
- const more = current*pageSize<total;
156
+ const startIdx= (current-1)*_pageSize;
157
+ const more = current*_pageSize<total;
154
158
  response.pagination={
155
- current,pageSize,total,startIdx,more
159
+ current,pageSize:_pageSize,total,startIdx,more
156
160
  };
157
161
  setPagination(response.pagination);
158
162
  response.data= clear?[]:(data||[]);