feat: 添加应用详情窗口和更新检查功能
- 实现全新的应用详情窗口,包含统计信息、基本信息和描述展示 - 添加应用更新检查功能到CLI工具 - 优化版本列表页面的文件路径处理逻辑 - 升级GUI版本至Beta 0.4 - 增强公告详情页面的链接处理能力
This commit is contained in:
@@ -14,6 +14,9 @@ from datetime import datetime
|
||||
import requests
|
||||
from colorama import init, Fore, Style
|
||||
|
||||
# 当前版本
|
||||
APP_VERSION = "Beta 0.3"
|
||||
|
||||
# 初始化colorama
|
||||
def init_colorama():
|
||||
"""初始化colorama,确保在Windows和其他平台上都能正确显示彩色文本"""
|
||||
@@ -327,10 +330,10 @@ class LeonAppCLI:
|
||||
|
||||
elif command == 'stats':
|
||||
self.get_count_info()
|
||||
|
||||
elif command == 'check-update':
|
||||
self.check_update()
|
||||
else:
|
||||
self.print_error("未知命令,请输入 'help' 获取帮助")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print()
|
||||
self.print_info("按 'exit' 退出")
|
||||
@@ -350,6 +353,7 @@ class LeonAppCLI:
|
||||
print(Fore.CYAN + "developer info [id]" + Fore.WHITE + " - 查看开发者信息")
|
||||
print(Fore.CYAN + "list announcements" + Fore.WHITE + " - 列出所有公告")
|
||||
print(Fore.CYAN + "stats" + Fore.WHITE + " - 查看统计信息")
|
||||
print(Fore.CYAN + "check-update" + Fore.WHITE + " - 检查更新")
|
||||
|
||||
def parse_arguments(self):
|
||||
"""解析命令行参数"""
|
||||
@@ -399,6 +403,46 @@ class LeonAppCLI:
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def check_update(self):
|
||||
"""检查更新功能"""
|
||||
self.print_header("检查更新")
|
||||
self.print_info("正在检查更新...")
|
||||
|
||||
# 获取LeonAPP的版本信息(App ID为15)
|
||||
data = self.make_api_request('getappversions', {'id': 15})
|
||||
|
||||
if data:
|
||||
try:
|
||||
# 检查数据格式
|
||||
if not isinstance(data, dict) or 'versions' not in data:
|
||||
self.print_error("获取版本信息失败:数据格式不正确")
|
||||
return
|
||||
|
||||
versions = data.get('versions', [])
|
||||
if not versions:
|
||||
self.print_error("未找到任何版本信息")
|
||||
return
|
||||
|
||||
# 最新版本通常在列表的第一个
|
||||
latest_version = versions[0].get('version', '未知')
|
||||
current_version = APP_VERSION
|
||||
|
||||
# 比较版本号
|
||||
if latest_version != current_version:
|
||||
# 版本不一致,显示更新提示
|
||||
self.print_separator()
|
||||
self.print_success(f"发现新版本:{latest_version}")
|
||||
self.print_info(f"当前版本:{current_version}")
|
||||
self.print_info("建议前往应用商店下载最新版本。")
|
||||
self.print_separator()
|
||||
else:
|
||||
# 已是最新版本
|
||||
self.print_success(f"已是最新版本:{current_version}")
|
||||
except Exception as e:
|
||||
self.print_error(f"处理版本信息时发生错误:{str(e)}")
|
||||
else:
|
||||
self.print_error("检查更新失败,请稍后重试。")
|
||||
|
||||
def run(self):
|
||||
"""运行CLI"""
|
||||
# 解析命令行参数
|
||||
@@ -421,6 +465,8 @@ class LeonAppCLI:
|
||||
self.list_all_announcements(args.page, args.limit)
|
||||
elif args.command == 'stats':
|
||||
self.get_count_info()
|
||||
elif args.command == 'check-update':
|
||||
self.check_update()
|
||||
elif args.command == 'interactive':
|
||||
self.interactive_mode()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user