移除多余代码

pull/733/head
lyswhut 2021-12-14 20:02:39 +08:00
parent 26369dd14b
commit 583e8c43d6
2 changed files with 3 additions and 10 deletions

View File

@ -26,7 +26,7 @@ export default ({ setting }) => {
}) })
const setPlayInfo = musicInfo => { const setPlayInfo = ({ musicInfo }) => {
setDesktopLyricInfo('music_info', { setDesktopLyricInfo('music_info', {
songmid: musicInfo.songmid, songmid: musicInfo.songmid,
singer: musicInfo.singer, singer: musicInfo.singer,
@ -50,10 +50,6 @@ export default ({ setting }) => {
} }
} }
const handleSetPlayInfo = ({ musicInfo }) => {
setPlayInfo(musicInfo)
}
const handlePlay = () => { const handlePlay = () => {
if (!musicInfo.lrc) return if (!musicInfo.lrc) return
const currentTime = getCurrentTime() * 1000 const currentTime = getCurrentTime() * 1000
@ -104,22 +100,20 @@ export default ({ setting }) => {
}) })
window.eventHub.on(player.setPlay, setPlayInfo)
window.eventHub.on(player.play, handlePlay) window.eventHub.on(player.play, handlePlay)
window.eventHub.on(player.pause, handlePause) window.eventHub.on(player.pause, handlePause)
window.eventHub.on(player.stop, handleStop) window.eventHub.on(player.stop, handleStop)
window.eventHub.on(player.error, handlePause) window.eventHub.on(player.error, handlePause)
window.eventHub.on(player.setPlayInfo, handleSetPlayInfo) window.eventHub.on(player.setPlayInfo, setPlayInfo)
window.eventHub.on(player.updateLyric, setLyric) window.eventHub.on(player.updateLyric, setLyric)
onBeforeUnmount(() => { onBeforeUnmount(() => {
rGetDesktopLyricInfo() rGetDesktopLyricInfo()
window.eventHub.off(player.setPlay, setPlayInfo)
window.eventHub.off(player.play, handlePlay) window.eventHub.off(player.play, handlePlay)
window.eventHub.off(player.pause, handlePause) window.eventHub.off(player.pause, handlePause)
window.eventHub.off(player.stop, handleStop) window.eventHub.off(player.stop, handleStop)
window.eventHub.off(player.error, handlePause) window.eventHub.off(player.error, handlePause)
window.eventHub.off(player.setPlayInfo, handleSetPlayInfo) window.eventHub.off(player.setPlayInfo, setPlayInfo)
window.eventHub.off(player.updateLyric, setLyric) window.eventHub.off(player.updateLyric, setLyric)
}) })
} }

View File

@ -15,7 +15,6 @@ const names = {
setTogglePlay: 'setTogglePlay', setTogglePlay: 'setTogglePlay',
setProgress: 'setProgress', setProgress: 'setProgress',
play: 'play', play: 'play',
setPlay: 'setPlay',
pause: 'pause', pause: 'pause',
setPause: 'setPause', setPause: 'setPause',
stop: 'stop', stop: 'stop',