| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <el-row id="manage-page-body">
- <el-col :span="3">
- <el-menu background-color="#f8f9fb" default-active="1" style="position: fixed;"
- @select="handleSelect">
- <el-menu-item index="0">
- <el-icon>
- <Back/>
- </el-icon>
- <span style="padding-left: 20px">返回首页</span>
- </el-menu-item>
- <el-menu-item index="1">
- <el-icon>
- <Document/>
- </el-icon>
- <span style="padding-left: 20px">全部课程</span>
- </el-menu-item>
- </el-menu>
- </el-col>
- <el-col :span="1"/>
- <el-col :span="18">
- <div class="pdf-reader">
- <pdf-viewer></pdf-viewer>
- <pointer-canvas ref="pointerCanvas" :no-pointer="!pointer" :no-box="!box"></pointer-canvas>
- <div class="pointer-actions">
- <c-button text :theme="pointer ? 'red' : ''" @click="pointer = !pointer">
- <i class="el-icon-edit"/> 指针</c-button>
- <c-button text :left="8" :theme="box ? 'blue' : ''" @click="box = !box">
- <i class="el-icon-crop"/> 框选</c-button>
- <c-button text :left="8" theme="orange" @click="cleanCanvas">
- <i class="el-icon-refresh-left"/> 清除</c-button>
- </div>
- </div>
- </el-col>
- </el-row>
- </template>
- <script>
- import PdfViewer from "@/components/PDF/PdfViewer";
- import { mapState } from "vuex";
- import {
- FOCUS_ON_INPUT,
- NEXT_PAGE,
- PREVIOUS_PAGE,
- RESET, SET_CURRENT_PAGE,
- SET_SRC,
- TOGGLE_SHOW_DISCUSSION,
- USE_FOCUS
- } from "@/store/types/pdf-types";
- import PointerCanvas from "@/components/PDF/PointerCanvas";
- import CButton from "@/components/Basic/CButton";
- export default {
- components: {CButton, PointerCanvas, PdfViewer},
- computed: {
- ...mapState({
- src: state => state.pdf.src,
- focus: state => state.pdf.focus
- })
- },
- data () {
- return {
- pointer: false,
- box: false,
- slide: {}
- };
- },
- mounted () {
- console.log("coursewarepage");
- this.$store.commit(RESET);
- let { page } = this.$route.params;
- if (page) {
- this.$store.commit(SET_CURRENT_PAGE, { currentPage: parseInt(page) });
- }
- const _slideId = this.$route.params.slideId;
- this.$apis.getSlideInfo({ slideId: _slideId }).then(res => {
- this.slide = res;
- }).catch(err => {
- //this.$setErrorMessage(err.response.data.msg)
- });
- this.$apis.getSlideUrl({ slideId: _slideId }).then(res => {
- console.log(this.$apis.getSlideUrl({ slideId: _slideId }));
- this.$store.commit(SET_SRC, { src: res });
- }).catch(err => {
- //this.$setErrorMessage('获取课件链接的过程中:' + err.response.data.msg)
- });
- window.addEventListener("keydown", this.handleKey);
- },
- beforeUnmount () {
- window.removeEventListener("keydown", this.handleKey);
- },
- methods: {
- handleSelect(index) {
- if (index === "0") {
- this.$router.push("portal");
- }
- if (index === "1") {
- document.getElementById("app").scrollIntoView({behavior: "smooth"});
- }
- },
- 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") {
- if (this.focus) {
- this.$store.commit(USE_FOCUS);
- } else {
- this.$store.commit(TOGGLE_SHOW_DISCUSSION);
- }
- return;
- }
- if (!this.showDiscussion || !this.focus) {
- switch (e.key) {
- case "ArrowDown":
- case "ArrowRight":
- case "s":
- case "d":
- case " ":
- this.$store.commit(NEXT_PAGE);
- break;
- case "ArrowUp":
- case "ArrowLeft":
- case "w":
- case "a":
- this.$store.commit(PREVIOUS_PAGE);
- break;
- case "c":
- this.cleanCanvas();
- break;
- case "q":
- case "z":
- this.$refs.pointerCanvas.undo();
- break;
- case "e":
- case "y":
- this.$refs.pointerCanvas.redo();
- break;
- case "[":
- case "b":
- this.box = !this.box;
- break;
- case "p":
- case "v":
- this.pointer = !this.pointer;
- break;
- }
- }
- },
- cleanCanvas () {
- this.$refs.pointerCanvas.cleanCanvas();
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .pdf-reader {
- display: flex;
- align-items: center;
- justify-content: center;
- min-height: 100vh;
- }
- .icon-button {
- z-index: 2;
- position: absolute;
- left: 16px;
- top: 16px;
- background-color: rgba(218, 234, 250, 0.4);
- backdrop-filter: saturate(150%) blur(20px);
- &:hover {
- background-color: rgba(218, 234, 250, 0.67);
- }
- }
- .show-discussion, .hide-discussion {
- transition: .2s;
- }
- .hide-discussion {
- transform: translateY(100%);
- opacity: 0;
- }
- .pointer-actions {
- position: fixed;
- left: 6px;
- bottom: 8px;
- .c-button {
- background-color: white;
- }
- }
- </style>
|