fix: test_pricing结果用subwidgets控件数组渲染
- dspy: items改为Text控件数组([{widgettype:Text, options:{text:json}}])
- ui: status_of.ok改为VScrollPanel+subwidgets引用items
- 解决之前返回纯文本字符串无法渲染为bricks控件的问题
This commit is contained in:
parent
bcdb1e02cd
commit
d22dbc57ae
@ -4,19 +4,24 @@ try:
|
|||||||
if isinstance(data, str):
|
if isinstance(data, str):
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
x = await buffered_charging(ppid, data)
|
x = await buffered_charging(ppid, data)
|
||||||
items = []
|
subwidgets = []
|
||||||
if isinstance(x, list):
|
if isinstance(x, list):
|
||||||
for r in x:
|
for r in x:
|
||||||
items.append(json.dumps(r, ensure_ascii=False))
|
subwidgets.append({
|
||||||
|
"widgettype": "Text",
|
||||||
|
"options": {"text": json.dumps(r, ensure_ascii=False), "width": "100%"}
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
items.append(json.dumps(x, ensure_ascii=False))
|
subwidgets.append({
|
||||||
result_text = '\n\n'.join(items)
|
"widgettype": "Text",
|
||||||
|
"options": {"text": json.dumps(x, ensure_ascii=False), "width": "100%"}
|
||||||
|
})
|
||||||
return {
|
return {
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
"data": {
|
"data": {
|
||||||
"ppid": ppid,
|
"ppid": ppid,
|
||||||
"data": data,
|
"data": data,
|
||||||
"items": result_text
|
"items": subwidgets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -49,11 +49,12 @@
|
|||||||
},
|
},
|
||||||
"status_of": {
|
"status_of": {
|
||||||
"ok": {
|
"ok": {
|
||||||
"widgettype": "Text",
|
"widgettype": "VScrollPanel",
|
||||||
"options":{
|
"options":{
|
||||||
"width": "100%",
|
"width": "100%",
|
||||||
"text": "${items}"
|
"height": "100%"
|
||||||
}
|
},
|
||||||
|
"subwidgets": "${items}"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user