fix: 调整变量顺序,更加直观

This commit is contained in:
Aqr-K
2025-01-05 17:07:11 +08:00
parent 704dcf46d3
commit 261bb5fa81
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -682,7 +682,7 @@ class PluginManager(metaclass=Singleton):
# 相同 ID 的插件保留版本号最大的版本 # 相同 ID 的插件保留版本号最大的版本
max_versions = {} max_versions = {}
for p in all_plugins: for p in all_plugins:
if p.id not in max_versions or StringUtils.compare_version(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]):
max_versions[p.id] = p.plugin_version max_versions[p.id] = p.plugin_version
result = [p for p in all_plugins if p.plugin_version == max_versions[p.id]] result = [p for p in all_plugins if p.plugin_version == max_versions[p.id]]
logger.info(f"共获取到 {len(result)} 个线上插件") logger.info(f"共获取到 {len(result)} 个线上插件")
@@ -823,7 +823,7 @@ class PluginManager(metaclass=Singleton):
plugin.has_update = False plugin.has_update = False
if plugin_static: if plugin_static:
installed_version = getattr(plugin_static, "plugin_version") installed_version = getattr(plugin_static, "plugin_version")
if StringUtils.compare_version(installed_version, plugin_info.get("version"), "<"): if StringUtils.compare_version(installed_version, "<", plugin_info.get("version")):
# 需要更新 # 需要更新
plugin.has_update = True plugin.has_update = True
# 运行状态 # 运行状态
+1 -1
View File
@@ -70,7 +70,7 @@ class ResourceHelper(metaclass=Singleton):
local_version = self.siteshelper.indexer_version local_version = self.siteshelper.indexer_version
else: else:
continue continue
if StringUtils.compare_version(version, local_version, ">"): if StringUtils.compare_version(version, ">", local_version):
logger.info(f"{rname} 资源包有更新,最新版本:v{version}") logger.info(f"{rname} 资源包有更新,最新版本:v{version}")
else: else:
continue continue
+1 -1
View File
@@ -770,7 +770,7 @@ class StringUtils:
return result return result
@staticmethod @staticmethod
def compare_version(v1: str, v2: str, compare_type, verbose: bool = False) \ def compare_version(v1: str, compare_type: str, v2: str, verbose: bool = False) \
-> Tuple[Optional[bool], str | Exception] | Optional[bool]: -> Tuple[Optional[bool], str | Exception] | Optional[bool]:
""" """
比较两个版本号的大小 比较两个版本号的大小