From 44b2de96f3973b4404bb305d517be394633ab11a Mon Sep 17 00:00:00 2001 From: ymq Date: Tue, 18 Aug 2026 13:46:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20task=5Fio=20=E7=BB=88=E6=80=81=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=B8=8D=E5=88=B7=E6=96=B0=EF=BC=88params.state=20?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=B8=85=E9=99=A4/=E8=AE=BE=E7=BD=AE=20timer?= =?UTF-8?q?=EF=BC=89+=20=E7=8A=B6=E6=80=81=E5=BE=BD=E7=AB=A0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/task_io.dspy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wwwroot/api/task_io.dspy b/wwwroot/api/task_io.dspy index bfd7d92..4e15aaa 100644 --- a/wwwroot/api/task_io.dspy +++ b/wwwroot/api/task_io.dspy @@ -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, }], }