什么是 node-red-contrib-presenchecker?
node-red-contrib-presenchecker 是一个基于 Node-RED 的 npm 包,用于检测并提示使用者幻灯片演示时是否存在拖延、跳过或重复的情况。它需要使用者在 Node-RED 中进行配置,并且使演示时更具有流畅性和效率。此包常常被前端设计师和程序员等使用,可以帮助他们更高效、流畅地进行技术演示。
安装
首先,你需要安装 Node-RED。
然后,在 Node-RED 界面的右上角中点击 "导航栏" -> "设置" -> "节点",在搜索栏中输入 "node-red-contrib-presenchecker",并在下拉列表中找到它。最后,点击 "安装"。
安装完成后,请确保在 Node-RED 界面右下角得到如下提示:
配置
配置过程分为两步:第一步是将 node-red-contrib-presenchecker 节点左侧的 "input (msg.payload)" 置空,第二步是在 "topic" 中输入演示幻灯片的顺序。
如下所示:
可以看到,在此演示中的幻灯片顺序为:Slide 01、Slide 02、Slide 03、Slide 04 和 Slide 05。
现在,你已经完成了配置过程。
使用
当你开始演示时,你可以将你的演示计划和演示用的幻灯片轮流讲解。此时,node-red-contrib-presenchecker 将会计算出你演示的时间,从而提示你是否需要加快或放慢节奏。
下面是一个示例代码,可以用于对 "topic" 输入框进行填充:
[{"id":"1ebe22f8.08970d","type":"inject","z":"6e0639ac.e04c6","name":"演示开始","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"demo","payload":"{\"seq\":1,\"slide\":\"Slide 01\"}","payloadType":"json","x":170,"y":260,"wires":[["4918fa27.0b19bc"]]},{"id":"4918fa27.0b19bc","type":"presenchecker","z":"6e0639ac.e04c6","name":"","pause":"true","sendDuration":false,"durationUnits":"1","durationShow":false,"resize":false,"passFlowdata":false,"tasks":[],"_tasks":[],"_listeners":{"data":1613447318880,"end":1613447318880},"x":470,"y":260,"wires":[["fb4068a1.0c329"]]},{"id":"fb4068a1.0c329","type":"debug","z":"6e0639ac.e04c6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":260,"wires":[]},{"id":"c0546c56.8ebc78","type":"inject","z":"6e0639ac.e04c6","name":"Slide 02","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"demo","payload":"{\"seq\":2,\"slide\":\"Slide 02\"}","payloadType":"json","x":170,"y":300,"wires":[["4918fa27.0b19bc"]]},{"id":"10c00d54.e34f89","type":"inject","z":"6e0639ac.e04c6","name":"Slide 03","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"demo","payload":"{\"seq\":3,\"slide\":\"Slide 03\"}","payloadType":"json","x":170,"y":340,"wires":[["4918fa27.0b19bc"]]},{"id":"d0d65536.6506d8","type":"inject","z":"6e0639ac.e04c6","name":"Slide 04","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"demo","payload":"{\"seq\":1,\"slide\":\"Slide 04\"}","payloadType":"json","x":170,"y":380,"wires":[["4918fa27.0b19bc"]]},{"id":"d12399e9.a5218","type":"inject","z":"6e0639ac.e04c6","name":"Slide 05","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"demo","payload":"{\"seq\":1,\"slide\":\"Slide 05\"}","payloadType":"json","x":170,"y":420,"wires":[["4918fa27.0b19bc"]]}]
以上示例代码应该通过 Node-RED 点击 "导入",并将代码粘贴进入文本框中,如图所示:
注意:此代码与 Node-RED 版本可能有所不同,因此请阅读并理解你使用的 Node-RED 版本所支持的功能。
总结
node-red-contrib-presenchecker 是一个十分有用的 npm 包。它可以帮助使用者更好地组织演示,避免主题和顺序的混乱,并提高演示效果的流畅性。建议在进行技术演示时使用此 npm 包,从而帮助你更有效地传递你的信息。
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/6005536181e8991b448d0998