https://github.com/yunsii/dva-base-models
📦 Base models config for dva.
https://github.com/yunsii/dva-base-models
curd dva model
Last synced: about 1 year ago
JSON representation
📦 Base models config for dva.
- Host: GitHub
- URL: https://github.com/yunsii/dva-base-models
- Owner: yunsii
- License: mit
- Created: 2019-07-30T15:17:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T02:29:36.000Z (about 3 years ago)
- Last Synced: 2025-02-14T02:51:26.870Z (about 1 year ago)
- Topics: curd, dva, model
- Language: TypeScript
- Homepage:
- Size: 418 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dva-base-models
[](https://github.com/theprimone/dva-base-models/blob/master/LICENSE)
[](https://www.npmjs.com/package/dva-base-models)
[](https://github.com/theprimone/dva-base-models/stargazers)
[](https://github.com/theprimone/dva-base-models/issues)
[](https://github.com/theprimone/dva-base-models/commits/master)
基于 dva 的基础 model 配置
## curdModel 增删改查 model
### config
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| getList | 配置如何从接口响应中得到数据列表和分页器 | (response) => ({ list: [], pagination: {} }) | - |
| getData | 配置如何从接口响应中得到对象详情 | (response) => ({}) | - |
| isResponseOk | 判断接口是否成功 | (response) => boolean | - |
### set
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| fetchMethod | 带查询参数的数据列表请求方法 | (paylaod) => Response | - |
| isolatedGetList | 单独定义 model 的 getList | (Response) => data | - |
| parallelFetchActions | 与查询并行的 action 列表 | string[] | [] |
| afterFetchActions | 查询后需要回调的 action 列表 | string[] | [] |
| detailMethod | 对象详情请求方法 | (id) => Response | - |
| isolatedGetData | 单独定义 model 的 getData | (Response) => data | - |
| parallelDetailActions | 与详情并行的 action 列表 | string[] | [] |
| afterDetailActions | 详情后需要回调的 action 列表 | string[] | [] |
| createMethod | 新建对象请求方法 | (paylaod) => Response | - |
| afterCreateActions | 创建后需要回调的 action 列表 | string[] | [] |
| updateMethod | 更新对象请求方法 | (id, paylaod) => Response | - |
| afterUpdateActions | 更新后需要回调的 action 列表 | string[] | [] |
| deleteMethod | 更新对象请求方法 | (id) => Response | - |
| afterDeleteActions | 删除后需要回调的 action 列表 | string[] | [] |
| extraState | 额外的 state ,可覆盖默认 state | {} | {} |
| extraEffects | 额外的 effect ,可覆盖默认 effect | {} | {} |
| extraReducers | 额外的 reducer ,可覆盖默认 reducer | {} | {} |
### 使用方法
* 配置 config : `getList` 、 `getData` 、 `isResponseOk`
* 配置 set : `fetchMethod` 、 `detailMethod` 、 `createMethod` 、 `updateMethod` 、 `deleteMethod`
具体使用参考 [Demo](https://github.com/zpr1g/ant-design-pro-plus/blob/v2/src/base-models/curd.ts) ,配置 `curdModel.config` 后导出 `curdModel.set` 。