diff --git a/wwwroot/api/workspace_tree.dspy b/wwwroot/api/workspace_tree.dspy index 7fc8dcd..601ad37 100644 --- a/wwwroot/api/workspace_tree.dspy +++ b/wwwroot/api/workspace_tree.dspy @@ -50,12 +50,21 @@ for name in entries: if name.startswith('.') or name == '__pycache__': continue if os.path.isdir(full): + # 叶子判定:目录下是否还有子目录(排除隐藏目录)。无子目录 → 叶子(不可展开) + has_subdir = False + try: + for sub in os.listdir(full): + if not sub.startswith('.') and os.path.isdir(os.path.join(full, sub)): + has_subdir = True + break + except Exception: + pass items.append({ "id": id_prefix + name, "parentid": node_id, "label": "📁 " + name, "path": full, - "is_leaf": False + "is_leaf": not has_subdir }) return items