mirror of
https://github.com/imsyy/SPlayer.git
synced 2026-04-25 06:55:57 +03:00
[PR #890] [MERGED] 🦄refactor(mac/tray/lyric): 重构 macOS 状态栏歌词功能,解决多项显示与交互问题,全面提升稳定性与用户体验 #709
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/imsyy/SPlayer/pull/890
Author: @Pissofdvpe
Created: 2/15/2026
Status: ✅ Merged
Merged: 2/16/2026
Merged by: @imsyy
Base:
dev← Head:dev📝 Commits (3)
8fd0112🦄refactor(mac/tray/lyric): 重构 macOS 状态栏歌词功能,解决多项显示与交互问题,全面提升稳定性与用户体验f0968b1🐞fix(mac/tray/lyric): 修复审查b221f24🦄refactor(mac/ipc,mac/tray): 优化 macOS 状态栏歌词和托盘菜单的 store 访问逻辑📊 Changes
3 files changed (+72 additions, -76 deletions)
View changed files
📝
electron/main/ipc/ipc-mac-statusbar.ts(+51 -36)📝
electron/main/ipc/ipc-tray.ts(+12 -15)📝
electron/main/tray/index.ts(+9 -25)📄 Description
本次提交对 macOS 状态栏歌词功能进行了深度优化与结构性重构,旨在全面提升其稳定性、响应速度、用户体验及代码可维护性,修复了系列显示与交互问题:
核心重构与优化:
统一状态管理,消除功能切换的竞态条件:
store.get("macos.statusBarLyric.enabled")直接在关键逻辑点查询最新状态。Store管理,取代了此前分散且易导致不一致的局部变量。明确模块职责边界,消除 UI 渲染冲突:
electron/main/tray/index.ts中冗余的setMacStatusBarLyricShow和setMacStatusBarLyricTitle方法,并通过ipc-tray.ts导出getCurrentSongTitle。ipc-mac-statusbar.ts在歌词功能关闭时直接调用tray?.setTitle(getCurrentSongTitle())。增强歌词显示与更新机制,优化平滑度与精确性:
updateMacStatusBarLyric函数中添加forceUpdate参数和isMacosLyricEnabled检查,并将歌词更新的权威触发点统一到TASKBAR_IPC_CHANNELS.SYNC_TICK事件处理器。updateMacStatusBarLyric的forceUpdate参数,并优化了歌词在启动和进度拖动时的更新策略。改进托盘菜单 UI 同步,提升交互一致性:
macos-lyric:toggle事件处理器中调用(tray as any)?.initTrayMenu()来强制刷新托盘菜单,并修改createTrayMenu直接从Store读取状态。提升代码健壮性与可维护性:
MainTray接口中添加initTrayMenu(): void声明;将CreateTray类中的initTrayMenu方法改为public。electron/main/index.ts中不再使用的ipcMain和useStore导入。electron/main/ipc/ipc-mac-statusbar.ts中的歌词和 IPC payload 类型,使其与@applemusic-like-lyrics/lyric和@shared模块保持一致。本次重构全面提升了 macOS 状态栏歌词功能的内部机制,带来了更稳定、更流畅、更符合预期的用户体验。
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.