update bar

This commit is contained in:
murmur 2024-06-30 17:29:27 +08:00
parent a9aba9ac7e
commit 2539869100
2 changed files with 14 additions and 27 deletions

View File

@ -1,10 +1,11 @@
//低代码框架 amis //低代码框架 amis
import win.ui; import win.ui;
/*DSG{{*/ /*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( winform.add(
bk={cls="bk";left=0;top=-1;right=967;bottom=30;bgcolor=10789024;dl=1;dr=1;dt=1;z=1}; 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} 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(){ getStatus = function(){
var str = /** var seed = string.random("Success","Fault","PowerDown")
// API 返回数据 return {state=seed};
{
"id": 1,
"state": "success",
"color": "#00FF00"
}
**/
return web.json.parse(str);
;
} }

View File

@ -182,10 +182,10 @@
"data": { "data": {
"maxBarCnt":"60", "maxBarCnt":"60",
"items": [ "items": [
{"color": "#FF0000"}, {"color": "#808080"},
{"color": "#00FF00"}, {"color": "#808080"},
{"color": "#0000FF"}, {"color": "#808080"},
{"color": "#FFFF00"}, {"color": "#808080"},
] ]
}, },
"body": [ "body": [
@ -194,11 +194,11 @@
"name": "items", "name": "items",
"items": { "items": {
"type": "tpl", "type": "tpl",
"tpl": "<div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color}; box-shadow: 0 0 5px ${color}, 0 0 10px ${color} inset'></div>", "tpl": "<div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color}; box-shadow: 0 0 5px ${color}, 0 0 10px ${color} inset' title='${state}'></div><br><div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color}; box-shadow: 0 0 5px ${color}, 0 0 10px ${color} inset' title='${state}'></div>",
"style": { "style": {
"display": "inline-block", "display": "inline-block",
"marginRight": "10px", "marginRight": "5px",
"marginBottom": "10px" "marginBottom": "5px"
} }
} }
} }
@ -208,7 +208,7 @@
"actions": [ "actions": [
{ {
"actionType": "custom", "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};"
} }
] ]
} }