feat: 更新应用信息标签页和主窗口UI
- 添加版本检查功能,支持从服务器获取最新版本信息 - 修改应用信息标签页布局,增加版权和许可证信息 - 主窗口改用MSFluentWindow并启用亚克力效果 - 更新README中的许可证信息为GPLv3 - 修改安装器警告信息,强调转载协议合规性 - 更新构建命令包含assets目录 - 更新依赖项PyQt-Fluent-Widgets为完整版
This commit is contained in:
@@ -26,7 +26,7 @@ from qfluentwidgets import (
|
||||
CardWidget, TitleLabel, SubtitleLabel, CaptionLabel, BodyLabel, PushButton,
|
||||
PrimaryPushButton, LineEdit, ComboBox, ProgressBar, TableWidget,
|
||||
ScrollArea, InfoBar, InfoBarPosition, NavigationInterface, NavigationItemPosition,
|
||||
FluentWindow, FluentIcon, SimpleCardWidget
|
||||
FluentWindow, MSFluentWindow, FluentIcon, SimpleCardWidget, PrimaryPushSettingCard
|
||||
)
|
||||
from qfluentwidgets import FluentTranslator
|
||||
from app_detail_window import AppDetailWindow
|
||||
@@ -712,8 +712,8 @@ class TagTab(QWidget):
|
||||
|
||||
# 创建标签列表
|
||||
self.tag_list = TableWidget()
|
||||
self.tag_list.setColumnCount(3)
|
||||
self.tag_list.setHorizontalHeaderLabels(["ID", "标签名称", "应用数量"])
|
||||
self.tag_list.setColumnCount(2)
|
||||
self.tag_list.setHorizontalHeaderLabels(["ID", "标签名称"])
|
||||
self.tag_list.horizontalHeader().setSectionResizeMode(1, 3)
|
||||
self.tag_list.cellDoubleClicked.connect(self.show_tag_apps)
|
||||
layout.addWidget(self.tag_list)
|
||||
@@ -817,11 +817,9 @@ class TagTab(QWidget):
|
||||
# 安全获取字段值,避免KeyError
|
||||
tag_id = str(tag.get('id', '未知ID'))
|
||||
tag_name = tag.get('name', '无名称')
|
||||
app_count = str(tag.get('app_count', 0))
|
||||
|
||||
self.tag_list.setItem(row_pos, 0, QTableWidgetItem(tag_id))
|
||||
self.tag_list.setItem(row_pos, 1, QTableWidgetItem(tag_name))
|
||||
self.tag_list.setItem(row_pos, 2, QTableWidgetItem(app_count))
|
||||
|
||||
# 更新分页信息,增加异常处理
|
||||
try:
|
||||
@@ -2564,8 +2562,9 @@ class AppVersionsWindow(QMainWindow):
|
||||
|
||||
class AppInfoTab(QWidget):
|
||||
"""APP信息标签页"""
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, api_client=None, parent=None):
|
||||
super().__init__(parent)
|
||||
self.api_client = api_client
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
@@ -2583,22 +2582,121 @@ class AppInfoTab(QWidget):
|
||||
card_layout = QVBoxLayout(card)
|
||||
card_layout.setContentsMargins(20, 20, 20, 20)
|
||||
|
||||
# 添加版本号信息
|
||||
version_label = SubtitleLabel(f"版本号: {APP_VERSION}")
|
||||
card_layout.addWidget(version_label, alignment=Qt.AlignCenter)
|
||||
# 添加版本号信息 - 使用PrimaryPushSettingCard
|
||||
self.version_card = PrimaryPushSettingCard(
|
||||
title="版本号",
|
||||
text="检查更新",
|
||||
content="目前APP版本号:" + APP_VERSION,
|
||||
icon=FluentIcon.INFO,
|
||||
parent=self
|
||||
)
|
||||
self.version_card.clicked.connect(self.check_update)
|
||||
card_layout.addWidget(self.version_card)
|
||||
|
||||
# 添加描述信息
|
||||
description_label = CaptionLabel("这是LeonApp应用商店的PC端管理工具,用于查看和管理应用、标签和开发者信息。")
|
||||
description_label.setWordWrap(True)
|
||||
card_layout.addWidget(description_label, alignment=Qt.AlignCenter)
|
||||
description_label.setAlignment(Qt.AlignCenter)
|
||||
description_label.setMinimumHeight(60)
|
||||
card_layout.addWidget(description_label)
|
||||
|
||||
# 添加分隔符
|
||||
card_layout.addSpacing(10)
|
||||
|
||||
# 添加QFluentDesign版权信息
|
||||
qfluentdesign_label = CaptionLabel("界面设计基于QFluentWidgets - PyQt5的Fluent Design风格组件库")
|
||||
qfluentdesign_label.setWordWrap(True)
|
||||
qfluentdesign_label.setAlignment(Qt.AlignCenter)
|
||||
card_layout.addWidget(qfluentdesign_label)
|
||||
|
||||
# 添加GPLv3许可证信息
|
||||
license_label = CaptionLabel("本应用采用GNU General Public License v3.0 (GPLv3) 许可协议发布")
|
||||
license_label.setWordWrap(True)
|
||||
license_label.setAlignment(Qt.AlignCenter)
|
||||
card_layout.addWidget(license_label)
|
||||
|
||||
# 添加信息卡片到主布局
|
||||
layout.addWidget(card, alignment=Qt.AlignCenter)
|
||||
|
||||
# 填充空白,使内容居中
|
||||
layout.addStretch()
|
||||
|
||||
def check_update(self):
|
||||
"""检查更新功能"""
|
||||
# 显示加载中的提示
|
||||
self.show_info("正在检查更新...")
|
||||
|
||||
# 创建工作线程来异步获取版本信息
|
||||
self.worker = WorkerThread(
|
||||
self.api_client,
|
||||
'getappversions',
|
||||
{'id': 15} # LeonAPP的ID为15
|
||||
)
|
||||
self.worker.finished.connect(self.on_update_checked)
|
||||
self.worker.error.connect(self.on_update_error)
|
||||
self.worker.start()
|
||||
|
||||
def on_update_checked(self, data):
|
||||
"""更新检查完成后的处理"""
|
||||
try:
|
||||
# 检查API返回的数据格式
|
||||
if not isinstance(data, dict) or 'versions' not in data:
|
||||
self.show_error("获取版本信息失败:数据格式不正确")
|
||||
return
|
||||
|
||||
versions = data.get('versions', [])
|
||||
if not versions:
|
||||
self.show_error("未找到任何版本信息")
|
||||
return
|
||||
|
||||
# 最新版本通常在列表的第一个
|
||||
latest_version = versions[0].get('version', '未知')
|
||||
current_version = APP_VERSION
|
||||
|
||||
# 比较版本号
|
||||
if latest_version != current_version:
|
||||
# 版本不一致,显示更新提示
|
||||
self.show_info(
|
||||
f"发现新版本:{latest_version}",
|
||||
f"当前版本:{current_version}\n建议前往应用商店下载最新版本。"
|
||||
)
|
||||
else:
|
||||
# 已是最新版本
|
||||
self.show_info("已是最新版本", f"当前版本 {current_version} 是最新版本")
|
||||
except Exception as e:
|
||||
self.show_error(f"处理版本信息时发生错误:{str(e)}")
|
||||
|
||||
def on_update_error(self, error_message):
|
||||
"""处理更新检查时的错误"""
|
||||
self.show_error(f"检查更新失败:{error_message}")
|
||||
|
||||
def show_info(self, title, content=None):
|
||||
"""显示信息消息"""
|
||||
if content is None:
|
||||
content = ""
|
||||
InfoBar.info(
|
||||
title=title,
|
||||
content=content,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=True,
|
||||
position=InfoBarPosition.BOTTOM_RIGHT,
|
||||
duration=5000,
|
||||
parent=self
|
||||
)
|
||||
|
||||
def show_error(self, message):
|
||||
"""显示错误消息"""
|
||||
InfoBar.error(
|
||||
title="错误",
|
||||
content=message,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=True,
|
||||
position=InfoBarPosition.BOTTOM_RIGHT,
|
||||
duration=5000,
|
||||
parent=self
|
||||
)
|
||||
|
||||
class LeonAppGUI(FluentWindow):
|
||||
class LeonAppGUI(MSFluentWindow):
|
||||
"""主应用窗口"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -2607,6 +2705,22 @@ class LeonAppGUI(FluentWindow):
|
||||
# 设置窗口标题和大小
|
||||
self.setWindowTitle("LeonApp For PC")
|
||||
self.resize(1000, 700)
|
||||
|
||||
# 设置窗口图标
|
||||
from PyQt5.QtGui import QIcon
|
||||
import os
|
||||
icon_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "icon.jpeg")
|
||||
if os.path.exists(icon_path):
|
||||
self.setWindowIcon(QIcon(icon_path))
|
||||
|
||||
# 启用亚克力效果
|
||||
from qfluentwidgets import isDarkTheme
|
||||
if hasattr(self, 'setAcrylicEffect'):
|
||||
self.setAcrylicEffect(True)
|
||||
elif hasattr(self, 'setWindowOpacity'):
|
||||
# 如果没有直接的亚克力效果方法,设置窗口透明度作为替代
|
||||
self.setWindowOpacity(0.95)
|
||||
|
||||
# 初始化UI
|
||||
self.init_ui()
|
||||
|
||||
@@ -2635,7 +2749,7 @@ class LeonAppGUI(FluentWindow):
|
||||
self.addSubInterface(self.stats_tab, FluentIcon.PIE_SINGLE, "统计信息")
|
||||
|
||||
# 添加APP信息标签页
|
||||
self.info_tab = AppInfoTab(self)
|
||||
self.info_tab = AppInfoTab(self.api_client, self)
|
||||
self.info_tab.setObjectName("info")
|
||||
self.addSubInterface(self.info_tab, FluentIcon.INFO, "应用信息")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user