import os import json # 递归获取目录文件树 def get_file_tree(path): file_tree = [] for item in os.listdir(path): full_path = os.path.join(path, item) if os.path.isdir(full_path): file_tree.append({"name": item, "type": "directory", "children": get_file_tree(full_path)}) else: file_tree.append({"name": item, "type": "file"}) return file_tree def load_config(path): config_file = os.path.join(path, '.config') if not os.path.exists(config_file): return None try: with open(config_file, 'r') as f: config = json.load(f) return config except Exception as e: print(e) return None