新增完整歌词相关字段和API支持
This commit is contained in:
Vendored
+3
@@ -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
|
||||
|
||||
@@ -64,6 +64,9 @@ export const initGlobalData = () => {
|
||||
lyricLineText: '',
|
||||
lyricLineAllText: '',
|
||||
lyric: '',
|
||||
tlyric: '',
|
||||
rlyric: '',
|
||||
lxlyric: '',
|
||||
collect: false,
|
||||
volume: 0,
|
||||
mute: false,
|
||||
|
||||
@@ -52,6 +52,15 @@ const handleSendStatus = (res: http.ServerResponse<http.IncomingMessage>, 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<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) => {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/event-stream',
|
||||
@@ -130,6 +139,9 @@ const handleStartServer = async(port: number, ip: string) => new Promise<void>((
|
||||
case '/lyric':
|
||||
msg = global.lx.player_status.lyric
|
||||
break
|
||||
case '/lyric-all':
|
||||
handleSendAllLyric(res)
|
||||
return
|
||||
case '/play':
|
||||
sendTaskbarButtonClick('play')
|
||||
break
|
||||
|
||||
@@ -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 ?? '',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user