code-server-like

This commit is contained in:
CakeCN
2025-09-15 14:15:20 +08:00
parent 306bf48754
commit ec45771376
19 changed files with 962 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
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