Browse Source

树结构文件1

yuchengwei 1 month ago
parent
commit
791caf7e34
1 changed files with 12 additions and 1 deletions
  1. 12 1
      agent/tree_utils.py

+ 12 - 1
agent/tree_utils.py

@@ -7,6 +7,9 @@ class TreeNodeDTO:
     id: int
     name: str
     pId: int
+    icon: str = ""
+    iconOpen: str = ""
+    iconClose: str = ""
 
 @dataclass
 class TreeDTO:
@@ -64,12 +67,20 @@ def add_tree(nodes: List[TreeNodeDTO], tree_obj: Dict, path_id_map: Dict[str, in
     
     # 判断是否为叶子节点
     is_leaf = not tree_obj.get('sNode', [])
+
+    # 设置图标
+    icon = "/images/node.png" if is_leaf else "/images/icon.png"
+    icon_open = "" if is_leaf else "/images/iconOpen.png"
+    icon_close = "" if is_leaf else "/images/iconClose.png"
     
     # 创建树节点
     node = TreeNodeDTO(
         id=current_id,
         name=tree_obj['name'],
-        pId=parent_id
+        pId=parent_id,
+        icon=icon,
+        iconOpen=icon_open,
+        iconClose=icon_close
     )
     nodes.append(node)