使用blessed-contrib 开发专业的终端dashboard

blessed-contrib 是blessed 的一个扩展包,以前有说过blessed(一个方便的开发cli 的工具)
我们使用blessed-contrib可以开发专业的终端dashboard 功能强大,组件丰富

以下是来自官方demo的一个有运行

clone 代码

git clone https://github.com/yaronn/blessed-contrib
 

安装依赖

cd blessed-contrib 
yarn
 

运行demo

node examples/dashboard.js
 

效果:

 

 

代码说明

使用过程中为了更新使用了setInterval,同时在定时函数中添加更新数据 ,同时为了界面的resize, 添加了resize 方法:

screen.on('resize', function() {
  donut.emit('attach');
  gauge.emit('attach');
  gauge_two.emit('attach');
  sparkline.emit('attach');
  bar.emit('attach');
  table.emit('attach');
  lcdLineOne.emit('attach');
  errorsLine.emit('attach');
  transactionsLine.emit('attach');
  map.emit('attach');
  log.emit('attach');
});
screen.render();
 
 

说明

blessed-contrib 是一个很强大的工具 ,很方便

参考资料

https://github.com/yaronn/blessed-contrib

posted on 2019-10-11 22:19  荣锋亮  阅读(1617)  评论(0编辑  收藏  举报

导航