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 是一個很強大的工具 ,很方便