From 75fe529eff1413a0fc04c2413af384f890dec2da Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 23 Jul 2026 15:03:05 +0800 Subject: [PATCH] fix: upload.dspy return statement --- wwwroot/knowledge_bases_list/upload.dspy | 30 +++++++----------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/wwwroot/knowledge_bases_list/upload.dspy b/wwwroot/knowledge_bases_list/upload.dspy index b52e885..fac70ce 100644 --- a/wwwroot/knowledge_bases_list/upload.dspy +++ b/wwwroot/knowledge_bases_list/upload.dspy @@ -1,7 +1,7 @@ ns = params_kw.copy() kb_id = ns.get('kb_id', '') -result = { +body = """{ "widgettype": "VBox", "options": {"width": "100%", "padding": "0", "spacing": "16px"}, "subwidgets": [ @@ -9,32 +9,18 @@ result = { { "widgettype": "VBox", "options": { - "id": "drop_zone", - "width": "100%", - "cheight": 12, - "bgcolor": "#f8f9fa", - "padding": "32px", - "css": "card", + "id": "drop_zone", "width": "100%", "cheight": 12, + "bgcolor": "#f8f9fa", "padding": "32px", "css": "card", "border": "2px dashed #3b82f6", - "alignItems": "center", - "justifyContent": "center" + "alignItems": "center", "justifyContent": "center" }, "subwidgets": [ {"widgettype": "Text", "options": {"text": "📂", "cfontsize": 40}}, {"widgettype": "Text", "options": {"text": "点击选择文件上传", "cfontsize": 16, "color": "#555"}}, - {"widgettype": "Text", "options": {"text": "支持: TXT, PDF, JPG, PNG, MP3, WAV, MP4", "cfontsize": 12, "color": "#999"}}, - {"widgettype": "Button", "options": {"label": "选择文件", "bgcolor": "#3b82f6", "color": "#fff", "padding": "8px 20px", "marginTop": "12px"}, - "binds": [{"wid": "self", "event": "click", "actiontype": "script", - "script": "var inp=document.createElement('input');inp.type='file';inp.onchange=function(e){var f=e.target.files[0];if(!f)return;var st=document.getElementById('status_text');if(st)st.innerText='上传中: '+f.name;var r=new XMLHttpRequest();r.open('POST','/api/doc/upload?kb_id=" + kb_id + "&file_name='+encodeURIComponent(f.name));r.onload=function(){if(st)st.innerText=r.status===200?'上传成功: '+f.name:'上传失败: HTTP '+r.status;location.reload()};r.send(f)};inp.click()"}]} - ] - }, - { - "widgettype": "VBox", - "options": {"id": "upload_status", "width": "100%", "padding": "12px", "bgcolor": "#f0fdf4", "border": "1px solid #86efac"}, - "subwidgets": [ - {"widgettype": "Text", "options": {"text": "⏳ 选择文件开始上传", "cfontsize": 13, "color": "#666", "id": "status_text"}} + {"widgettype": "Text", "options": {"text": "支持: TXT, PDF, JPG, PNG, MP3, WAV, MP4", "cfontsize": 12, "color": "#999"}} ] } ] -} -result +}""" +import json +return json.loads(body)