You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
xuesinan f32f128f37 发证 4 years ago
.gitignore 适配模板 4 years ago
.svrxrc.js feat: svrx mock 4 years ago
README.md doc: 添加说明文档 4 years ago
index.html 发证 4 years ago
package-lock.json 绑定按钮插件 4 years ago
package.json feat: svrx mock 4 years ago
route.js 患者转归插件 4 years ago

README.md

插件模板

环境搭建

安装svrx

npm install -g @svrx/cli

运行

npm run dev

mock

修改route.js里的文件, 范例:

get('/handle(.*)').to.handle((ctx) => { ctx.body = 'handle'; });
get('/blog(.*)').to.json({ code: 200 });
get('/code(.*)').to.send('code', 201);
get('/json(.*)').to.send({ json: true });
get('/text(.*)').to.send('haha');
get('/html(.*)').to.send('<html>haha</html>');
get('/rewrite:path(.*)').to.rewrite('/query{path}');
get('/redirect:path(.*)').to.redirect('localhost:9002/proxy{path}');
get('/api(.*)').to.proxy('http://mock.server.com/')
get('/test(.*)').to.proxy('http://mock.server.com/', {
  secure: false,
})
get('/test/:id').to.proxy('http://{id}.dynamic.server.com/')
get('/query(.*)').to.handle((ctx) => {
  ctx.body = ctx.query;
});
get('/header(.*)')
  .to.header({ 'X-From': 'svrx' })
  .json({ user: 'svrx' });
get('/user').to.json({ user: 'svrx' });

get('/sendFile/:path(.*)').to.sendFile('./{path}');

参考文档:

开发注意事项

  • 请求推荐使用fetch
  • 内置插件要求有唯一的根元素, 添加data-root属性, 以此来进行DOM操作,data-root的值, 会再插件绑定时动态替换为全局唯一的id. data-root属性在代码片段中, 只允许在根元素上出现
  • TALL传递的数据从根元素的父级元素上通过data-[xxx]的方式获取
  • 代码片段中不允许添加id等属性(TALL页面中会出现多个同样的插件)
  • 插件的script里要添加全局的命名空间, 命名格式为p[id], 如插件id为100, namespace为p100