feat: 后端添加version上报

This commit is contained in:
DLmaster361
2025-09-07 03:21:38 +08:00
parent 2636858fc0
commit 6bf30b4dc6
8 changed files with 199 additions and 7 deletions

View File

@@ -116,6 +116,10 @@ class GlobalConfig(ConfigBase):
"Update", "MirrorChyanCDK", "", EncryptValidator()
)
Data_UID = ConfigItem("Data", "UID", str(uuid.uuid4()), UUIDValidator())
Data_LastStatisticsUpload = ConfigItem(
"Data", "LastStatisticsUpload", "2000-01-01 00:00:00"
)
Data_LastStageUpdated = ConfigItem(
"Data", "LastStageUpdated", "2000-01-01 00:00:00"
)
@@ -571,7 +575,7 @@ TYPE_BOOK = {"MaaConfig": "MAA", "GeneralConfig": "通用"}
class AppConfig(GlobalConfig):
VERSION = "5.0.0.1"
VERSION = [5, 0, 0, 1]
def __init__(self) -> None:
super().__init__(if_save_multi_config=False)
@@ -579,7 +583,7 @@ class AppConfig(GlobalConfig):
logger.info("")
logger.info("===================================")
logger.info("AUTO_MAA 后端应用程序")
logger.info(f"版本号: v{self.VERSION}")
logger.info(f"版本号: {self.version()}")
logger.info(f"工作目录: {Path.cwd()}")
logger.info("===================================")
@@ -605,6 +609,16 @@ class AppConfig(GlobalConfig):
truststore.inject_into_ssl()
def version(self) -> str:
"""获取版本号字符串"""
if self.VERSION[3] == 0:
return f"v{'.'.join(str(_) for _ in self.VERSION[0:3])}"
else:
return (
f"v{'.'.join(str(_) for _ in self.VERSION[0:3])}-beta.{self.VERSION[3]}"
)
async def init_config(self) -> None:
"""初始化配置管理"""

View File

@@ -22,7 +22,7 @@ import asyncio
import keyboard
from datetime import datetime
from app.services import System
from app.services import Matomo, System
from app.utils import get_logger
from .config import Config
@@ -42,6 +42,33 @@ class _MainTimer:
await asyncio.sleep(1)
async def hour_task(self):
"""每小时定期任务"""
logger.info("每小时定期任务启动")
while True:
if (
datetime.strptime(
Config.get("Data", "LastStatisticsUpload"), "%Y-%m-%d %H:%M:%S"
).date()
!= datetime.now().date()
):
await Matomo.send_event(
"App",
"Version",
Config.version(),
1 if "beta" in Config.version() else 0,
)
await Config.set(
"Data",
"LastStatisticsUpload",
datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
)
await asyncio.sleep(3600)
async def set_silence(self):
"""静默模式通过模拟老板键来隐藏模拟器窗口"""