继续改

This commit is contained in:
2025-07-25 02:54:03 +08:00
parent 78661f450b
commit 9fc6b4577a
10 changed files with 2070 additions and 1770 deletions

20
app/tools/check_update.py Normal file
View File

@@ -0,0 +1,20 @@
import requests
from packaging.version import parse as vparse
def check_update(local_version, repo="goldenfishs/MRobot"):
"""
检查 GitHub 上是否有新版本
:param local_version: 当前版本号字符串,如 "1.0.2"
:param repo: 仓库名,格式 "用户名/仓库名"
:return: 最新版本号字符串(如果有新版本),否则 None
"""
url = f"https://api.github.com/repos/{repo}/releases/latest"
try:
resp = requests.get(url, timeout=5)
if resp.status_code == 200:
latest = resp.json()["tag_name"].lstrip("v")
if vparse(latest) > vparse(local_version):
return latest
except Exception as e:
print(f"检查更新失败: {e}")
return None