diff --git a/publish/changeLog.md b/publish/changeLog.md index 01d3dbda..fcc44958 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -2,7 +2,7 @@ - 新增「设置 → 其他设置 → 主窗口使用软件内置的圆角及阴影」选项(#2360) *默认启用,关闭后将使用系统原生的窗口样式,该选项重启软件后生效* -- 开放 API 新增播放器声音大小、静音、播放进度控制,详情看接入文档(#2386) +- 开放 API 新增播放器声音大小、静音、播放进度控制、完整歌词获取,详情看接入文档(#2386) - 新增「设置 → 播放设置 → 调换歌词翻译与歌词罗马音位置」选项,默认关闭(#2451) - 新增启动参数 `-hidden`,在启动时将软件最小化到系统托盘(#2459) - 新增 Any Listen 歌词标签数据读取与播放(#2485) diff --git a/src/common/types/player.d.ts b/src/common/types/player.d.ts index 754f1bbe..81e4b428 100644 --- a/src/common/types/player.d.ts +++ b/src/common/types/player.d.ts @@ -31,6 +31,9 @@ declare namespace LX { lyricLineText: string lyricLineAllText: string lyric: string + tlyric: string + rlyric: string + lxlyric: string collect: boolean volume: number mute: boolean diff --git a/src/main/app.ts b/src/main/app.ts index 44c892cf..815a5001 100644 --- a/src/main/app.ts +++ b/src/main/app.ts @@ -64,6 +64,9 @@ export const initGlobalData = () => { lyricLineText: '', lyricLineAllText: '', lyric: '', + tlyric: '', + rlyric: '', + lxlyric: '', collect: false, volume: 0, mute: false, diff --git a/src/main/modules/openApi/index.ts b/src/main/modules/openApi/index.ts index 5475c0bb..866da4a4 100644 --- a/src/main/modules/openApi/index.ts +++ b/src/main/modules/openApi/index.ts @@ -52,6 +52,15 @@ const handleSendStatus = (res: http.ServerResponse, query? for (const k of keys) resp[k] = global.lx.player_status[k] sendResponse(res, 200, resp, 'application/json; charset=utf-8') } +const handleSendAllLyric = (res: http.ServerResponse) => { + const resp: Partial> = { + lyric: global.lx.player_status.lyric, + tlyric: global.lx.player_status.tlyric, + rlyric: global.lx.player_status.rlyric, + lxlyric: global.lx.player_status.lxlyric, + } + sendResponse(res, 200, resp, 'application/json; charset=utf-8') +} const handleSubscribePlayerStatus = (req: http.IncomingMessage, res: http.ServerResponse, query?: string) => { res.writeHead(200, { 'Content-Type': 'text/event-stream', @@ -130,6 +139,9 @@ const handleStartServer = async(port: number, ip: string) => new Promise(( case '/lyric': msg = global.lx.player_status.lyric break + case '/lyric-all': + handleSendAllLyric(res) + return case '/play': sendTaskbarButtonClick('play') break diff --git a/src/renderer/core/useApp/usePlayer/usePlayStatus.ts b/src/renderer/core/useApp/usePlayer/usePlayStatus.ts index e40a408c..73b9d250 100644 --- a/src/renderer/core/useApp/usePlayer/usePlayStatus.ts +++ b/src/renderer/core/useApp/usePlayer/usePlayStatus.ts @@ -52,6 +52,9 @@ export default () => { const handleSetLyric = () => { sendPlayerStatus({ lyric: musicInfo.lrc ?? '', + tlyric: musicInfo.tlrc ?? '', + rlyric: musicInfo.rlrc ?? '', + lxlyric: musicInfo.lxlrc ?? '', lyricLineText: '', lyricLineAllText: '', }) @@ -188,6 +191,9 @@ export default () => { playbackRate: appSetting['player.playbackRate'], picUrl: musicInfo.pic ?? '', lyric: musicInfo.lrc ?? '', + tlyric: musicInfo.tlrc ?? '', + rlyric: musicInfo.rlrc ?? '', + lxlyric: musicInfo.lxlrc ?? '', }) } }