fix: upload.dspy return statement

This commit is contained in:
yumoqing 2026-07-23 15:03:05 +08:00
parent 96c8661af3
commit 75fe529eff

View File

@ -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)