Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
feat: show change log when checking update
Browse files Browse the repository at this point in the history
  • Loading branch information
zyf722 committed Feb 6, 2024
1 parent 83097aa commit 0b0a493
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions examples/bf1chs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from InquirerPy.separator import Separator
from rich import box
from rich.console import Console
from rich.markdown import Markdown
from rich.progress import (
BarColumn,
MofNCompleteColumn,
Expand All @@ -34,7 +35,7 @@

from flamethrower.localization import Histogram, StringsBinary

VERSION = "v0.3.0"
VERSION = "v0.3.1"
PROJECT_ID = 8862
REPO_NAME = "flamethrower"
REPO_OWNER_GITHUB = "zyf722"
Expand All @@ -57,7 +58,16 @@
os.chdir(os.path.dirname(os.path.abspath(__file__)))

console = Console(
theme=Theme({"dark-gray": "#5c6370", "light-blue": "#61afef"}),
theme=Theme(
{
"dark-gray": "#5c6370",
"light-blue": "#61afef",
# Override rich's default theme
"markdown.item.bullet": "yellow",
"markdown.link_url": "#61afef",
"markdown.code": "#e83e8c",
}
),
highlight=False,
)

Expand Down Expand Up @@ -1247,11 +1257,9 @@ def _check_update(self):
"""
console.print("[yellow]正在检查更新...")
try:
(
latest_asset_url,
latest_version,
latest_published_time,
) = self.source_api.get_latest_asset(ASSET_NAME)
(latest_asset_url, latest_version, latest_published_time, latest_log) = (
self.source_api.get_latest_asset(ASSET_NAME)
)
except ProxyError as e:
console.print("[bold red]代理错误。请检查代理设置是否正确。\n")
raise e
Expand All @@ -1267,6 +1275,9 @@ def _check_update(self):
console.print(
f"[yellow]发现新版本 {latest_version},发布于 {latest_published_time.strftime('%Y年%m月%d日 %H:%M:%S')}\n"
)
console.print("[underline yellow]更新日志:")
console.print(Markdown(latest_log.split("## `bf1chs`\r\n")[1]))
console.print()
if self._rich_confirm(message="是否立即下载?"):
webbrowser.open(latest_asset_url)
raise BF1ChsToolbox.ExitException
Expand Down

0 comments on commit 0b0a493

Please sign in to comment.