AntD的前端设计(二) 之前只讲如何配置 RequestConfig 和 ResponseStructure, 这里面内部其实就是为了保持和服务端消息同步, 日常消息协议格式我都采取以下方式:
// 常规消息结构体 { "error": 0, "message": "success", "data": {}, } // 这里提供登录授权完成和数据分页完成格式的返回示例 // 1. 授权完成 { "error": 0, "message": "success", "data": { "uid": 1, "username": "meteorcat", "nickname": "MeteorCat", "token": "97ba4dd71592c7b26bc90308806d42f3" }, } // 2. 分页返回, 分页返回有两种: // 2.1 前端推送页数(page)和数据量(total), 服务端返回当前页和总页数(list,page,total) // 2.2 前端推送偏移两(offset)和数据量(total), 服务端返回当前页和总页数(list,page,total) { "error": 0, "message": "success", "data": { "list": [ { "id": 1, "name": "MeteorCat" }, // 其他数据 ], "page": 1, // 数据分页页码 "total": 10, // 总共数据页数 } } 大部分业务都是围绕数据流展示( 像是支付订单|人员流失的查询 )和图表分析( 后台返回数据JSON格式 ), 基本上面那些方式够用了.