Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions .github/workflows/build-unified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,18 @@ jobs:
# Windows PyInstaller 构建
- name: 运行 Windows PyInstaller 构建
if: |
matrix.platform == 'windows' &&
matrix.packager == 'pyinstaller' &&
(github.event_name != 'workflow_dispatch' ||
matrix.platform == 'windows' &&
matrix.packager == 'pyinstaller' &&
(github.event_name != 'workflow_dispatch' ||
(inputs.build_target == 'all' || inputs.build_target == 'windows') &&
(inputs.packager == 'pyinstaller' || inputs.packager == 'both')) &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_dispatch' ||
(contains(github.event.head_commit.message, '打包') ||
contains(github.event.head_commit.message, 'pi') ||
contains(github.event.head_commit.message, 'both') ||
contains(github.event.head_commit.message, 'all') ||
contains(github.event.head_commit.message, 'win'))) &&
(github.event_name != 'push' ||
(github.event_name != 'push' ||
!startsWith(github.ref, 'refs/tags/v') ||
(startsWith(github.ref_name, 'v') && contains(github.ref_name, '.') && !contains(github.ref_name, '-')))
run: |
Expand All @@ -210,18 +210,18 @@ jobs:
# Windows Nuitka 构建
- name: 运行 Windows Nuitka 构建
if: |
matrix.platform == 'windows' &&
matrix.packager == 'nuitka' &&
(github.event_name != 'workflow_dispatch' ||
matrix.platform == 'windows' &&
matrix.packager == 'nuitka' &&
(github.event_name != 'workflow_dispatch' ||
(inputs.build_target == 'all' || inputs.build_target == 'windows') &&
(inputs.packager == 'nuitka' || inputs.packager == 'both')) &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_dispatch' ||
(contains(github.event.head_commit.message, '打包') ||
contains(github.event.head_commit.message, 'nk') ||
contains(github.event.head_commit.message, 'both') ||
contains(github.event.head_commit.message, 'all') ||
contains(github.event.head_commit.message, 'win'))) &&
(github.event_name != 'push' ||
(github.event_name != 'push' ||
!startsWith(github.ref, 'refs/tags/v') ||
(startsWith(github.ref_name, 'v') && contains(github.ref_name, '.') && !contains(github.ref_name, '-')))
run: |
Expand All @@ -234,18 +234,18 @@ jobs:
# Linux 构建
- name: 运行 Linux 构建
if: |
matrix.platform == 'linux' &&
matrix.packager == 'pyinstaller' &&
(github.event_name != 'workflow_dispatch' ||
matrix.platform == 'linux' &&
matrix.packager == 'pyinstaller' &&
(github.event_name != 'workflow_dispatch' ||
(inputs.build_target == 'all' || inputs.build_target == 'linux') &&
(inputs.packager == 'pyinstaller' || inputs.packager == 'both')) &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_dispatch' ||
(contains(github.event.head_commit.message, '打包') ||
contains(github.event.head_commit.message, 'pi') ||
contains(github.event.head_commit.message, 'both') ||
contains(github.event.head_commit.message, 'all') ||
contains(github.event.head_commit.message, 'linux'))) &&
(github.event_name != 'push' ||
(github.event_name != 'push' ||
!startsWith(github.ref, 'refs/tags/v') ||
(startsWith(github.ref_name, 'v') && contains(github.ref_name, '.') && !contains(github.ref_name, '-')))
run: |
Expand All @@ -258,7 +258,7 @@ jobs:
# Windows 打包操作
- name: Windows 打包操作
if: |
matrix.platform == 'windows' &&
matrix.platform == 'windows' &&
(github.event_name != 'workflow_dispatch' || inputs.package == 'true')
run: |
echo "开始 Windows 打包操作..."
Expand Down Expand Up @@ -303,7 +303,7 @@ jobs:
# Linux 打包操作
- name: Linux 打包操作
if: |
matrix.platform == 'linux' &&
matrix.platform == 'linux' &&
(github.event_name != 'workflow_dispatch' || inputs.package == 'true')
run: |
echo "开始 Linux 打包操作..."
Expand Down Expand Up @@ -344,7 +344,7 @@ jobs:

- name: 上传应用程序
if: |
github.event_name != 'pull_request' &&
github.event_name != 'pull_request' &&
(github.event_name != 'workflow_dispatch' || inputs.package == 'true')
uses: actions/upload-artifact@v4.4.2
with:
Expand All @@ -355,9 +355,9 @@ jobs:
release:
needs: [builder_matrix]
if: |
(startsWith(github.ref, 'refs/tags/v') &&
(startsWith(github.ref, 'refs/tags/v') &&
contains(github.ref_name, '.') && !contains(github.ref_name, '-') &&
(github.event_name != 'workflow_dispatch' || inputs.release == 'true')) ||
(github.event_name != 'workflow_dispatch' || inputs.release == 'true')) ||
(github.event_name == 'workflow_dispatch' && inputs.release == 'true')
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -501,4 +501,4 @@ jobs:
name: SecRandom 新版本 - ${{ github.ref_name }}
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159 changes: 153 additions & 6 deletions app/common/notification/notification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,39 @@ def update_content(self, widgets):
self.layout.addWidget(widget)
self.content_widgets.append(widget)

# 确保新添加的 BodyLabel 可见:根据主题强制设置前景色
try:
from app.tools.personalised import is_dark_theme
from qfluentwidgets import qconfig
from qfluentwidgets import BodyLabel as QFBodyLabel

fg = "#ffffff" if is_dark_theme(qconfig) else "#000000"

def apply_fg_to(w):
# 如果是直接的 BodyLabel,设置样式
if isinstance(w, QFBodyLabel):
existing = w.styleSheet() or ""
if "color:" not in existing:
# 保留已有样式,追加颜色
w.setStyleSheet(existing + f" color: {fg};")
else:
# 遍历子控件查找 BodyLabel
for child in w.findChildren(QFBodyLabel):
existing = child.styleSheet() or ""
if "color:" not in existing:
child.setStyleSheet(existing + f" color: {fg};")

for w in self.content_widgets:
try:
apply_fg_to(w)
except Exception as e:
from loguru import logger

logger.exception("Error applying fg to content widget: {}", e)
except Exception:
# 忽略主题检测错误,保持原样
pass


class NotificationWindowTemplate(PageTemplate):
"""通知窗口页面模板"""
Expand Down Expand Up @@ -69,6 +102,16 @@ def __init__(self, parent=None):
# 设置UI
self.setup_ui()

# 订阅主题变化,确保切换主题时更新文字颜色
try:
from qfluentwidgets import qconfig

qconfig.themeChanged.connect(self._on_theme_changed)
except Exception as e:
from loguru import logger

logger.exception("Error connecting themeChanged signal (ignored): {}", e)

# 设置窗口圆角
self.setBorderRadius(15)

Expand Down Expand Up @@ -198,7 +241,10 @@ def update_background_style(self):
)
self.update_drag_line_style()
self.update_drag_line_container_style()
except:
except Exception as e:
from loguru import logger

logger.exception("Error updating background style (fallback used): {}", e)
# 如果无法获取主题信息,默认使用白色背景和深色拖动线
background_color = "#ffffff"
self.background_widget.setStyleSheet(
Expand Down Expand Up @@ -227,7 +273,12 @@ def update_drag_line_container_style(self):
self.drag_line_container.setStyleSheet(
f"background-color: {background_color}; border-top-left-radius: 15px; border-top-right-radius: 15px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px;"
)
except:
except Exception as e:
from loguru import logger

logger.exception(
"Error updating drag line container style (fallback used): {}", e
)
# 如果无法获取主题信息,默认使用白色背景
self.drag_line_container.setStyleSheet(
"background-color: #ffffff; border-top-left-radius: 15px; border-top-right-radius: 15px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px;"
Expand Down Expand Up @@ -258,6 +309,20 @@ def apply_settings(self, settings=None):
# 设置透明度(背景和字体透明度统一)
self.setWindowOpacity(transparency)

# 设置倒计时标签颜色,确保与背景对比
try:
from app.tools.personalised import is_dark_theme
from qfluentwidgets import qconfig

fg = "#ffffff" if is_dark_theme(qconfig) else "#000000"
existing = self.countdown_label.styleSheet() or ""
if "color:" not in existing:
self.countdown_label.setStyleSheet(existing + f" color: {fg};")
except Exception as e:
from loguru import logger

logger.exception("Error setting countdown label color: {}", e)

# 根据设置定位窗口
self.position_window(settings)

Expand Down Expand Up @@ -287,6 +352,69 @@ def update_countdown_display(self):
self.countdown_timer.stop()
self.countdown_label.setText("连续点击3次关闭窗口")

def _on_theme_changed(self):
"""主题切换时更新浮窗内文字和背景颜色"""
try:
from app.tools.personalised import is_dark_theme
from qfluentwidgets import qconfig

fg = "#ffffff" if is_dark_theme(qconfig) else "#000000"

# 更新所有 BodyLabel 子控件颜色
for lbl in self.findChildren(BodyLabel):
try:
existing = lbl.styleSheet() or ""
parts = [
p.strip()
for p in existing.split(";")
if p.strip() and not p.strip().startswith("color:")
]
parts.append(f"color: {fg} !important")
lbl.setStyleSheet("; ".join(parts) + ";")
except Exception as e:
from loguru import logger

logger.exception(
"Error applying color to label child (continuing): {}", e
)
continue

# 更新倒计时标签颜色
try:
existing = self.countdown_label.styleSheet() or ""
parts = [
p.strip()
for p in existing.split(";")
if p.strip() and not p.strip().startswith("color:")
]
parts.append(f"color: {fg} !important")
self.countdown_label.setStyleSheet("; ".join(parts) + ";")
except Exception as e:
from loguru import logger

logger.exception(
"Error applying countdown label color (ignored): {}", e
)
pass

# 更新背景与拖动线样式
try:
self.update_background_style()
self.update_drag_line_style()
self.update_drag_line_container_style()
except Exception as e:
from loguru import logger

logger.exception(
"Error updating background/drag line styles (ignored): {}", e
)
pass
except Exception as e:
from loguru import logger

logger.exception("Error in _on_theme_changed (ignored): {}", e)
pass

def _get_screen_from_settings(self, settings):
"""根据设置获取屏幕"""
screen = QApplication.primaryScreen()
Expand Down Expand Up @@ -540,6 +668,13 @@ def start_show_animation(self, settings=None):

# 立即更新倒计时显示(显示"正在抽取中")
self.update_countdown_display()
# 确保颜色与当前主题同步
try:
self._on_theme_changed()
except Exception as e:
from loguru import logger

logger.exception("Error syncing theme on show (ignored): {}", e)

def on_animation_finished(self):
"""动画完成后的处理"""
Expand All @@ -561,9 +696,10 @@ def on_animation_finished(self):
try:
if not (self.windowFlags() & Qt.WindowDoesNotAcceptFocus):
self.activateWindow()
except Exception:
# 保险兜底:如果出现问题则不激活窗口
pass
except Exception as e:
from loguru import logger

logger.exception("Error activating window (ignored): {}", e)

# 更新倒计时显示
self.update_countdown_display()
Expand Down Expand Up @@ -616,6 +752,14 @@ def update_content(self, student_labels, settings=None):
for label in student_labels:
self.content_layout.addWidget(label)

# 确保颜色与当前主题同步
try:
self._on_theme_changed()
except Exception as e:
from loguru import logger

logger.exception("Error syncing theme on update_content (ignored): {}", e)

# 调整窗口大小以适应内容
self.adjustSize()

Expand Down Expand Up @@ -673,7 +817,10 @@ def get_notification_title(self):
return get_content_name_async(
"notification_settings", "notification_result"
)
except:
except Exception as e:
from loguru import logger

logger.exception("Error getting notification title (fallback used): {}", e)
# 如果无法获取多语言文本,则使用默认文本
return "通知结果"

Expand Down
13 changes: 9 additions & 4 deletions app/page_building/page_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from PySide6.QtGui import *
from PySide6.QtCore import *
from PySide6.QtNetwork import *
import loguru
from qfluentwidgets import *

from app.tools.variable import *
Expand Down Expand Up @@ -108,10 +109,12 @@ def create_content(self):
self.content_created = True

elapsed = time.perf_counter() - start
logger.debug(f"创建内容组件 {content_name} 耗时: {elapsed:.3f}s")
loguru.logger.debug(f"创建内容组件 {content_name} 耗时: {elapsed:.3f}s")
except Exception as e:
elapsed = time.perf_counter() - start
logger.error(f"创建内容组件失败 ({elapsed:.3f}s): {e}")
from loguru import logger

logger.exception(f"创建内容组件失败 ({elapsed:.3f}s): {e}")

def create_empty_content(self, message="该页面正在开发中,敬请期待!"):
"""创建空页面内容"""
Expand Down Expand Up @@ -437,8 +440,10 @@ def load_all_pages(self, interval_ms: int = 50, max_per_tick: int = 5):
]
),
)
except Exception:
pass
except Exception as e:
from loguru import logger

logger.exception("Error scheduling batch page loads (ignored): {}", e)

def on_current_index_changed(self, index: int):
"""堆叠窗口索引改变时的处理"""
Expand Down
8 changes: 7 additions & 1 deletion app/page_building/window_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@ def _apply_current_theme(self) -> None:
self.default_page.setStyleSheet(
"background-color: transparent;"
)
except:
except Exception as e:
from loguru import logger

logger.exception(
"Error detecting dark mode with darkdetect (fallback to light): {}",
e,
)
# 如果检测失败,使用浅色主题
self.setStyleSheet("background-color: #ffffff;")
self.default_page.setStyleSheet("background-color: transparent;")
Expand Down
Loading
Loading