From 34e70adabb681ed471fcf7de2626bbbe057c5c48 Mon Sep 17 00:00:00 2001 From: thsrite Date: Wed, 29 May 2024 20:40:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=20=E6=8F=92=E4=BB=B6=E5=BA=93=E7=9B=B8?= =?UTF-8?q?=E5=90=8CID=E7=9A=84=E6=8F=92=E4=BB=B6=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E6=9C=80=E5=A4=A7=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/plugin.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/core/plugin.py b/app/core/plugin.py index dd8e2f7a..31273c5a 100644 --- a/app/core/plugin.py +++ b/app/core/plugin.py @@ -26,7 +26,6 @@ from app.utils.system import SystemUtils class PluginMonitorHandler(FileSystemEventHandler): - # 计时器 __reload_timer = None # 防抖时间间隔 @@ -350,6 +349,7 @@ class PluginManager(metaclass=Singleton): :param pid: 插件ID :param key: 仪表盘key """ + def __get_params_count(func: Callable): """ 获取函数的参数信息 @@ -630,14 +630,14 @@ class PluginManager(metaclass=Singleton): all_plugins.sort( key=lambda x: settings.PLUGIN_MARKET.split(",").index(x.repo_url) if x.repo_url else 0 ) - # 按插件ID和版本号去重,相同插件以前面的为准 - result = [] - _dup = [] + + # 相同ID的插件保留版本号最大版本 + max_versions = {} for p in all_plugins: - key = f"{p.id}v{p.plugin_version}" - if key not in _dup: - _dup.append(key) - result.append(p) + if p.id not in max_versions or p.plugin_version > max_versions[p.id]: + max_versions[p.id] = p.plugin_version + result = [p for p in all_plugins if + p.plugin_version == max_versions[p.id]] logger.info(f"共获取到 {len(result)} 个第三方插件") return result From 07de1eaa0d020e0f858581e3778cd29b1593930d Mon Sep 17 00:00:00 2001 From: thsrite Date: Thu, 30 May 2024 10:02:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=20=E6=8F=92=E4=BB=B6=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=AF=94=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/core/plugin.py b/app/core/plugin.py index 31273c5a..69fb628d 100644 --- a/app/core/plugin.py +++ b/app/core/plugin.py @@ -634,7 +634,7 @@ class PluginManager(metaclass=Singleton): # 相同ID的插件保留版本号最大版本 max_versions = {} for p in all_plugins: - if p.id not in max_versions or p.plugin_version > max_versions[p.id]: + if p.id not in max_versions or StringUtils.compare_version(p.plugin_version, max_versions[p.id]) > 0: max_versions[p.id] = p.plugin_version result = [p for p in all_plugins if p.plugin_version == max_versions[p.id]]