From 49d3d0291a2b7dfde575f8543cf5523fcb20d274 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 22 Jul 2026 18:20:56 +0800 Subject: [PATCH] feat: Tree widget for directory nav + folder_content dynamic view --- wwwroot/knowledge_bases_list/detail.ui | 136 ++++++++---------- .../knowledge_bases_list/folder_content.ui | 73 ++++++++++ 2 files changed, 130 insertions(+), 79 deletions(-) create mode 100644 wwwroot/knowledge_bases_list/folder_content.ui diff --git a/wwwroot/knowledge_bases_list/detail.ui b/wwwroot/knowledge_bases_list/detail.ui index 9dda2a3..8b9b3c1 100644 --- a/wwwroot/knowledge_bases_list/detail.ui +++ b/wwwroot/knowledge_bases_list/detail.ui @@ -12,18 +12,18 @@ "options": { "width": "100%", "bgcolor": "#f8f9fa", - "padding": "12px 16px", + "padding": "10px 16px", "alignItems": "center", "borderBottom": "1px solid #e0e0e0" }, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "← 返回知识库列表", "css": "clickable", "cfontsize": 14, "color": "#4a90d9"}, "binds": [ + {"widgettype": "Text", "options": {"text": "← 知识库列表", "css": "clickable", "cfontsize": 14, "color": "#4a90d9"}, "binds": [ {"wid": "self", "event": "click", "actiontype": "urlwidget", "target": "app.rag_main_content", "mode": "replace", "options": {"url": "{{entire_url('/knowledge_bases_list/index.ui')}}"}} ]}, - {"widgettype": "Text", "options": {"text": "/", "cfontsize": 14, "color": "#ccc"}}, + {"widgettype": "Text", "options": {"text": " / ", "cfontsize": 14, "color": "#ccc"}}, {"widgettype": "Text", "options": {"text": "📚 产品文档", "cfontsize": 16, "fontWeight": "bold", "color": "#333"}}, {"widgettype": "Text", "options": {"text": "", "css": "filler"}}, - {"widgettype": "Text", "options": {"text": "📄 12 文档 · 📁 3 目录 · 💾 256MB", "cfontsize": 12, "color": "#888"}} + {"widgettype": "Text", "options": {"text": "📄 12文档 · 📁 3目录 · 💾 256MB", "cfontsize": 12, "color": "#888"}} ] }, { @@ -37,61 +37,72 @@ { "widgettype": "VBox", "options": { - "cwidth": 14, + "cwidth": 15, "bgcolor": "#fafafa", "borderRight": "1px solid #e0e0e0", - "padding": "12px", - "spacing": "4px" + "spacing": 0 }, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📁 目录结构", "cfontsize": 13, "fontWeight": "bold", "color": "#666"}}, - {"widgettype": "Text", "options": {"text": ""}}, { "widgettype": "HBox", - "options": {"spacing": "4px", "alignItems": "center"}, + "options": { + "padding": "10px 12px", + "bgcolor": "#f0f0f0", + "borderBottom": "1px solid #e0e0e0", + "justifyContent": "space-between", + "alignItems": "center" + }, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📂", "cfontsize": 12}}, - {"widgettype": "Text", "options": {"text": "技术文档", "cfontsize": 13, "color": "#4a90d9", "css": "clickable"}} + {"widgettype": "Text", "options": {"text": "📁 目录结构", "cfontsize": 13, "fontWeight": "bold", "color": "#666"}}, + {"widgettype": "Text", "options": {"text": "+ 新建", "cfontsize": 12, "color": "#4a90d9", "css": "clickable"}} ] }, { - "widgettype": "VBox", - "options": {"padding": "0 0 0 16px", "spacing": "2px"}, - "subwidgets": [ - {"widgettype": "HBox", "options": {"spacing": "4px"}, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📄", "cfontsize": 11}}, - {"widgettype": "Text", "options": {"text": "API参考.pdf", "cfontsize": 12, "color": "#666"}} - ]}, - {"widgettype": "HBox", "options": {"spacing": "4px"}, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📄", "cfontsize": 11}}, - {"widgettype": "Text", "options": {"text": "部署指南.md", "cfontsize": 12, "color": "#666"}} - ]} + "widgettype": "Tree", + "options": { + "items": [ + { + "label": "技术文档", + "id": "folder_tech", + "icon": "📂", + "children": [ + {"label": "API参考.pdf", "id": "file_api", "icon": "📄"}, + {"label": "部署指南.md", "id": "file_deploy", "icon": "📄"}, + {"label": "接口规范", "id": "folder_api_spec", "icon": "📂", "children": [ + {"label": "REST API.md", "id": "file_rest", "icon": "📄"}, + {"label": "WebSocket.md", "id": "file_ws", "icon": "📄"} + ]} + ] + }, + { + "label": "产品介绍", + "id": "folder_product", + "icon": "📂" + }, + { + "label": "培训材料", + "id": "folder_training", + "icon": "📂" + } + ] + }, + "binds": [ + { + "wid": "self", + "event": "selected", + "actiontype": "urlwidget", + "target": "app.detail_content", + "mode": "replace", + "options": {"url": "{{entire_url('/knowledge_bases_list/folder_content.ui')}}", "params": {"folder_id": "${item.id}", "folder_label": "${item.label}"}} + } ] - }, - {"widgettype": "Text", "options": {"text": ""}}, - { - "widgettype": "HBox", - "options": {"spacing": "4px", "alignItems": "center"}, - "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📂", "cfontsize": 12}}, - {"widgettype": "Text", "options": {"text": "产品介绍", "cfontsize": 13, "color": "#4a90d9", "css": "clickable"}} - ] - }, - { - "widgettype": "HBox", - "options": {"spacing": "4px", "alignItems": "center"}, - "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📂", "cfontsize": 12}}, - {"widgettype": "Text", "options": {"text": "培训材料", "cfontsize": 13, "color": "#4a90d9", "css": "clickable"}} - ] - }, - {"widgettype": "Text", "options": {"text": ""}}, - {"widgettype": "Button", "options": {"label": "+ 新建目录", "bgcolor": "#e8e8e8", "color": "#666"}} + } ] }, { "widgettype": "VBox", "options": { + "id": "detail_content", "css": "filler", "padding": "16px", "spacing": "12px" @@ -111,49 +122,16 @@ }, "subwidgets": [ {"widgettype": "Text", "options": {"text": "📂 拖拽文件到此处上传", "cfontsize": 15, "color": "#888"}}, - {"widgettype": "Text", "options": {"text": "支持: TXT, PDF, JPG, PNG, MP3, WAV, MP4 · 最大500MB", "cfontsize": 11, "color": "#aaa"}} + {"widgettype": "Text", "options": {"text": "选中左侧目录后上传到该目录 · 支持 TXT/PDF/JPG/PNG/MP3/WAV/MP4", "cfontsize": 11, "color": "#aaa"}} ] }, { "widgettype": "Text", "options": { - "text": "📄 当前目录: 技术文档 (2个文件)", + "text": "📂 全部分文件 · 请选择左侧目录查看具体内容", "cfontsize": 13, - "color": "#888" + "color": "#aaa" } - }, - { - "widgettype": "HBox", - "options": {"width": "100%", "bgcolor": "#f8f9fa", "padding": "8px 12px", "borderBottom": "1px solid #e0e0e0"}, - "subwidgets": [ - {"widgettype": "Text", "options": {"text": "文件名", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 20}}, - {"widgettype": "Text", "options": {"text": "类型", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "大小", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "状态", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "上传时间", "cfontsize": 12, "fontWeight": "bold", "color": "#888"}} - ] - }, - { - "widgettype": "HBox", - "options": {"width": "100%", "padding": "6px 12px", "borderBottom": "1px solid #f0f0f0"}, - "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📄 API参考.pdf", "cfontsize": 13, "color": "#333", "cwidth": 20}}, - {"widgettype": "Text", "options": {"text": "PDF", "cfontsize": 12, "color": "#e6a23c", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "1.2MB", "cfontsize": 12, "color": "#888", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "✅ 已入库", "cfontsize": 12, "color": "#50b86c", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "2026-07-20", "cfontsize": 12, "color": "#888"}} - ] - }, - { - "widgettype": "HBox", - "options": {"width": "100%", "padding": "6px 12px", "borderBottom": "1px solid #f0f0f0"}, - "subwidgets": [ - {"widgettype": "Text", "options": {"text": "📄 部署指南.md", "cfontsize": 13, "color": "#333", "cwidth": 20}}, - {"widgettype": "Text", "options": {"text": "Markdown", "cfontsize": 12, "color": "#4a90d9", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "45KB", "cfontsize": 12, "color": "#888", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "✅ 已入库", "cfontsize": 12, "color": "#50b86c", "cwidth": 8}}, - {"widgettype": "Text", "options": {"text": "2026-07-21", "cfontsize": 12, "color": "#888"}} - ] } ] } diff --git a/wwwroot/knowledge_bases_list/folder_content.ui b/wwwroot/knowledge_bases_list/folder_content.ui new file mode 100644 index 0000000..ffc7d6d --- /dev/null +++ b/wwwroot/knowledge_bases_list/folder_content.ui @@ -0,0 +1,73 @@ +{ + "widgettype": "VBox", + "options": { + "width": "100%", + "spacing": "12px" + }, + "subwidgets": [ + { + "widgettype": "HBox", + "options": { + "width": "100%", + "justifyContent": "space-between", + "alignItems": "center" + }, + "subwidgets": [ + { + "widgettype": "HBox", + "options": {"spacing": "4px", "alignItems": "center"}, + "subwidgets": [ + {"widgettype": "Text", "options": {"text": "📂", "cfontsize": 16}}, + {"widgettype": "Text", "options": {"text": "{{params_kw.folder_label or '全部文件'}}", "cfontsize": 16, "fontWeight": "bold", "color": "#333"}}, + {"widgettype": "Text", "options": {"text": "({{params_kw.folder_id or 'root'}})", "cfontsize": 11, "color": "#aaa"}} + ] + }, + { + "widgettype": "HBox", + "options": {"spacing": "8px"}, + "subwidgets": [ + {"widgettype": "Button", "options": {"label": "📁 上传文件", "bgcolor": "#4a90d9", "color": "#fff"}}, + {"widgettype": "Button", "options": {"label": "📂 新建子目录", "bgcolor": "#e8e8e8", "color": "#666"}}, + {"widgettype": "Button", "options": {"label": "🗑 删除选中", "bgcolor": "#f56c6c", "color": "#fff"}} + ] + } + ] + }, + { + "widgettype": "VBox", + "options": { + "width": "100%", + "cheight": 5, + "bgcolor": "#f8f9fa", + "padding": "12px", + "css": "card", + "border": "2px dashed #d0d0d0", + "alignItems": "center", + "justifyContent": "center" + }, + "subwidgets": [ + {"widgettype": "Text", "options": {"text": "拖拽文件到此处上传到当前目录", "cfontsize": 13, "color": "#888"}} + ] + }, + { + "widgettype": "HBox", + "options": {"width": "100%", "bgcolor": "#f5f5f5", "padding": "8px 12px", "borderBottom": "1px solid #e0e0e0"}, + "subwidgets": [ + {"widgettype": "Text", "options": {"text": "文件名", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 18}}, + {"widgettype": "Text", "options": {"text": "类型", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 6}}, + {"widgettype": "Text", "options": {"text": "大小", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 6}}, + {"widgettype": "Text", "options": {"text": "状态", "cfontsize": 12, "fontWeight": "bold", "color": "#888", "cwidth": 6}}, + {"widgettype": "Text", "options": {"text": "上传时间", "cfontsize": 12, "fontWeight": "bold", "color": "#888"}} + ] + }, + { + "widgettype": "Text", + "options": { + "text": "当前目录暂无文件", + "color": "#aaa", + "cfontsize": 13, + "halign": "center" + } + } + ] +}