From 8bbfdcbc04c1203a614d8810dfdc2a1f20c020e5 Mon Sep 17 00:00:00 2001 From: DLmaster Date: Mon, 27 Jan 2025 12:20:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(utils):=20=E4=BF=AE=E5=A4=8D=20version=5Fte?= =?UTF-8?q?xt=20=E5=BC=95=E8=B5=B7=E7=9A=84=E6=89=93=E5=8C=85=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 3 +-- app/ui/setting.py | 14 +++++++++++++- app/utils/Updater.py | 12 +++++++++++- app/utils/__init__.py | 3 +-- app/utils/package.py | 15 +++++++++++++-- app/utils/version.py | 38 -------------------------------------- main.py | 2 +- 7 files changed, 40 insertions(+), 47 deletions(-) delete mode 100644 app/utils/version.py diff --git a/app/__init__.py b/app/__init__.py index 348605b..0c70453 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -33,7 +33,7 @@ from .core import AppConfig, QueueConfig, MaaConfig, Task, Task_manager, Main_ti from .models import MaaManager from .services import Notify, Crypto, System from .ui import AUTO_MAA -from .utils import Updater, version_text +from .utils import Updater __all__ = [ "AppConfig", @@ -48,5 +48,4 @@ __all__ = [ "System", "AUTO_MAA", "Updater", - "version_text", ] diff --git a/app/ui/setting.py b/app/ui/setting.py index 6ca4781..1562ff8 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -50,7 +50,7 @@ import requests from app.core import Config, MainInfoBar from app.services import Crypto, System -from app.utils import Updater, version_text +from app.utils import Updater from .Widget import InputMessageBox, LineEditSettingCard @@ -717,3 +717,15 @@ class OtherSettingCard(HeaderCardWidget): self.viewLayout.setContentsMargins(0, 0, 0, 0) self.viewLayout.setSpacing(0) self.addGroupWidget(widget) + + +def version_text(version_numb: list) -> str: + """将版本号列表转为可读的文本信息""" + + if version_numb[3] == 0: + version = f"v{'.'.join(str(_) for _ in version_numb[0:3])}" + else: + version = ( + f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}" + ) + return version diff --git a/app/utils/Updater.py b/app/utils/Updater.py index ffad9cb..364288f 100644 --- a/app/utils/Updater.py +++ b/app/utils/Updater.py @@ -42,7 +42,17 @@ from qfluentwidgets import ProgressBar, IndeterminateProgressBar, BodyLabel from PySide6.QtGui import QIcon from PySide6.QtCore import QObject, QThread, Signal -from .version import version_text + +def version_text(version_numb: list) -> str: + """将版本号列表转为可读的文本信息""" + + if version_numb[3] == 0: + version = f"v{'.'.join(str(_) for _ in version_numb[0:3])}" + else: + version = ( + f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}" + ) + return version class UpdateProcess(QThread): diff --git a/app/utils/__init__.py b/app/utils/__init__.py index 2f1ba20..3cbc288 100644 --- a/app/utils/__init__.py +++ b/app/utils/__init__.py @@ -30,6 +30,5 @@ __author__ = "DLmaster361 " __license__ = "GPL-3.0 license" from .Updater import Updater -from .version import version_text -__all__ = ["Updater", "version_text"] +__all__ = ["Updater"] diff --git a/app/utils/package.py b/app/utils/package.py index d960840..7c17754 100644 --- a/app/utils/package.py +++ b/app/utils/package.py @@ -26,16 +26,27 @@ v4.2 """ import os +import sys import json import shutil from pathlib import Path -from app import version_text + +def version_text(version_numb: list) -> str: + """将版本号列表转为可读的文本信息""" + + if version_numb[3] == 0: + version = f"v{'.'.join(str(_) for _ in version_numb[0:3])}" + else: + version = ( + f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}" + ) + return version if __name__ == "__main__": - root_path = Path.cwd() + root_path = Path(sys.argv[0]).resolve().parent with (root_path / "resources/version.json").open(mode="r", encoding="utf-8") as f: version = json.load(f) diff --git a/app/utils/version.py b/app/utils/version.py deleted file mode 100644 index 56cc393..0000000 --- a/app/utils/version.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright © <2024> - -# This file is part of AUTO_MAA. - -# AUTO_MAA is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, -# or (at your option) any later version. - -# AUTO_MAA is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with AUTO_MAA. If not, see . - -# DLmaster_361@163.com - -""" -AUTO_MAA -AUTO_MAA版本号工具 -v4.2 -作者:DLmaster_361 -""" - - -def version_text(version_numb: list) -> str: - """将版本号列表转为可读的文本信息""" - - if version_numb[3] == 0: - version = f"v{'.'.join(str(_) for _ in version_numb[0:3])}" - else: - version = ( - f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}" - ) - return version diff --git a/main.py b/main.py index ddc8e64..6e557e4 100644 --- a/main.py +++ b/main.py @@ -32,7 +32,7 @@ from qfluentwidgets import FluentTranslator import sys -# @logger.catch +@logger.catch def main(): application = QApplication(sys.argv)