fix: file list action buttons spacing 6px->14px; drop analysis button; legacy /api/doc/upload now saves via FileStorage (flat files/ layout caused 404)
This commit is contained in:
parent
267fd276c5
commit
371afae84a
12
rag/init.py
12
rag/init.py
@ -321,15 +321,9 @@ async def doc_upload_handler(request, params_kw, *args, **kwargs):
|
||||
return json.dumps({"error": "storage_quota_exceeded",
|
||||
"message": "存储配额超限:机构已用 " + _fmt_bytes(used) + ",限额 " + _fmt_bytes(quota_limit) + ",本文件 " + _fmt_bytes(file_size)}, ensure_ascii=False)
|
||||
|
||||
# Save file
|
||||
# Save file via FileStorage (layered dir layout, returns web path e.g. /191/193/197/97/xxx.txt)
|
||||
doc_id = uuid.uuid4().hex[:16]
|
||||
ext = os.path.splitext(file_name)[1] or ".bin"
|
||||
saved_name = f"{doc_id}{ext}"
|
||||
files_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "files")
|
||||
os.makedirs(files_dir, exist_ok=True)
|
||||
file_path = os.path.join(files_dir, saved_name)
|
||||
with open(file_path, "wb") as f:
|
||||
f.write(file_data)
|
||||
web_path = await env.save_file(file_data, file_name)
|
||||
|
||||
file_type = _detect_file_type(file_name, "application/octet-stream")
|
||||
|
||||
@ -339,7 +333,7 @@ async def doc_upload_handler(request, params_kw, *args, **kwargs):
|
||||
"INSERT INTO documents (id, kb_id, file_name, file_type, file_size, file_path, mime_type, status, org_id, created_at, updated_at) "
|
||||
"VALUES (${id}$, ${kb_id}$, ${file_name}$, ${file_type}$, ${file_size}$, ${file_path}$, ${mime_type}$, 'pending', ${org_id}$, NOW(), NOW())",
|
||||
{"id": doc_id, "kb_id": kb_id, "file_name": file_name, "file_type": file_type,
|
||||
"file_size": file_size, "file_path": "/idfile/files/" + saved_name,
|
||||
"file_size": file_size, "file_path": web_path,
|
||||
"mime_type": "application/octet-stream", "org_id": userorgid})
|
||||
|
||||
# Update KB stats
|
||||
|
||||
@ -50,10 +50,7 @@ header = {
|
||||
"subwidgets": [
|
||||
{"widgettype": "Text", "options": {"text": "📄 " + folder_label, "cfontsize": 14, "fontWeight": "bold", "color": "#333"}},
|
||||
{"widgettype": "Text", "options": {"text": "(" + str(len(rows)) + " 个文件)", "cfontsize": 12, "color": "#999", "marginLeft": "8px"}},
|
||||
{"widgettype": "Text", "options": {"text": "", "css": "filler"}},
|
||||
{"widgettype": "Button", "options": {"label": "📊 分析结果", "cfontsize": 12, "bgcolor": "#ede7f6", "color": "#4527a0", "padding": "4px 12px", "borderRadius": "14px", "marginLeft": "8px"},
|
||||
"binds": [{"wid": "self", "event": "click", "actiontype": "urlwidget", "target": "file_list_panel", "mode": "replace",
|
||||
"options": {"url": "./analysis.dspy?kb_id=" + kb_id}}]}
|
||||
{"widgettype": "Text", "options": {"text": "", "css": "filler"}}
|
||||
]
|
||||
}
|
||||
|
||||
@ -89,7 +86,7 @@ else:
|
||||
{"widgettype": "Text", "options": {"text": st, "cfontsize": 11, "color": sc, "cwidth": 6, "halign": "center"}},
|
||||
{"widgettype": "Text", "options": {"text": f["created_at"], "cfontsize": 11, "color": "#999", "cwidth": 13, "halign": "center"}},
|
||||
{
|
||||
"widgettype": "HBox", "options": {"spacing": "6px"},
|
||||
"widgettype": "HBox", "options": {"spacing": "14px"},
|
||||
"subwidgets": [
|
||||
{"widgettype": "Text", "options": {"text": "👁", "cfontsize": 14, "css": "clickable", "color": "#4a90d9", "title": "查看"},
|
||||
"binds": [{"wid": "self", "event": "click", "actiontype": "script", "target": "self",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user