39 lines
2.3 KiB
Plaintext
39 lines
2.3 KiB
Plaintext
ns = params_kw.copy()
|
|
kb_id = ns.get('kb_id', '')
|
|
|
|
import json
|
|
body = json.dumps({
|
|
"widgettype": "VBox",
|
|
"options": {"spacing": "16px", "padding": "0"},
|
|
"subwidgets": [
|
|
{"widgettype": "Text", "options": {"text": "📤 上传文件", "cfontsize": 18, "fontWeight": "bold", "color": "#333"}},
|
|
{"widgettype": "Text", "options": {"text": "知识库: " + kb_id, "cfontsize": 12, "color": "#888"}},
|
|
{
|
|
"widgettype": "VBox",
|
|
"options": {"id": "upload_zone", "width": "100%", "cheight": 10, "bgcolor": "#f8f9fa", "padding": "24px", "css": "card", "border": "2px dashed #3b82f6", "alignItems": "center", "justifyContent": "center"},
|
|
"subwidgets": [
|
|
{"widgettype": "Text", "options": {"text": "📂", "cfontsize": 40}},
|
|
{"widgettype": "Text", "options": {"text": "拖拽文件到此处上传", "cfontsize": 15, "color": "#888"}},
|
|
{"widgettype": "Text", "options": {"text": "支持: TXT,PDF,JPG,PNG,MP3,WAV,MP4", "cfontsize": 12, "color": "#aaa"}},
|
|
{
|
|
"widgettype": "Button",
|
|
"options": {"label": "选择文件上传", "bgcolor": "#3b82f6", "color": "#fff", "marginTop": "12px"},
|
|
"binds": [{
|
|
"wid": "self",
|
|
"event": "click",
|
|
"actiontype": "script",
|
|
"script": "var i=document.createElement('input');i.type='file';i.onchange=function(){for(var j=0;j<i.files.length;j++){var f=i.files[j];var x=new XMLHttpRequest();x.open('POST','/api/doc/upload?kb_id=" + kb_id + "&file_name='+encodeURIComponent(f.name));x.send(f)}};i.click()"
|
|
}]
|
|
},
|
|
{"widgettype": "Text", "options": {"text": "", "id": "upload_status", "cfontsize": 12, "color": "#50b86c", "marginTop": "8px"}}
|
|
]
|
|
},
|
|
{
|
|
"widgettype": "Button",
|
|
"options": {"label": "← 返回文件管理", "bgcolor": "#e0e0e0", "color": "#666"},
|
|
"binds": [{"wid": "self", "event": "click", "actiontype": "urlwidget", "target": "app.rag_main_content", "mode": "replace", "options": {"url": entire_url('/knowledge_bases_list/index.ui')}}]
|
|
}
|
|
]
|
|
})
|
|
return json.loads(body)
|