feat: task_io 终态任务不刷新(params.state 判断清除/设置 timer)+ 状态徽章显示
This commit is contained in:
parent
eba0f17767
commit
44b2de96f3
@ -74,7 +74,7 @@ async with DBPools().sqlorContext(dbname) as sor:
|
||||
"widgettype": "HBox",
|
||||
"options": {"gap": "12px", "width": "100%"},
|
||||
"subwidgets": [
|
||||
{"widgettype": "Text", "options": {"text": "状态: " + state, "cfontsize": 0.8, "color": sc, "halign": "left"}},
|
||||
{"widgettype": "Text", "options": {"text": state, "cfontsize": 0.75, "color": "#ffffff", "halign": "left", "padding": "1px 10px", "style": {"background": sc, "borderRadius": "12px", "fontWeight": "bold"}}},
|
||||
{"widgettype": "Text", "options": {"text": "角色: " + role, "cfontsize": 0.8, "color": "#64748b", "halign": "left"}},
|
||||
{"widgettype": "Text", "options": {"text": "更新: " + updated_at, "cfontsize": 0.75, "color": "#94a3b8", "halign": "left"}},
|
||||
{"widgettype": "Filler"},
|
||||
@ -136,9 +136,13 @@ async with DBPools().sqlorContext(dbname) as sor:
|
||||
})
|
||||
subwidgets.append(card)
|
||||
|
||||
# 5 秒刷新:on_parent 事件(add_widget 时触发)里 setInterval,重新 render_browser 刷新当前任务内容
|
||||
# 5 秒刷新:仅非终态任务刷新。终态(completed/approved/failed/rejected/cancelled)不再变化,
|
||||
# 切到终态任务时清除定时器;非终态任务设置定时器。params.state 由 binds.params 传入 script。
|
||||
refresh_script = (
|
||||
"if(!window._task_io_timer){"
|
||||
"var _term=['completed','approved','failed','rejected','cancelled'];"
|
||||
"if(_term.indexOf(params.state)>=0){"
|
||||
"if(window._task_io_timer){clearInterval(window._task_io_timer);window._task_io_timer=null;}"
|
||||
"}else if(!window._task_io_timer){"
|
||||
"window._task_io_timer=setInterval(function(){"
|
||||
"var rb=bricks.getWidgetById('task_rb',bricks.app);"
|
||||
"if(rb&&rb.current_id){var cid=rb.current_id;rb.current_id=undefined;rb.render_browser(cid);}"
|
||||
@ -154,6 +158,7 @@ resp = {
|
||||
"event": "on_parent",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"params": {"state": state},
|
||||
"script": refresh_script,
|
||||
}],
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user