From e9c9ec703b13e41c29024ee2fb3d7395ca595b84 Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Tue, 8 Jul 2025 12:11:55 +0800 Subject: [PATCH 1/2] Optimize the analysis of get plugins --- backend/plugin/tools.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/plugin/tools.py b/backend/plugin/tools.py index 8c213d4a..a9c922e1 100644 --- a/backend/plugin/tools.py +++ b/backend/plugin/tools.py @@ -45,15 +45,15 @@ def get_plugins() -> list[str]: plugin_packages = [] # 遍历插件目录 - for item in os.listdir(PLUGIN_DIR): - if item.endswith('.py') or item.endswith('backup') or item == '__pycache__': + for d in os.listdir(PLUGIN_DIR): + if not os.path.isdir(os.path.join(PLUGIN_DIR, d)) and d == '__pycache__': continue - item_path = os.path.join(PLUGIN_DIR, item) + item_path = os.path.join(PLUGIN_DIR, d) # 检查是否为目录且包含 __init__.py 文件 if os.path.isdir(item_path) and '__init__.py' in os.listdir(item_path): - plugin_packages.append(item) + plugin_packages.append(d) return plugin_packages From 1d3b6bd72bad45bfea91ca2c8dbd4248b8fed6d8 Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Tue, 8 Jul 2025 12:19:21 +0800 Subject: [PATCH 2/2] update var --- backend/plugin/tools.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/plugin/tools.py b/backend/plugin/tools.py index a9c922e1..f79f7885 100644 --- a/backend/plugin/tools.py +++ b/backend/plugin/tools.py @@ -45,15 +45,15 @@ def get_plugins() -> list[str]: plugin_packages = [] # 遍历插件目录 - for d in os.listdir(PLUGIN_DIR): - if not os.path.isdir(os.path.join(PLUGIN_DIR, d)) and d == '__pycache__': + for item in os.listdir(PLUGIN_DIR): + if not os.path.isdir(os.path.join(PLUGIN_DIR, item)) and item == '__pycache__': continue - item_path = os.path.join(PLUGIN_DIR, d) + item_path = os.path.join(PLUGIN_DIR, item) # 检查是否为目录且包含 __init__.py 文件 if os.path.isdir(item_path) and '__init__.py' in os.listdir(item_path): - plugin_packages.append(d) + plugin_packages.append(item) return plugin_packages