fix: read kb_id from URL params in JS, not jinja2 template
This commit is contained in:
parent
8d4e707c7c
commit
77b8121ec9
@ -77,7 +77,7 @@
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"script": "var i=document.createElement('input');i.type='file';i.multiple=true;i.onchange=function(){var kb='{{params_kw.kb_id}}';var fd=window._rag_current_folder||'';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+'&file_name='+encodeURIComponent(f.name)+'&folder='+fd);x.onload=function(){if(x.status===200){var st=document.getElementById('upload_status');if(st)st.innerText='上传成功: '+f.name;else location.reload()}};x.send(f)}};i.click()"
|
||||
"script": "var i=document.createElement('input');i.type='file';i.multiple=true;i.onchange=function(){var u=new URL(window.location.href);var kb=u.searchParams.get('kb_id')||'';var fd=window._rag_current_folder||'';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='+encodeURIComponent(kb)+'&file_name='+encodeURIComponent(f.name)+'&folder='+encodeURIComponent(fd));x.onload=function(){if(x.status===200){var st=document.getElementById('upload_status');if(st)st.innerText='上传成功: '+f.name;else location.reload()}};x.send(f)}};i.click()"
|
||||
}]
|
||||
},
|
||||
{"widgettype": "Text", "options": {"id": "upload_status", "cfontsize": 12, "color": "#50b86c", "marginTop": "8px", "text": ""}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user