41 lines
2.2 KiB
Plaintext
41 lines
2.2 KiB
Plaintext
ns = params_kw.copy()
|
|
kb_id = ns.get('kb_id', '')
|
|
|
|
result = {
|
|
"widgettype": "VBox",
|
|
"options": {"width": "100%", "padding": "0", "spacing": "16px"},
|
|
"subwidgets": [
|
|
{"widgettype": "Text", "options": {"text": "📤 上传文件", "cfontsize": 20, "fontWeight": "bold", "color": "#333"}},
|
|
{
|
|
"widgettype": "VBox",
|
|
"options": {
|
|
"id": "drop_zone",
|
|
"width": "100%",
|
|
"cheight": 12,
|
|
"bgcolor": "#f8f9fa",
|
|
"padding": "32px",
|
|
"css": "card",
|
|
"border": "2px dashed #3b82f6",
|
|
"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"}}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
result
|