From 7711d6ce82f50dfdd7864dc43502c60b31552d89 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 23 Jul 2026 13:51:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20popup=20auto=5Fclose=3Dfalse,=20submit?= =?UTF-8?q?=E2=86=92refresh=20KB=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/knowledge_bases_list/create_kb.dspy | 5 ++- wwwroot/knowledge_bases_list/index.ui | 1 + wwwroot/knowledge_bases_list/new_kb_form.ui | 3 +- wwwroot/knowledge_bases_list/upload.dspy | 44 +++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 wwwroot/knowledge_bases_list/upload.dspy diff --git a/wwwroot/knowledge_bases_list/create_kb.dspy b/wwwroot/knowledge_bases_list/create_kb.dspy index 8f18909..8b70633 100644 --- a/wwwroot/knowledge_bases_list/create_kb.dspy +++ b/wwwroot/knowledge_bases_list/create_kb.dspy @@ -12,5 +12,8 @@ async with db.sqlorContext(dbname) as sor: "INSERT INTO knowledge_bases (id, name, description, org_id, embedding_engine, vdb_collection, doc_count, total_size, chunk_count, status, created_at) " "VALUES (${id}$, ${name}$, ${desc}$, ${org_id}$, 'CLIP ViT-H-14', 'rag_collection', 0, 0, 0, 'active', NOW())", {"id": kb_id, "name": name, "desc": desc, "org_id": userorgid}) - return {"status": "SUCCEEDED", "kb_id": kb_id} + return { + "widgettype": "urlwidget", + "options": {"url": entire_url('/knowledge_bases_list/index.ui')} + } return {"error": "failed"} diff --git a/wwwroot/knowledge_bases_list/index.ui b/wwwroot/knowledge_bases_list/index.ui index df18fb2..27be65b 100644 --- a/wwwroot/knowledge_bases_list/index.ui +++ b/wwwroot/knowledge_bases_list/index.ui @@ -15,6 +15,7 @@ {"widgettype": "Button", "options": {"label": "+ 新建知识库", "bgcolor": "#4a90d9", "color": "#fff"}, "binds": [ {"wid": "self", "event": "click", "actiontype": "urlwidget", "target": "Popup", + "popup_options": {"auto_close": false}, "options": {"url": "{{entire_url('/knowledge_bases_list/new_kb_form.ui')}}"}} ]} ] diff --git a/wwwroot/knowledge_bases_list/new_kb_form.ui b/wwwroot/knowledge_bases_list/new_kb_form.ui index 6b04c60..bf672be 100644 --- a/wwwroot/knowledge_bases_list/new_kb_form.ui +++ b/wwwroot/knowledge_bases_list/new_kb_form.ui @@ -20,7 +20,8 @@ "wid": "kb_form", "event": "submit", "actiontype": "urlwidget", - "target": "self", + "target": "app.rag_main_content", + "mode": "replace", "options": { "url": "{{entire_url('./create_kb.dspy')}}" } diff --git a/wwwroot/knowledge_bases_list/upload.dspy b/wwwroot/knowledge_bases_list/upload.dspy new file mode 100644 index 0000000..c447baf --- /dev/null +++ b/wwwroot/knowledge_bases_list/upload.dspy @@ -0,0 +1,44 @@ +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, AVI", "cfontsize": 12, "color": "#999"}}, + {"widgettype": "Text", "options": {"text": "单个文件最大 500MB · 自动向量化入库", "cfontsize": 12, "color": "#999"}} + ] + }, + { + "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