-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
在启动时检查更新:检查更新配置 这个提交更改了代码中的导入语句,以使用名为`utils.type_checker`的模块替代了已删除的`utils.checker`模块。这样修改的原因是通过这个更改,代码现在能够在启动时检查更新。这将有助于确保获取最新的更新,并及时对系统进行升级。这个更改消除了不再使用的`utils.checker`模块,并替换为更适合的`utils.type_checker`模块。
- Loading branch information
1 parent
fdcc78e
commit 6007ab8
Showing
6 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Literal | ||
from .logger import get_logger | ||
from .config import config | ||
import version | ||
import httpx | ||
|
||
logger = get_logger() | ||
|
||
|
||
async def get_latest_version() -> dict[str, str]: | ||
async with httpx.AsyncClient(proxies=config["system"].get("proxy")) as client: | ||
response = await client.get("https://onedisc.itcdt.top/version.json") | ||
return response.json() | ||
|
||
def get_version_type() -> Literal["beta", "stable"]: | ||
return "stable" if version.SUB_VER == 0 else "beta" | ||
|
||
def parse_version_number(version_number: str) -> tuple[str, int, str]: | ||
ver = version_number.split(".") | ||
return ".".join(ver[:3]), int(ver[3]), version_number | ||
|
||
async def check_update() -> None: | ||
latest_version = parse_version_number( | ||
(await get_latest_version())[get_version_type()] | ||
) | ||
if latest_version[0] == version.VERSION and latest_version[1] <= version.SUB_VER: | ||
return | ||
logger.info(f"发现新版本: {latest_version[2]}") |