From eb6674f884dffb7277a2b3ca7767ad233cab473d Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 31 Jul 2026 12:00:23 +0800 Subject: [PATCH] refactor(cockpit): replace Form with UiText widget, file chip UI --- wwwroot/sd_cockpit/index.ui | 129 +++++++++--------------------------- 1 file changed, 32 insertions(+), 97 deletions(-) diff --git a/wwwroot/sd_cockpit/index.ui b/wwwroot/sd_cockpit/index.ui index 5032c24..5368708 100644 --- a/wwwroot/sd_cockpit/index.ui +++ b/wwwroot/sd_cockpit/index.ui @@ -16,37 +16,16 @@ "gap": "12px" }, "subwidgets": [ - { - "widgettype": "Title2", - "options": { "text": "开发产线驾驶舱" } - }, - { - "widgettype": "Text", - "options": { - "text": "AI驱动的对话式开发", - "cfontsize": 0.9, - "color": "#94a3b8" - } - }, - { - "widgettype": "Filler" - }, + { "widgettype": "Title2", "options": { "text": "开发产线驾驶舱" } }, + { "widgettype": "Text", "options": { "text": "AI驱动的对话式开发", "cfontsize": 0.9, "color": "#94a3b8" } }, + { "widgettype": "Filler" }, { "widgettype": "Button", - "options": { - "name": "refresh_btn", - "label": "刷新", - "css": "small" - }, - "binds": [ - { - "wid": "self", - "event": "click", - "actiontype": "script", - "target": "self", - "script": "var c=bricks.getWidgetById('cockpit_chat');if(c)c.render({});var s=bricks.getWidgetById('cockpit_stats_row');if(s)s.render({});" - } - ] + "options": { "name": "refresh", "label": "刷新", "css": "small" }, + "binds": [{ + "wid": "self", "event": "click", "actiontype": "script", "target": "self", + "script": "var c=bricks.getWidgetById('chat_scroll');if(c)c.render({});var s=bricks.getWidgetById('stats_row');if(s)s.render({});" + }] } ] }, @@ -61,7 +40,7 @@ "subwidgets": [ { "widgettype": "urlwidget", - "id": "cockpit_stats_row", + "id": "stats_row", "options": { "url": "{{entire_url('/pipeline-sdlc/api/cockpit_stats.dspy')}}", "method": "GET" @@ -81,7 +60,7 @@ "subwidgets": [ { "widgettype": "VScrollPanel", - "id": "cockpit_chat", + "id": "chat_scroll", "options": { "css": "filler", "width": "100%", @@ -97,30 +76,8 @@ "widgettype": "VBox", "options": { "alignItems": "center", "padding": "40px 0", "gap": "12px" }, "subwidgets": [ - { - "widgettype": "Text", - "options": { - "text": "🤖", - "cfontsize": 2.5, - "color": "#94a3b8" - } - }, - { - "widgettype": "Text", - "options": { - "text": "选择一个迭代后,在下方输入你的需求。", - "cfontsize": 1, - "color": "#64748b" - } - }, - { - "widgettype": "Text", - "options": { - "text": "Agent 将自动分析需求、生成设计方案、驱动开发产线。", - "cfontsize": 0.85, - "color": "#94a3b8" - } - } + { "widgettype": "Text", "options": { "text": "选择一个迭代后,在下方输入你的需求。", "cfontsize": 1, "color": "#64748b" } }, + { "widgettype": "Text", "options": { "text": "Agent 将自动分析需求、生成设计、驱动产线执行。", "cfontsize": 0.85, "color": "#94a3b8" } } ] } ] @@ -133,49 +90,34 @@ "border": "1px solid #e2e8f0", "borderTop": "none", "borderRadius": "0 0 8px 8px", - "padding": "12px 16px 12px 16px", - "gap": "8px" + "padding": "10px 14px 10px 14px", + "gap": "6px" }, "subwidgets": [ { "widgettype": "HBox", - "id": "file_list_area", + "id": "file_list", "options": { "width": "100%", "wrap": "wrap", - "gap": "6px", + "gap": "4px", "minHeight": "0" }, "subwidgets": [] }, { - "widgettype": "Form", - "id": "chat_form", + "widgettype": "VBox", + "id": "uitext_wrapper", "options": { - "name": "chat_form", - "submit_url": "{{entire_url('/pipeline-sdlc/api/cockpit_chat.dspy')}}", - "fields": [ - { "name": "message_text", "uitype": "textarea", "placeholder": "输入需求或回复 Agent...", "rows": 3 }, - { "name": "iteration_id", "uitype": "hide", "value": "" }, - { "name": "task_id", "uitype": "hide", "value": "" }, - { "name": "action", "uitype": "hide", "value": "send_message" }, - { "name": "file_paths", "uitype": "hide", "value": "[]" } - ] + "width": "100%" }, "binds": [ { "wid": "self", - "event": "beforesubmit", + "event": "render", "actiontype": "script", "target": "self", - "script": "var iter=bricks.getWidgetById('current_iteration_id');if(!iter||!iter.options.value){bricks.show_error({title:'提示',message:'请先选择迭代'});return false;}var msg=this.getValue('message_text');if(!msg||!msg.trim()){bricks.show_error({title:'提示',message:'请输入内容'});return false;}var files=[];var fa=document.getElementById('cockpit_file_list');if(fa){var kids=fa.children;for(var i=0;i×';fa.appendChild(chip);}};inp.click();" + "wid": "self", "event": "click", "actiontype": "script", "target": "self", + "script": "var inp=document.createElement('input');inp.type='file';inp.multiple=true;inp.onchange=function(){var list=document.getElementById('cockpit_file_bag');if(!list){list=document.createElement('div');list.id='cockpit_file_bag';list.style.cssText='display:flex;flex-wrap:wrap;gap:4px';var fl=bricks.getWidgetById('file_list');if(fl)fl.dom_element.appendChild(list);}for(var i=0;i×';list.appendChild(chip);}};inp.click();" } ] }, - { - "widgettype": "Filler" - }, + { "widgettype": "Filler" }, { "widgettype": "Button", - "options": { - "name": "send_btn", - "label": "发送", - "type": "submit", - "css": "primary" - } + "options": { "name": "send_btn", "label": "发送", "css": "primary" }, + "binds": [ + { + "wid": "self", "event": "click", "actiontype": "script", "target": "self", + "script": "var ut=document.getElementsByName('cockpit_input')[0];var msg=ut?ut.value.trim():'';if(!msg){bricks.show_error({title:'提示',message:'请输入内容'});return;}var iter=bricks.getWidgetById('current_iteration_id');var iid=iter?iter.options.value:'';if(!iid){bricks.show_error({title:'提示',message:'请先选择迭代'});return;}var files=[];var bag=document.getElementById('cockpit_file_bag');if(bag){var chips=bag.querySelectorAll('[data-fn]');for(var j=0;j