新增完整歌词相关字段和API支持

This commit is contained in:
lyswhut
2025-09-29 12:37:22 +08:00
parent a3b1a433c6
commit d03f93166f
5 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
- 新增「设置 → 其他设置 → 主窗口使用软件内置的圆角及阴影」选项(#2360) - 新增「设置 → 其他设置 → 主窗口使用软件内置的圆角及阴影」选项(#2360)
*默认启用,关闭后将使用系统原生的窗口样式,该选项重启软件后生效* *默认启用,关闭后将使用系统原生的窗口样式,该选项重启软件后生效*
- 开放 API 新增播放器声音大小、静音、播放进度控制,详情看接入文档(#2386) - 开放 API 新增播放器声音大小、静音、播放进度控制、完整歌词获取,详情看接入文档(#2386)
- 新增「设置 → 播放设置 → 调换歌词翻译与歌词罗马音位置」选项,默认关闭(#2451) - 新增「设置 → 播放设置 → 调换歌词翻译与歌词罗马音位置」选项,默认关闭(#2451)
- 新增启动参数 `-hidden`,在启动时将软件最小化到系统托盘(#2459) - 新增启动参数 `-hidden`,在启动时将软件最小化到系统托盘(#2459)
- 新增 Any Listen 歌词标签数据读取与播放(#2485) - 新增 Any Listen 歌词标签数据读取与播放(#2485)
+3
View File
@@ -31,6 +31,9 @@ declare namespace LX {
lyricLineText: string lyricLineText: string
lyricLineAllText: string lyricLineAllText: string
lyric: string lyric: string
tlyric: string
rlyric: string
lxlyric: string
collect: boolean collect: boolean
volume: number volume: number
mute: boolean mute: boolean
+3
View File
@@ -64,6 +64,9 @@ export const initGlobalData = () => {
lyricLineText: '', lyricLineText: '',
lyricLineAllText: '', lyricLineAllText: '',
lyric: '', lyric: '',
tlyric: '',
rlyric: '',
lxlyric: '',
collect: false, collect: false,
volume: 0, volume: 0,
mute: false, mute: false,
+12
View File
@@ -52,6 +52,15 @@ const handleSendStatus = (res: http.ServerResponse<http.IncomingMessage>, query?
for (const k of keys) resp[k] = global.lx.player_status[k] for (const k of keys) resp[k] = global.lx.player_status[k]
sendResponse(res, 200, resp, 'application/json; charset=utf-8') sendResponse(res, 200, resp, 'application/json; charset=utf-8')
} }
const handleSendAllLyric = (res: http.ServerResponse<http.IncomingMessage>) => {
const resp: Partial<Record<SubscribeKeys, any>> = {
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<http.IncomingMessage>, query?: string) => { const handleSubscribePlayerStatus = (req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage>, query?: string) => {
res.writeHead(200, { res.writeHead(200, {
'Content-Type': 'text/event-stream', 'Content-Type': 'text/event-stream',
@@ -130,6 +139,9 @@ const handleStartServer = async(port: number, ip: string) => new Promise<void>((
case '/lyric': case '/lyric':
msg = global.lx.player_status.lyric msg = global.lx.player_status.lyric
break break
case '/lyric-all':
handleSendAllLyric(res)
return
case '/play': case '/play':
sendTaskbarButtonClick('play') sendTaskbarButtonClick('play')
break break
@@ -52,6 +52,9 @@ export default () => {
const handleSetLyric = () => { const handleSetLyric = () => {
sendPlayerStatus({ sendPlayerStatus({
lyric: musicInfo.lrc ?? '', lyric: musicInfo.lrc ?? '',
tlyric: musicInfo.tlrc ?? '',
rlyric: musicInfo.rlrc ?? '',
lxlyric: musicInfo.lxlrc ?? '',
lyricLineText: '', lyricLineText: '',
lyricLineAllText: '', lyricLineAllText: '',
}) })
@@ -188,6 +191,9 @@ export default () => {
playbackRate: appSetting['player.playbackRate'], playbackRate: appSetting['player.playbackRate'],
picUrl: musicInfo.pic ?? '', picUrl: musicInfo.pic ?? '',
lyric: musicInfo.lrc ?? '', lyric: musicInfo.lrc ?? '',
tlyric: musicInfo.tlrc ?? '',
rlyric: musicInfo.rlrc ?? '',
lxlyric: musicInfo.lxlrc ?? '',
}) })
} }
} }