为播放详情页歌词选择界面添加全选快捷键支持

pull/1761/head
lyswhut 2023-12-08 16:34:33 +08:00
parent f40f019d2e
commit 98b4abfa19
2 changed files with 28 additions and 1 deletions

View File

@ -25,7 +25,7 @@
</div>
</transition>
<transition enter-active-class="animated fadeIn" leave-active-class="animated fadeOut">
<div v-if="isShowLrcSelectContent" :class="[$style.lyricSelectContent, 'select', 'scroll', 'lyricSelectContent']" @contextmenu="handleCopySelectText">
<div v-if="isShowLrcSelectContent" ref="dom_lrc_select_content" tabindex="-1" :class="[$style.lyricSelectContent, 'select', 'scroll', 'lyricSelectContent']" @contextmenu="handleCopySelectText">
<div v-for="(info, index) in lyric.lines" :key="index" :class="[$style.lyricSelectline, { [$style.lrcActive]: lyric.line == index }]">
<span>{{ info.text }}</span>
<template v-for="(lrc, i) in info.extendedLyrics" :key="i">
@ -59,6 +59,7 @@ import useLyric from '@renderer/utils/compositions/useLyric'
import LyricMenu from './components/LyricMenu.vue'
import { appSetting } from '@renderer/store/setting'
import { setLyricOffset } from '@renderer/core/lyric'
import useSelectAllLrc from './useSelectAllLrc'
export default {
components: {
@ -83,6 +84,8 @@ export default {
handleScrollLrc,
} = useLyric({ isPlay, lyric, playProgress, isShowLyricProgressSetting })
const dom_lrc_select_content = useSelectAllLrc()
watch([isFullscreen, isShowPlayComment], () => {
setTimeout(handleScrollLrc, 400)
})
@ -154,6 +157,7 @@ export default {
dom_lyric,
dom_lyric_text,
dom_skip_line,
dom_lrc_select_content,
isMsDown,
timeStr,
handleLyricMouseDown,

View File

@ -0,0 +1,23 @@
import { ref, onBeforeUnmount } from '@common/utils/vueTools'
export default () => {
const dom_lrc_select_content = ref()
const handle_key_mod_a_down = ({ event }) => {
if (event.target.tagName == 'INPUT' || !dom_lrc_select_content.value || document.activeElement != dom_lrc_select_content.value) return
event.preventDefault()
if (event.repeat) return
let selection = window.getSelection()
let range = document.createRange()
range.selectNodeContents(dom_lrc_select_content.value)
selection.removeAllRanges()
selection.addRange(range)
}
onBeforeUnmount(() => {
window.key_event.off('key_mod+a_down', handle_key_mod_a_down)
})
window.key_event.on('key_mod+a_down', handle_key_mod_a_down)
return dom_lrc_select_content
}