fix: 使用 Python 内建的 packaging.version 模块判断版本号,一劳永逸解决问题

This commit is contained in:
DrSmoothl
2025-03-17 12:36:33 +08:00
parent 53232737f6
commit 41f44d41ff

View File

@@ -6,6 +6,7 @@ from loguru import logger
import shutil import shutil
import ast import ast
import json import json
from packaging import version
is_share = False is_share = False
@@ -13,7 +14,8 @@ debug = True
config_data = toml.load("config/bot_config.toml") config_data = toml.load("config/bot_config.toml")
CONFIG_VERSION = config_data["inner"]["version"] CONFIG_VERSION = config_data["inner"]["version"]
PARSED_CONFIG_VERSION = float(CONFIG_VERSION[2:]) PARSED_CONFIG_VERSION = version.parse(CONFIG_VERSION)
HAVE_ONLINE_STATUS_VERSION = version.parse("0.0.9")
#============================================== #==============================================
#env环境配置文件读取部分 #env环境配置文件读取部分
@@ -1148,7 +1150,7 @@ with gr.Blocks(title="MaimBot配置文件编辑") as app:
enable_debug_output = gr.Checkbox(value=config_data['others']['enable_debug_output'], label="是否开启调试输出") enable_debug_output = gr.Checkbox(value=config_data['others']['enable_debug_output'], label="是否开启调试输出")
with gr.Row(): with gr.Row():
enable_friend_chat = gr.Checkbox(value=config_data['others']['enable_friend_chat'], label="是否开启好友聊天") enable_friend_chat = gr.Checkbox(value=config_data['others']['enable_friend_chat'], label="是否开启好友聊天")
if PARSED_CONFIG_VERSION > 0.8: if PARSED_CONFIG_VERSION > HAVE_ONLINE_STATUS_VERSION:
with gr.Row(): with gr.Row():
gr.Markdown( gr.Markdown(
"""### 远程统计设置\n """### 远程统计设置\n
@@ -1178,7 +1180,7 @@ with gr.Blocks(title="MaimBot配置文件编辑") as app:
with gr.Row(): with gr.Row():
save_other_config_message = gr.Textbox() save_other_config_message = gr.Textbox()
with gr.Row(): with gr.Row():
if PARSED_CONFIG_VERSION <= 0.8: if PARSED_CONFIG_VERSION <= HAVE_ONLINE_STATUS_VERSION:
remote_status = gr.Checkbox(value=False,visible=False) remote_status = gr.Checkbox(value=False,visible=False)
save_other_config_btn.click( save_other_config_btn.click(
save_other_config, save_other_config,