修复歌词调整时间显示问题

pull/930/merge
lyswhut 2022-04-07 09:24:09 +08:00
parent 65ae08add6
commit 6de84d3b9b
2 changed files with 16 additions and 13 deletions

View File

@ -52,6 +52,9 @@ export default {
},
setup() {
const setting = useRefGetter('setting')
const isZoomActiveLrc = computed(() => setting.value.playDetail.isZoomActiveLrc)
const isShowLyricProgressSetting = computed(() => setting.value.playDetail.isShowLyricProgressSetting)
const {
dom_lyric,
dom_lyric_text,
@ -64,7 +67,7 @@ export default {
handleSkipPlay,
handleSkipMouseEnter,
handleSkipMouseLeave,
} = useLyric({ isPlay, lyric })
} = useLyric({ isPlay, lyric, isShowLyricProgressSetting })
const lyricMenuVisible = ref(false)
const lyricMenuXY = reactive({
@ -111,8 +114,6 @@ export default {
'--playDetail-lrc-font-size': (isShowPlayComment.value ? size * 0.82 : size) + 'rem',
}
})
const isZoomActiveLrc = computed(() => setting.value.playDetail.isZoomActiveLrc)
const isShowLyricProgressSetting = computed(() => setting.value.playDetail.isShowLyricProgressSetting)
onMounted(() => {
window.eventHub.on(eventPlayerNames.updateLyric, updateMusicInfo)

View File

@ -2,7 +2,7 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from '@renderer/util
import { scrollTo, throttle, formatPlayTime2 } from '@renderer/utils'
import { player as eventPlayerNames } from '@renderer/event/names'
export default ({ isPlay, lyric }) => {
export default ({ isPlay, lyric, isShowLyricProgressSetting }) => {
const dom_lyric = ref(null)
const dom_lyric_text = ref(null)
const dom_skip_line = ref(null)
@ -40,13 +40,11 @@ export default ({ isPlay, lyric }) => {
startLyricScrollTimeout()
}
const setTime = throttle(() => {
if (point.x == null) {
const throttleSetTime = throttle(() => {
if (!dom_skip_line.value) return
const rect = dom_skip_line.value.getBoundingClientRect()
point.x = rect.x
point.y = rect.y
}
let dom = document.elementFromPoint(point.x, point.y)
if (dom_pre_line === dom) return
if (dom.tagName == 'SPAN') {
@ -70,6 +68,9 @@ export default ({ isPlay, lyric }) => {
}
dom_pre_line = dom
})
const setTime = () => {
if (isShowLyricProgressSetting.value) throttleSetTime()
}
const handleScrollLrc = (duration = 300) => {
if (!dom_lines?.length || !dom_lyric.value) return
@ -184,14 +185,15 @@ export default ({ isPlay, lyric }) => {
watch(() => lyric.line, scrollLine)
onMounted(() => {
document.addEventListener('mousemove', handleMouseMsMove)
document.addEventListener('mouseup', handleMouseMsUp)
initLrc(lyric.lines, null)
nextTick(() => {
scrollLine(lyric.line)
})
})
document.addEventListener('mousemove', handleMouseMsMove)
document.addEventListener('mouseup', handleMouseMsUp)
onBeforeUnmount(() => {
document.removeEventListener('mousemove', handleMouseMsMove)
document.removeEventListener('mouseup', handleMouseMsUp)