feat: 顶部待办角标 + 1分钟定时刷新 + 我的待办入口(点击做事)

This commit is contained in:
yumoqing 2026-08-24 12:54:08 +08:00
parent 25e9900193
commit 00506cef3f
2 changed files with 32 additions and 0 deletions

View File

@ -53,6 +53,25 @@
"url": "{{entire_url('i18n/language.ui')}}"
}
},
{
"widgettype": "Button",
"id": "todo_badge",
"options": {
"label": "",
"css": "text",
"color": "#fbbf24",
"cfontsize": 0.85
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "if(window.openMyTodos){openMyTodos();}"
}
]
},
{
"widgettype": "urlwidget",
"options": {
@ -377,6 +396,14 @@
}
}
]
},
{
"widgettype": "Html",
"options": {
"html": "<script>window.refreshTodo=function(){fetch('/pipeline-sdlc/api/project_human_count.dspy').then(function(r){return r.json()}).then(function(d){var n=(d&&d.count)||0;var b=bricks.getWidgetById&&bricks.getWidgetById('todo_badge',bricks.app);if(b&&b.text_w){b.text_w.set_text(n>0?('待办 '+n):'');}});};window.openMyTodos=function(){var pw=new bricks.PopupWindow({title:'我的待办',cwidth:70,cheight:40,auto_open:true});var vs=new bricks.VScrollPanel({css:'filler',padding:'12px',gap:'8px'});pw.content_w.add_widget(vs);fetch('/pipeline-sdlc/api/my_todos.dspy').then(function(r){return r.json()}).then(function(d){var todos=(d&&d.todos)||[];if(todos.length===0){vs.add_widget(new bricks.Text({text:'暂无待办',cfontsize:0.9,color:'#94a3b8'}));return;}todos.forEach(function(t){var src=t.source||'';var title=src==='question'?(t.question||''):(t.title||'');var label=src==='question'?'问题':(t.task_type==='bug_acceptance'?'Bug验收':'人类任务');var card=new bricks.VBox({bgcolor:'#fff',border:'1px solid #e2e8f0',borderRadius:'8px',padding:'10px 14px',gap:'6px',marginBottom:'4px'});var hdr=new bricks.HBox({alignItems:'center',gap:'8px'});hdr.add_widget(new bricks.Text({text:label,cfontsize:0.7,color:'#ffffff',padding:'1px 8px',style:{background:src==='question'?'#8b5cf6':(t.task_type==='bug_acceptance'?'#f0a040':'#2563eb'),borderRadius:'10px',fontWeight:'bold'}}));hdr.add_widget(new bricks.Text({text:title,cfontsize:0.9,color:'#1e293b',fontWeight:'bold'}));card.add_widget(hdr);if(t.project_name)card.add_widget(new bricks.Text({text:'项目:'+t.project_name,cfontsize:0.7,color:'#94a3b8'}));if(src==='human_task'&&t.task_type==='bug_acceptance'){var hb=new bricks.HBox({gap:'6px'});var okb=new bricks.Button({label:'通过',css:'small'});okb.set_click(function(){fetch('/pipeline-sdlc/api/bug_accept.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'bug_id='+encodeURIComponent(t.bug_id)+'&accept=1'}).then(function(r){return r.json()}).then(function(d){alert(d.success?'验收通过Bug已关闭':(d.error||'失败'));if(d.success){pw.destroy();refreshTodo();}});});var nob=new bricks.Button({label:'不通过',css:'small'});nob.set_click(function(){fetch('/pipeline-sdlc/api/bug_accept.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'bug_id='+encodeURIComponent(t.bug_id)+'&accept=0'}).then(function(r){return r.json()}).then(function(d){alert(d.success?'验收不通过Bug已重新打开':(d.error||'失败'));if(d.success){pw.destroy();refreshTodo();}});});hb.add_widget(okb);hb.add_widget(nob);card.add_widget(hb);}else if(src==='human_task'){var db=new bricks.Button({label:'处理',css:'small'});db.set_click(function(){var v=prompt('请输入处理结果:','');if(v===null)return;fetch('/pipeline-sdlc/api/human_task_complete.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'human_task_id='+encodeURIComponent(t.id)+'&result_data='+encodeURIComponent(JSON.stringify({content:v}))}).then(function(r){return r.json()}).then(function(d){alert(d.success?'已提交等待QC检查':(d.error||'失败'));if(d.success){pw.destroy();refreshTodo();}});});card.add_widget(db);}vs.add_widget(card);});});};setInterval(function(){refreshTodo();},60000);setTimeout(function(){refreshTodo();},800);</script>",
"height": "0",
"width": "0"
}
}
]
}

View File

@ -8,6 +8,11 @@
"width":"75%"
},
"items":[
{
"name":"my_todos",
"label":"我的待办",
"script":"if(window.openMyTodos){openMyTodos();}"
},
{
"name":"aboutme",
"label":"我",