mirror of
https://github.com/goldenfishs/MRobot.git
synced 2026-03-31 21:07:14 +08:00
优化了ai个零件库
This commit is contained in:
@@ -2,19 +2,13 @@ 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
|
||||
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
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
raise RuntimeError("GitHub API 请求失败")
|
||||
Reference in New Issue
Block a user