fix: size format MB/GB, add new_kb_form with button binds
This commit is contained in:
parent
60d48a2fc2
commit
186e3659fb
9
init.py
9
init.py
@ -29,7 +29,14 @@ async def kb_list_handler(request, params_kw, *args, **kwargs):
|
|||||||
doc_recs = await sor.R("documents", {"kb_id": r.id})
|
doc_recs = await sor.R("documents", {"kb_id": r.id})
|
||||||
doc_count = len(doc_recs)
|
doc_count = len(doc_recs)
|
||||||
total_size = r.total_size or 0
|
total_size = r.total_size or 0
|
||||||
size_str = f"{total_size/1024:.0f}KB" if total_size else "0B"
|
if total_size >= 1073741824:
|
||||||
|
size_str = f"{total_size/1073741824:.1f}GB"
|
||||||
|
elif total_size >= 1048576:
|
||||||
|
size_str = f"{total_size/1048576:.0f}MB"
|
||||||
|
elif total_size >= 1024:
|
||||||
|
size_str = f"{total_size/1024:.0f}KB"
|
||||||
|
else:
|
||||||
|
size_str = f"{total_size}B"
|
||||||
engine = r.embedding_engine or "CLIP"
|
engine = r.embedding_engine or "CLIP"
|
||||||
card = {"widgettype":"VBox","options":{"cwidth":16,"cheight":12,"bgcolor":"#f0f7ff","padding":"16px","css":"card clickable","border":"1px solid #d0e4f7"},"subwidgets":[
|
card = {"widgettype":"VBox","options":{"cwidth":16,"cheight":12,"bgcolor":"#f0f7ff","padding":"16px","css":"card clickable","border":"1px solid #d0e4f7"},"subwidgets":[
|
||||||
{"widgettype":"Text","options":{"text":"📚 " + str(r.name),"cfontsize":16,"fontWeight":"bold"}},
|
{"widgettype":"Text","options":{"text":"📚 " + str(r.name),"cfontsize":16,"fontWeight":"bold"}},
|
||||||
|
|||||||
@ -15,7 +15,10 @@
|
|||||||
{"widgettype": "Text", "options": {"text": "知识库", "cfontsize": 22, "fontWeight": "bold", "color": "#333"}},
|
{"widgettype": "Text", "options": {"text": "知识库", "cfontsize": 22, "fontWeight": "bold", "color": "#333"}},
|
||||||
{"widgettype": "Text", "options": {"text": "点击知识库进入文档管理,支持多级目录和拖拽上传", "cfontsize": 14, "color": "#888"}}
|
{"widgettype": "Text", "options": {"text": "点击知识库进入文档管理,支持多级目录和拖拽上传", "cfontsize": 14, "color": "#888"}}
|
||||||
]},
|
]},
|
||||||
{"widgettype": "Button", "options": {"label": "+ 新建知识库", "bgcolor": "#4a90d9", "color": "#fff"}}
|
{"widgettype": "Button", "options": {"label": "+ 新建知识库", "bgcolor": "#4a90d9", "color": "#fff"}, "binds": [
|
||||||
|
{"wid": "self", "event": "tap", "actiontype": "urlwidget", "target": "app.rag_main_content", "mode": "replace",
|
||||||
|
"options": {"url": "{{entire_url('/knowledge_bases_list/new_kb_form.ui')}}"}}
|
||||||
|
]}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
17
wwwroot/knowledge_bases_list/new_kb_form.ui
Normal file
17
wwwroot/knowledge_bases_list/new_kb_form.ui
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options": {"spacing": "12px", "padding": "16px"},
|
||||||
|
"subwidgets": [
|
||||||
|
{"widgettype": "Text", "options": {"text": "新建知识库", "cfontsize": 18, "fontWeight": "bold"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "", "cheight": 0.5}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "名称"}},
|
||||||
|
{"widgettype": "Input", "options": {"id": "kb_name", "width": "100%"}},
|
||||||
|
{"widgettype": "Text", "options": {"text": "描述"}},
|
||||||
|
{"widgettype": "Input", "options": {"id": "kb_desc", "width": "100%"}},
|
||||||
|
{"widgettype": "Button", "options": {"label": "创建", "bgcolor": "#4a90d9", "color": "#fff"}},
|
||||||
|
{"widgettype": "Button", "options": {"label": "取消", "bgcolor": "#e0e0e0", "color": "#666"}, "binds": [
|
||||||
|
{"wid": "self", "event": "tap", "actiontype": "urlwidget", "target": "app.rag_main_content", "mode": "replace",
|
||||||
|
"options": {"url": "{{entire_url('/knowledge_bases_list/index.ui')}}"}}
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user