Repository navigation
Conversation
Member
Author
插件实现功能正常,将继续以插件形式开发,本 PR 将关闭。 Edit:插件已发布 SPlayerLRC-In-ClassIsland |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

背景
SPlayer-Next 当前已具备桌面歌词、灵动岛、任务栏歌词等"本应用内"的歌词展示能力,但无法将歌词推送到班级大屏课表软件 ClassIsland 主界面。
ClassIsland 生态已有成熟的 LyricsIsland 协议:
http://127.0.0.1:50063/本 PR 让 SPlayer-Next 作为该协议的客户端,复用 ClassIsland 主界面这一展示位,扩大应用的使用场景。
改动内容
新增
electron/main/services/lyricsIsland.ts:LyricsIsland 协议客户端核心服务nowPlaying的track-change/lyric-change/lyric-offset-change/position-sync事件修改
shared/types/settings.ts:新增LyricsIslandSettings接口,SystemConfig新增lyricsIsland字段shared/defaults/settings.ts:新增lyricsIsland默认值(enabled: false、port: 50063、showTranslation: true、showNextLine: true)electron/main/services/nowPlaying.ts:onTrackChange/onLyricChange/onPositionSync/onLyricOffsetChange四个订阅方法改为返回取消订阅函数(便于服务清理资源)electron/main/utils/logger.ts:新增lyricsIslandLogscoped loggerelectron/main/core/index.ts:app.whenReady中调用initLyricsIsland(),before-quit中调用disposeLyricsIsland()src/settings/categories/externalLyric.ts:新增"ClassIsland 联动"section(带 Beta 标签),含总开关与三个子项src/i18n/locales/zh-CN.json/en-US.json:新增中英文文案实现细节
协议一致性
POST /component/lyrics/lyrics/(与 ExtraIslandLyricsIslandLyricsProvider.cs一致){ "lyric": "<主歌词>", "extra": "<次级歌词>" }50063(与 ExtraIsland、LyricsIslandBNCMbase.js一致)lyric.js行为一致)配置变更即时生效
服务在事件回调中实时读取
store.get("lyricsIsland.enabled")等配置,用户在设置页切换开关后无需重启应用即可生效。歌词行定位逻辑
position + lyricOffsetMs作为查找时间(支持用户调整的歌词偏移)LyricLine[]找到startTime <= time的最大索引行节流策略
position-sync频率约 5Hz,但只在歌词行索引变化时发 HTTP 请求使用说明
可选配置:
测试验证
pnpm typecheck:node通过pnpm typecheck:web通过pnpm lint通过pnpm dev构建启动成功设计决策
为什么放在主进程?
nowPlaying服务在主进程,可直接订阅其 EventEmitter,无 IPC 开销lastfm、externalApi等主进程服务架构一致store读取,无需额外 IPC为什么不用现有的外部 API(HTTP+WS)服务器?
外部 API 是"被动响应外部请求",而 LyricsIsland 需要"主动推送"给 ClassIsland。两者方向相反,且外部 API 默认关闭、端口可配,不适合作为 LyricsIsland 的载体。
Edit