[patch] 优化PDD的js环境补充 优化配置文件心跳环境检测 优化打包环境补充逻辑
This commit is contained in:
272
main.py
272
main.py
@@ -62,10 +62,9 @@ class LoginWindow(QMainWindow):
|
||||
self.disconnect_signals = DisconnectSignals()
|
||||
self.disconnect_signals.disconnected.connect(self._show_disconnect_dialog)
|
||||
|
||||
# 横幅动画相关
|
||||
# 横幅相关
|
||||
self.promo_banner = None
|
||||
self.banner_animation = None
|
||||
self.banner_color_index = 0
|
||||
self.banner_shadow = None # 阴影效果引用
|
||||
|
||||
self.initUI()
|
||||
|
||||
@@ -177,60 +176,94 @@ class LoginWindow(QMainWindow):
|
||||
print("[INFO] 窗口已自适应内容大小")
|
||||
|
||||
def create_promo_banner(self, layout):
|
||||
"""创建宣传横幅(带动态渐变效果)"""
|
||||
"""创建宣传横幅(使用图片,带悬停动画效果)"""
|
||||
try:
|
||||
# 创建横幅容器(最小化高度)
|
||||
# 创建横幅容器
|
||||
banner_frame = QFrame()
|
||||
banner_frame.setObjectName("promoBanner")
|
||||
banner_frame.setCursor(Qt.PointingHandCursor) # 鼠标变手型
|
||||
banner_frame.setMinimumHeight(65) # 最小高度
|
||||
banner_frame.setMaximumHeight(65) # 固定高度
|
||||
|
||||
# 保存横幅引用,用于动画
|
||||
self.promo_banner = banner_frame
|
||||
|
||||
# 横幅布局(最小内边距)
|
||||
# 使用图片标签
|
||||
banner_image = QLabel()
|
||||
banner_image.setObjectName("bannerImage")
|
||||
|
||||
# 加载横幅图片
|
||||
from windows_taskbar_fix import get_resource_path
|
||||
image_path = get_resource_path("static/hengfu.jpg")
|
||||
|
||||
if os.path.exists(image_path):
|
||||
from PyQt5.QtGui import QPixmap
|
||||
pixmap = QPixmap(image_path)
|
||||
|
||||
# 设置固定的横幅尺寸
|
||||
target_width = 400 # 固定宽度
|
||||
target_height = 70 # 固定高度(调整为70px,更紧凑)
|
||||
|
||||
# 缩放图片以适应目标尺寸
|
||||
scaled_pixmap = pixmap.scaled(
|
||||
target_width,
|
||||
target_height,
|
||||
Qt.IgnoreAspectRatio, # 忽略宽高比,拉伸填充
|
||||
Qt.SmoothTransformation # 平滑缩放,提高图片质量
|
||||
)
|
||||
|
||||
# 设置图片
|
||||
banner_image.setPixmap(scaled_pixmap)
|
||||
banner_image.setScaledContents(False)
|
||||
|
||||
banner_frame.setFixedHeight(target_height)
|
||||
banner_image.setFixedSize(target_width, target_height)
|
||||
|
||||
# 🔧 使用CSS圆角来处理边角(更简单稳定)
|
||||
banner_image.setStyleSheet("""
|
||||
QLabel#bannerImage {
|
||||
border-radius: 12px;
|
||||
background-color: transparent;
|
||||
}
|
||||
""")
|
||||
|
||||
print(f"[INFO] 横幅图片已加载: {image_path}, 尺寸: {target_width}x{target_height}")
|
||||
else:
|
||||
# 图片不存在时的备用方案
|
||||
banner_image.setText("🌟 限时优惠活动 - 点击了解详情 →")
|
||||
banner_image.setAlignment(Qt.AlignCenter)
|
||||
banner_image.setStyleSheet("""
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #667eea, stop:1 #764ba2);
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
border-radius: 12px;
|
||||
padding: 15px;
|
||||
""")
|
||||
banner_frame.setFixedHeight(60)
|
||||
print(f"[WARNING] 横幅图片未找到: {image_path},使用备用样式")
|
||||
|
||||
# 创建布局
|
||||
banner_layout = QHBoxLayout()
|
||||
banner_layout.setContentsMargins(10, 6, 10, 6) # 最小内边距
|
||||
banner_layout.setSpacing(8) # 最小间距
|
||||
banner_layout.setContentsMargins(0, 0, 0, 0)
|
||||
banner_layout.setSpacing(0)
|
||||
banner_frame.setLayout(banner_layout)
|
||||
banner_layout.addWidget(banner_image)
|
||||
|
||||
# 左侧图标(最小化)
|
||||
icon_label = QLabel("🎁")
|
||||
icon_label.setFont(QFont('Microsoft YaHei', 22)) # 更小的图标字体
|
||||
icon_label.setAlignment(Qt.AlignCenter)
|
||||
icon_label.setFixedSize(45, 45) # 更小的图标尺寸
|
||||
banner_layout.addWidget(icon_label)
|
||||
# 设置圆角和边框
|
||||
banner_frame.setStyleSheet("""
|
||||
QFrame#promoBanner {
|
||||
border-radius: 12px;
|
||||
background: transparent;
|
||||
}
|
||||
""")
|
||||
|
||||
# 右侧文字区域
|
||||
text_layout = QVBoxLayout()
|
||||
text_layout.setSpacing(1) # 最小文字间距
|
||||
|
||||
# 标题
|
||||
title_label = QLabel("🌟 限时优惠活动进行中")
|
||||
title_label.setFont(QFont('Microsoft YaHei', 10, QFont.Bold)) # 更小字体
|
||||
title_label.setStyleSheet("color: white;")
|
||||
text_layout.addWidget(title_label)
|
||||
|
||||
# 副标题
|
||||
subtitle_label = QLabel("立即访问官网了解更多优惠详情 →")
|
||||
subtitle_label.setFont(QFont('Microsoft YaHei', 8)) # 更小字体
|
||||
subtitle_label.setStyleSheet("color: rgba(255, 255, 255, 0.9);")
|
||||
text_layout.addWidget(subtitle_label)
|
||||
|
||||
banner_layout.addLayout(text_layout)
|
||||
banner_layout.addStretch()
|
||||
|
||||
# 初始样式(紫色渐变背景)
|
||||
self.update_banner_style(0)
|
||||
|
||||
# 添加阴影效果(更轻量)
|
||||
shadow = QGraphicsDropShadowEffect()
|
||||
shadow.setBlurRadius(10) # 减小模糊半径
|
||||
shadow.setXOffset(0)
|
||||
shadow.setYOffset(2) # 减小偏移
|
||||
shadow.setColor(QColor(0, 0, 0, 40)) # 降低不透明度
|
||||
banner_frame.setGraphicsEffect(shadow)
|
||||
# 初始阴影效果
|
||||
self.banner_shadow = QGraphicsDropShadowEffect()
|
||||
self.banner_shadow.setBlurRadius(15)
|
||||
self.banner_shadow.setXOffset(0)
|
||||
self.banner_shadow.setYOffset(3)
|
||||
self.banner_shadow.setColor(QColor(0, 0, 0, 60))
|
||||
banner_frame.setGraphicsEffect(self.banner_shadow)
|
||||
|
||||
# 点击事件 - 跳转官网
|
||||
def open_official_website():
|
||||
@@ -244,88 +277,82 @@ class LoginWindow(QMainWindow):
|
||||
|
||||
banner_frame.mousePressEvent = lambda event: open_official_website()
|
||||
|
||||
# 🎯 添加鼠标悬停事件(动态效果)
|
||||
def on_enter(event):
|
||||
"""鼠标进入时的动画效果"""
|
||||
try:
|
||||
# 增强阴影效果
|
||||
self.banner_shadow.setBlurRadius(25)
|
||||
self.banner_shadow.setYOffset(5)
|
||||
self.banner_shadow.setColor(QColor(0, 0, 0, 100))
|
||||
|
||||
# 轻微放大动画
|
||||
animation = QPropertyAnimation(banner_frame, b"geometry")
|
||||
original_rect = banner_frame.geometry()
|
||||
|
||||
expanded_rect = QRect(
|
||||
original_rect.x() - 3,
|
||||
original_rect.y() - 2,
|
||||
original_rect.width() + 6,
|
||||
original_rect.height() + 4
|
||||
)
|
||||
|
||||
animation.setDuration(200)
|
||||
animation.setStartValue(original_rect)
|
||||
animation.setEndValue(expanded_rect)
|
||||
animation.setEasingCurve(QEasingCurve.OutCubic)
|
||||
animation.start()
|
||||
|
||||
# 保存动画引用避免被垃圾回收
|
||||
banner_frame.hover_animation = animation
|
||||
|
||||
except Exception as e:
|
||||
print(f"[DEBUG] 悬停动画错误: {e}")
|
||||
|
||||
def on_leave(event):
|
||||
"""鼠标离开时的动画效果"""
|
||||
try:
|
||||
# 恢复阴影效果
|
||||
self.banner_shadow.setBlurRadius(15)
|
||||
self.banner_shadow.setYOffset(3)
|
||||
self.banner_shadow.setColor(QColor(0, 0, 0, 60))
|
||||
|
||||
# 恢复原始大小
|
||||
animation = QPropertyAnimation(banner_frame, b"geometry")
|
||||
current_rect = banner_frame.geometry()
|
||||
|
||||
original_rect = QRect(
|
||||
current_rect.x() + 3,
|
||||
current_rect.y() + 2,
|
||||
current_rect.width() - 6,
|
||||
current_rect.height() - 4
|
||||
)
|
||||
|
||||
animation.setDuration(200)
|
||||
animation.setStartValue(current_rect)
|
||||
animation.setEndValue(original_rect)
|
||||
animation.setEasingCurve(QEasingCurve.InCubic)
|
||||
animation.start()
|
||||
|
||||
# 保存动画引用避免被垃圾回收
|
||||
banner_frame.leave_animation = animation
|
||||
|
||||
except Exception as e:
|
||||
print(f"[DEBUG] 离开动画错误: {e}")
|
||||
|
||||
# 安装事件过滤器
|
||||
banner_frame.enterEvent = on_enter
|
||||
banner_frame.leaveEvent = on_leave
|
||||
|
||||
# 添加到主布局
|
||||
layout.addWidget(banner_frame)
|
||||
|
||||
# 启动颜色渐变动画
|
||||
self.start_banner_animation()
|
||||
|
||||
print("[INFO] 宣传横幅已创建(带动态渐变效果)")
|
||||
print("[INFO] 宣传横幅已创建(使用图片,带悬停动画)")
|
||||
|
||||
except Exception as e:
|
||||
print(f"[WARNING] 创建宣传横幅失败: {e}")
|
||||
|
||||
def update_banner_style(self, color_index):
|
||||
"""更新横幅颜色样式"""
|
||||
if not self.promo_banner:
|
||||
return
|
||||
|
||||
# 定义多组渐变颜色方案(呼吸效果)
|
||||
color_schemes = [
|
||||
# 紫色(原色)
|
||||
{
|
||||
'normal': ('667eea', '764ba2'),
|
||||
'hover': ('778ff5', '865cb3')
|
||||
},
|
||||
# 深紫色(变暗)
|
||||
{
|
||||
'normal': ('5a6dc8', '6a3f8f'),
|
||||
'hover': ('6b7ed9', '7b50a0')
|
||||
},
|
||||
# 亮紫色(变亮)
|
||||
{
|
||||
'normal': ('7890fc', '8658b4'),
|
||||
'hover': ('89a1ff', '9769c5')
|
||||
},
|
||||
# 紫色(原色)- 循环
|
||||
{
|
||||
'normal': ('667eea', '764ba2'),
|
||||
'hover': ('778ff5', '865cb3')
|
||||
}
|
||||
]
|
||||
|
||||
scheme = color_schemes[color_index % len(color_schemes)]
|
||||
|
||||
style = f"""
|
||||
QFrame#promoBanner {{
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #{scheme['normal'][0]},
|
||||
stop:1 #{scheme['normal'][1]}
|
||||
);
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}}
|
||||
QFrame#promoBanner:hover {{
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #{scheme['hover'][0]},
|
||||
stop:1 #{scheme['hover'][1]}
|
||||
);
|
||||
}}
|
||||
"""
|
||||
|
||||
self.promo_banner.setStyleSheet(style)
|
||||
|
||||
def start_banner_animation(self):
|
||||
"""启动横幅呼吸动画"""
|
||||
try:
|
||||
# 创建定时器,每2秒切换一次颜色
|
||||
self.banner_animation = QTimer(self)
|
||||
self.banner_animation.timeout.connect(self.animate_banner_color)
|
||||
self.banner_animation.start(2000) # 2秒间隔
|
||||
|
||||
print("[INFO] 横幅呼吸动画已启动")
|
||||
except Exception as e:
|
||||
print(f"[WARNING] 启动横幅动画失败: {e}")
|
||||
|
||||
def animate_banner_color(self):
|
||||
"""动画:循环改变横幅颜色"""
|
||||
try:
|
||||
self.banner_color_index = (self.banner_color_index + 1) % 4
|
||||
self.update_banner_style(self.banner_color_index)
|
||||
except Exception as e:
|
||||
print(f"[WARNING] 横幅颜色动画失败: {e}")
|
||||
# 横幅颜色动画相关方法已移除(改用图片横幅)
|
||||
|
||||
def apply_modern_styles(self):
|
||||
"""应用现代化简约样式 - 精致美化版"""
|
||||
@@ -779,11 +806,6 @@ class LoginWindow(QMainWindow):
|
||||
"""真正退出应用程序"""
|
||||
print("[INFO] 正在退出应用程序...")
|
||||
|
||||
# 停止横幅动画
|
||||
if hasattr(self, 'banner_animation') and self.banner_animation:
|
||||
self.banner_animation.stop()
|
||||
print("[INFO] 横幅动画已停止")
|
||||
|
||||
# 执行原来的关闭逻辑
|
||||
try:
|
||||
# 使用 WebSocket 管理器断开所有连接
|
||||
|
||||
Reference in New Issue
Block a user