PdfReader.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="pdf-reader">
  3. <icon-button title="返回主页面">arrow_back</icon-button>
  4. <pdf-viewer></pdf-viewer>
  5. <discussion-area
  6. :class="showDiscussion ? 'show-discussion' : 'hide-discussion'"
  7. >
  8. </discussion-area>
  9. </div>
  10. </template>
  11. <script>
  12. import PdfViewer from '@/components/PDF/PdfViewer'
  13. import { mapState } from 'vuex'
  14. import DiscussionArea from '@/components/Discussion/DiscussionArea'
  15. import { getSlideInfo, getSlideUrl } from '@/server/slide'
  16. import { NEXT_PAGE, PREVIOUS_PAGE, RESET, SET_SRC } from '@/store/types/pdf-types'
  17. import IconButton from '@/components/Basic/IconButton'
  18. export default {
  19. components: { IconButton, DiscussionArea, PdfViewer },
  20. computed: {
  21. ...mapState({
  22. src: state => state.pdf.src,
  23. showDiscussion: state => state.pdf.showDiscussion
  24. })
  25. },
  26. data () {
  27. return {
  28. slide: {}
  29. }
  30. },
  31. mounted () {
  32. this.$store.commit(RESET)
  33. const _slideId = this.$route.params.slideId
  34. getSlideInfo({ slideId: _slideId }).then(res => {
  35. this.slide = res
  36. }).catch(err => {
  37. this.$setErrorMessage(err.response.data.msg)
  38. })
  39. getSlideUrl({ slideId: _slideId }).then(res => {
  40. this.$store.commit(SET_SRC, { src: res })
  41. }).catch(err => {
  42. this.$setErrorMessage('获取课件链接的过程中:' + err.response.data.msg)
  43. })
  44. window.addEventListener('keydown', this.handleKey)
  45. },
  46. methods: {
  47. handleKey (e) {
  48. switch (e.key) {
  49. case 'ArrowDown':
  50. case 'ArrowRight':
  51. console.log(1)
  52. this.$store.commit(NEXT_PAGE)
  53. break
  54. case 'ArrowUp':
  55. case 'ArrowLeft':
  56. this.$store.commit(PREVIOUS_PAGE)
  57. break
  58. }
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .pdf-reader {
  65. display: flex;
  66. align-items: center;
  67. justify-content: center;
  68. min-height: 100vh;
  69. }
  70. .icon-button {
  71. z-index: 2;
  72. position: absolute;
  73. left: 16px;
  74. top: 16px;
  75. background-color: rgba(218, 234, 250, 0.4);
  76. backdrop-filter: saturate(150%) blur(20px);
  77. &:hover {
  78. background-color: rgba(218, 234, 250, 0.67);
  79. }
  80. }
  81. .show-discussion, .hide-discussion {
  82. transition: .2s;
  83. }
  84. .hide-discussion {
  85. transform: translateY(100%);
  86. opacity: 0;
  87. }
  88. </style>