diff --git a/main.aardio b/main.aardio index 795ba00..486fc2a 100644 --- a/main.aardio +++ b/main.aardio @@ -1,10 +1,11 @@ //低代码框架 amis import win.ui; /*DSG{{*/ -var winform = win.form(text="WebView2 - 调用百度低代码前端框架 amis";right=966;bottom=622;border="none";maximize=1) +var winform = win.form(text="WebView2 - 调用百度低代码前端框架 amis";right=966;bottom=622;border="none";maximize=1;) winform.add( -bk={cls="bk";left=0;top=-1;right=967;bottom=30;bgcolor=10789024;dl=1;dr=1;dt=1;z=1}; -custom={cls="custom";text="自定义控件";left=0;top=32;right=967;bottom=623;db=1;dl=1;dr=1;dt=1;z=2} +bk={cls="bk";left=0;top=-1;right=967;bottom=30;bgcolor=10789024;dl=1;dr=1;dt=1;z=1;}; +custom={cls="custom";text="自定义控件";left=0;top=32;right=967;bottom=623;db=1;dl=1;dr=1;dt=1;z=2;}; + ) /*}}*/ @@ -115,22 +116,8 @@ udpSend = function(d){ getStatus = function(){ - var str = /** -// API 返回数据 - - { - "id": 1, - "state": "success", - "color": "#00FF00" - } - - - -**/ - -return web.json.parse(str); - - ; + var seed = string.random("Success","Fault","PowerDown") + return {state=seed}; } diff --git a/res/cfg.json b/res/cfg.json index 873c1dc..c79ac73 100644 --- a/res/cfg.json +++ b/res/cfg.json @@ -182,10 +182,10 @@ "data": { "maxBarCnt":"60", "items": [ - {"color": "#FF0000"}, - {"color": "#00FF00"}, - {"color": "#0000FF"}, - {"color": "#FFFF00"}, + {"color": "#808080"}, + {"color": "#808080"}, + {"color": "#808080"}, + {"color": "#808080"}, ] }, "body": [ @@ -194,11 +194,11 @@ "name": "items", "items": { "type": "tpl", - "tpl": "
", + "tpl": "

", "style": { "display": "inline-block", - "marginRight": "10px", - "marginBottom": "10px" + "marginRight": "5px", + "marginBottom": "5px" } } } @@ -208,7 +208,7 @@ "actions": [ { "actionType": "custom", - "script": "const color = event.data.responseData.items;\ncontext.props.data.items.push(color)\nif (context.props.data.items.length > context.props.data.maxBarCnt) {\n context.props.data.items.shift(); // Remove the oldest value\n};" + "script": "const colorMap={'Success':'#00ff00','Fault':'#ff0000','PowerDown':'#808080'};\n const ncolor = colorMap[event.data.responseData.state];\n console.log(event.data.responseData.state,ncolor);\ncontext.props.data.items.push({'color':ncolor})\nif (context.props.data.items.length > context.props.data.maxBarCnt) {\n context.props.data.items.shift(); // Remove the oldest value\n};" } ] }