tree: fix __root__ expansion returns subdirs

This commit is contained in:
p 2026-08-13 14:26:56 +08:00
parent 751c953ad3
commit e0d095cb04

View File

@ -43,8 +43,14 @@ if not node_id:
"is_leaf": False "is_leaf": False
}] }]
# 展开节点 # 展开节点:__root__ 特殊处理,其余用相对路径
scan_path = ws_dir + '/' + node_id 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): if not os.path.isdir(scan_path):
return [] return []
@ -60,7 +66,7 @@ for name in entries:
continue continue
if os.path.isdir(full): if os.path.isdir(full):
items.append({ items.append({
"id": node_id + '/' + name, "id": id_prefix + name,
"parentid": node_id, "parentid": node_id,
"label": "📁 " + name, "label": "📁 " + name,
"path": full, "path": full,