From e0d095cb04866d2a384ec3b8f26c9511dcfe2e20 Mon Sep 17 00:00:00 2001 From: p Date: Thu, 13 Aug 2026 14:26:56 +0800 Subject: [PATCH] tree: fix __root__ expansion returns subdirs --- wwwroot/api/workspace_tree.dspy | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wwwroot/api/workspace_tree.dspy b/wwwroot/api/workspace_tree.dspy index 8cd5f77..503400d 100644 --- a/wwwroot/api/workspace_tree.dspy +++ b/wwwroot/api/workspace_tree.dspy @@ -43,8 +43,14 @@ if not node_id: "is_leaf": False }] -# 展开节点 -scan_path = ws_dir + '/' + node_id +# 展开节点:__root__ 特殊处理,其余用相对路径 +if node_id == '__root__': + scan_path = ws_dir + id_prefix = '' +else: + scan_path = ws_dir + '/' + node_id + id_prefix = node_id + '/' + if not os.path.isdir(scan_path): return [] @@ -60,7 +66,7 @@ for name in entries: continue if os.path.isdir(full): items.append({ - "id": node_id + '/' + name, + "id": id_prefix + name, "parentid": node_id, "label": "📁 " + name, "path": full,