Ver código fonte

improvement: 优化快捷键体验

ChenYangfan 6 anos atrás
pai
commit
534a7e74bf
1 arquivos alterados com 15 adições e 2 exclusões
  1. 15 2
      src/views/reader/PdfReader.vue

+ 15 - 2
src/views/reader/PdfReader.vue

@@ -14,7 +14,15 @@ import PdfViewer from '@/components/PDF/PdfViewer'
 import { mapState } from 'vuex'
 import DiscussionArea from '@/components/Discussion/DiscussionArea'
 import { getSlideInfo, getSlideUrl } from '@/server/slide'
-import { FOCUS_ON_INPUT, NEXT_PAGE, PREVIOUS_PAGE, RESET, SET_SRC, USE_FOCUS } from '@/store/types/pdf-types'
+import {
+  FOCUS_ON_INPUT,
+  NEXT_PAGE,
+  PREVIOUS_PAGE,
+  RESET,
+  SET_SRC,
+  TOGGLE_SHOW_DISCUSSION,
+  USE_FOCUS
+} from '@/store/types/pdf-types'
 import IconButton from '@/components/Basic/IconButton'
 
 export default {
@@ -52,11 +60,16 @@ export default {
   methods: {
     handleKey (e) {
       if (e.key === 'Enter') {
+        !this.showDiscussion && this.$store.commit(TOGGLE_SHOW_DISCUSSION)
         !this.focus && this.$store.commit(FOCUS_ON_INPUT)
         return
       }
       if (e.key === 'Escape') {
-        this.focus && this.$store.commit(USE_FOCUS)
+        if (this.focus) {
+          this.$store.commit(USE_FOCUS)
+        } else {
+          this.$store.commit(TOGGLE_SHOW_DISCUSSION)
+        }
         return
       }
       if (!this.showDiscussion || !this.focus) {