fix: replace Droppable with script-based file upload button

This commit is contained in:
yumoqing 2026-07-23 18:16:50 +08:00
parent c30e9bf09e
commit b322c4533e

View File

@ -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"}}
]
}
]