Skip to content

Commit 9ff47c0

Browse files
author
Taois
committed
feat: 细节调整
1 parent ec8e108 commit 9ff47c0

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

dashboard/src/views/LocalBookReader.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,38 @@ const saveReadingSettings = () => {
718718
}
719719
}
720720
721+
const SCROLL_STEP = 300
722+
721723
// 键盘快捷键
722724
const handleKeydown = (event) => {
725+
const target = event.target
726+
const isInputFocused = target instanceof HTMLElement && ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName)
727+
723728
switch (event.key) {
729+
case 'ArrowUp':
730+
if (isInputFocused) return
731+
event.preventDefault()
732+
if (contentRef.value) {
733+
contentRef.value.scrollBy({ top: -SCROLL_STEP, behavior: 'smooth' })
734+
}
735+
break
736+
case 'ArrowDown':
737+
if (isInputFocused) return
738+
event.preventDefault()
739+
if (contentRef.value) {
740+
contentRef.value.scrollBy({ top: SCROLL_STEP, behavior: 'smooth' })
741+
}
742+
break
743+
case 'ArrowLeft':
744+
if (isInputFocused) return
745+
event.preventDefault()
746+
handlePrevChapter()
747+
break
748+
case 'ArrowRight':
749+
if (isInputFocused) return
750+
event.preventDefault()
751+
handleNextChapter()
752+
break
724753
case 'Escape':
725754
event.preventDefault()
726755
if (showChapterPanel.value) {

0 commit comments

Comments
 (0)