From d5fc14ae1ceb63d7d57c5528b598d24373b1f241 Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 15 Aug 2026 01:40:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20workspace=5Ftree=20=E5=8F=B6=E5=AD=90?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E2=80=94=E2=80=94=E6=97=A0=E5=AD=90=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=9A=84=E7=9B=AE=E5=BD=95=E6=A0=87=20is=5Fleaf=3Dtru?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原把所有目录硬编码 is_leaf:false,导致无子目录的目录(叶子)也被当成可展开的非叶子。 改为扫描子目录判断 has_subdir,is_leaf = not has_subdir。 --- wwwroot/api/workspace_tree.dspy | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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