From b322c4533ef71902388456de6c982afebbb881a9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 23 Jul 2026 18:16:50 +0800 Subject: [PATCH] fix: replace Droppable with script-based file upload button --- wwwroot/knowledge_bases_list/detail.ui | 31 +++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/wwwroot/knowledge_bases_list/detail.ui b/wwwroot/knowledge_bases_list/detail.ui index 68a3c51..2afde35 100644 --- a/wwwroot/knowledge_bases_list/detail.ui +++ b/wwwroot/knowledge_bases_list/detail.ui @@ -53,37 +53,36 @@ }, { "widgettype": "VBox", - "options": {"id": "detail_content", "css": "filler", "padding": "0", "spacing": 0}, + "options": {"id": "detail_content", "css": "filler", "padding": "16px", "spacing": "12px"}, "subwidgets": [ { - "widgettype": "Droppable", + "widgettype": "VBox", "options": { "width": "100%", "cheight": 6, "bgcolor": "#f8f9fa", + "padding": "16px", + "css": "card", "border": "2px dashed #3b82f6", "alignItems": "center", "justifyContent": "center" }, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📂 拖拽文件到此处自动上传", "cfontsize": 15, "color": "#888"}}, - {"widgettype": "Text", "options": {"text": "支持 TXT/PDF/JPG/PNG/MP3/WAV/MP4", "cfontsize": 12, "color": "#aaa"}} - ], - "binds": [ + {"widgettype": "Text", "options": {"text": "📂 点击或拖拽文件到此处上传", "cfontsize": 15, "color": "#888"}}, + {"widgettype": "Text", "options": {"text": "支持 TXT/PDF/JPG/PNG/MP3/WAV/MP4", "cfontsize": 12, "color": "#aaa"}}, { - "wid": "self", - "event": "drop", - "actiontype": "urlwidget", - "target": "app.rag_main_content", - "mode": "replace", - "options": {"url": "{{entire_url('./upload.dspy')}}", "params": {"kb_id": "{{params_kw.kb_id}}"}} + "widgettype": "Button", + "options": {"label": "选择文件", "bgcolor": "#3b82f6", "color": "#fff", "marginTop": "8px"}, + "binds": [{ + "wid": "self", + "event": "click", + "actiontype": "script", + "script": "var inp=document.createElement('input');inp.type='file';inp.multiple=true;inp.onchange=function(){var fd=new FormData();for(var f of inp.files){fd.append('file',f)};var xhr=new XMLHttpRequest();xhr.open('POST','/api/doc/upload?kb_id={{params_kw.kb_id}}&file_name='+encodeURIComponent(inp.files[0].name));xhr.onload=function(){var d=JSON.parse(xhr.responseText);if(d.status=='SUCCEEDED'){location.reload()}};xhr.send(inp.files[0])};inp.click()" + }] } ] }, - { - "widgettype": "Text", - "options": {"text": "暂无文件,拖拽文件到上方区域上传", "cfontsize": 13, "color": "#aaa", "padding": "16px", "halign": "center"} - } + {"widgettype": "Text", "options": {"text": "暂无文件", "cfontsize": 13, "color": "#aaa", "halign": "center"}} ] } ]