edpx-bat-ria
基于 bat-ria
的 edp
扩展,用来快速搭建业务端系统、生成项目代码框架。
RIA tools for Brand Ads Team
基于 bat-ria
的 edp
扩展,用来快速搭建业务端系统、生成项目代码框架。
传送门:eoo入口不对
最近有点时间想搞搞mock这块儿,现在bat-ria的mock方案还不是特别实用,大部分东西还是要自己搞,并且也缺少参数校验的功能,和我们项目的接口文档也没什么相关性,但是想想其实两者有很大的关联。因此有些想法和实现方案,大家可以一起讨论下可行性。
其实接口文档和mock是有很大的关联性的,而原来的开发方式这两者是孤立的,并且最要命的是还有复制/粘贴型的依赖,这有很大的隐患,而且大部分是人肉工作,低效,影响心情。但是文档又不能直接导出mock,因为文档是给人看得,程序看不懂,或者解析难度大。
要把两者联系起来,就必须把接口描述成让程序能看懂,所以,作为FE的我们,自然而然的想到json。把接口spec化,由它作为文档和mock的桥梁。文档和mock不再要自己人肉去开发,而是spec的产出。这样,不管需求和接口文档怎么变化,我们只要相应的更新spec,运行指令,就能轻松同步更新接口文档和mock。而且,有了spec,我们就知道了接口的请求参数的描述,我们就能做请求参数校验了,在联调之前我们就能杜绝刚才所说得问题的发生。这才是美好的世界啊。
spec数据结构:
[
{
module: '推广计划', //模块标示,用来作为接口文档的大标题
api: [
{
desc: '推广计划列表', //接口标示,作为副标题
req: {
url: '/data/promotion/173/list',
params: [
{
field: 'status',
desc: '推广计划状态 0: 未启用 1: 启用中 2: 结束',
required: true //用来作参数校验
},
...
]
},
res: {
isList: true, //是否是列表,来决定是否输出page相关内容,否则是一般响应
result: [ //忽略success、message..
{
field: 'ader',
desc: '广告主'//用来mock数据 比如 desc + @rowNumber
},
{
field: 'adId',
desc: '广告主Id',//用来mock数据 比如 desc + @rowNumber
type: 'number' //数据类型,用来伪造数据,不写则根据desc来构造
},
{
field: 'srcId',
desc: '资源Id',
value: '123,234235' //有时候可能因为规则复杂或者没有必要,就直接用固定值mock了
},
{
field: 'startTime',
desc: '投放开始时间',
type: 'time' //数据类型,用来伪造数据,不写则根据desc来构造
},
{
field: 'version',
desc: '数据版本',
value: '0', //有时候可能因为规则复杂或者没有必要,就直接用固定值mock了
},
...
]
}
},
...
]
},
...
]
这样,接口文档和mock逻辑都可以从这个spec文件中解析出来。
1、删除action相关模块文件目录
2、从main.less里面去除@import
3、从main.js里面requireConfig里面去除require
提供一个命令感觉有必要
RT,运行edp bat-ria init 命令创建单页应用,目录结构有问题,和wiki中描述的不一致。node6.0和0.12.3中都是这样
RT
edpx-bat-ria (0.2.1)
好像是因为 Win7 下面报错了,导致没有走到 then()
的处理逻辑。
require('../../lib/util/gen-main-less')(projectInfo, options);
require('../../lib/util/gen-index')(projectInfo, options);
if (entry) {
require('../../lib/util/gen-entry-main-less')(projectInfo, options);
}
// 生成默认的API配置和mockup
var createApi = require('../../lib/util/create-api');
createApi(projectInfo, ['api', 'constants', '/data/system/constants', 'ok']);
createApi(projectInfo, ['api', 'user', '/data/system/session', 'session']);
// var createAction = require('../../lib/util/create-action');
// createAction(projectInfo, ['action', '/dev/index', entry]);
// 更新本地的配置文件
var updateLoaderConfig = require('edp-project/cli/project/updateLoaderConfig');
updateLoaderConfig.cli.main();
package.json里面没有bat-ria-tool的信息,直接使用edp install 不会自动安装bat-ria-tool
这时候edp webserver启动会报错
如果用npm install bat-ria-tool不太人性化。
执行edp bat-ria create list /foo/bar
就可以了,不需要在配置其它额外的东东。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.