CourseWarePage.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <el-row id="manage-page-body">
  3. <!-- <div class="pdf-reader">-->
  4. <!-- <el-button type="info" circle @click="this.$router.go(-1)" class="mybuttton"><el-icon class="myicon"><Back /></el-icon></el-button>-->
  5. <!-- <div class="container">-->
  6. <!-- <iframe :src="pdfurl" width="100%" height="100%"></iframe>-->
  7. <!-- </div>-->
  8. <!-- <img :src="imageUrl" alt="" class="image">-->
  9. <!-- <canvas class="pdf pdf-canvas" id="pdf-canvas"></canvas>-->
  10. <!-- <pdf-viewer></pdf-viewer>-->
  11. <!-- <pointer-canvas ref="pointerCanvas" :no-pointer="!pointer" :no-box="!box"></pointer-canvas>-->
  12. <!-- <div class="pointer-actions">-->
  13. <!-- <c-button text :theme="pointer ? 'red' : ''" @click="pointer = !pointer">-->
  14. <!-- <i class="el-icon-edit"/> 指针</c-button>-->
  15. <!-- <c-button text :left="8" :theme="box ? 'blue' : ''" @click="box = !box">-->
  16. <!-- <i class="el-icon-crop"/> 框选</c-button>-->
  17. <!-- <c-button text :left="8" theme="orange" @click="cleanCanvas">-->
  18. <!-- <i class="el-icon-refresh-left"/> 清除</c-button>-->
  19. <!-- </div>-->
  20. <!-- </div>-->
  21. </el-row>
  22. </template>
  23. <script>
  24. // import PdfViewer from "@/components/PDF/PdfViewer";
  25. // import { mapState } from "vuex";
  26. // import {
  27. // FOCUS_ON_INPUT,
  28. // NEXT_PAGE,
  29. // PREVIOUS_PAGE,
  30. // RESET, SET_CURRENT_PAGE,
  31. // SET_SRC,
  32. // TOGGLE_SHOW_DISCUSSION,
  33. // USE_FOCUS
  34. // } from "@/store/types/pdf-types";
  35. // import PointerCanvas from "@/components/PDF/PointerCanvas";
  36. // import CButton from "@/components/Basic/CButton";
  37. // import { SET_TOTAL_PAGES } from "@/store/types/pdf-types";
  38. // import FadeTransition from "@/animations/FadeTransition";
  39. //
  40. // const pdfJS = require("pdfjs-dist");
  41. // pdfJS.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/build/pdf.worker.entry");
  42. //
  43. // export default {
  44. // components: {
  45. // // CButton,
  46. // // PointerCanvas,
  47. // // PdfViewer
  48. // },
  49. // computed: {
  50. // ...mapState({
  51. // src: state => state.pdf.src,
  52. // focus: state => state.pdf.focus,
  53. // currentPage: state => state.pdf.currentPage,
  54. // screenShot: state => state.pdf.screenShot,
  55. // }),
  56. // imageUrl() {
  57. // //return "https://seec-portal.oss-cn-hangzhou.aliyuncs.com/1/1bc3ed2e423eec0.jpg" + "?t=" + Date.now().valueOf();
  58. // return "https://seec-portal.oss-cn-hangzhou.aliyuncs.com/1/8610161.jpg";
  59. // },
  60. // },
  61. // data () {
  62. // return {
  63. // pdfurl:"",
  64. // courseWare: {}
  65. // };
  66. // },
  67. // watch: {
  68. // currentPage() {
  69. // this.showPage();
  70. // }
  71. // },
  72. // async mounted() {
  73. // console.log("coursewarepage");
  74. // console.log(this.$route.params.courseWareId);
  75. // this.$store.commit(RESET);
  76. // let {page} = this.$route.params.page;
  77. // if (page) {
  78. // this.$store.commit(SET_CURRENT_PAGE, {currentPage: parseInt(page)});
  79. // }
  80. // this.courseWare = (await this.$apis.getSlideInfo(this.$route.params.courseWareId)).data.data;
  81. // this.pdfurl = (await this.$apis.getSlideUrl(this.$route.params.courseWareId)).data.data;
  82. // this.$store.commit(SET_SRC, {src: this.pdfurl});
  83. // window.addEventListener("keydown", this.handleKey);
  84. //
  85. // this._canvas = document.getElementById("pdf-canvas");
  86. // this._context = this._canvas.getContext("2d");
  87. //
  88. // this.load(this.pdfurl);
  89. // },
  90. // beforeUnmount () {
  91. // window.removeEventListener("keydown", this.handleKey);
  92. // },
  93. // methods: {
  94. // handleKey (e) {
  95. // if (e.key === "Enter") {
  96. // !this.showDiscussion && this.$store.commit(TOGGLE_SHOW_DISCUSSION);
  97. // !this.focus && this.$store.commit(FOCUS_ON_INPUT);
  98. // return;
  99. // }
  100. // if (e.key === "Escape") {
  101. // if (this.focus) {
  102. // this.$store.commit(USE_FOCUS);
  103. // } else {
  104. // this.$store.commit(TOGGLE_SHOW_DISCUSSION);
  105. // }
  106. // return;
  107. // }
  108. // if (!this.showDiscussion || !this.focus) {
  109. // switch (e.key) {
  110. // case "ArrowDown":
  111. // case "ArrowRight":
  112. // case "s":
  113. // case "d":
  114. // case " ":
  115. // this.$store.commit(NEXT_PAGE);
  116. // break;
  117. // case "ArrowUp":
  118. // case "ArrowLeft":
  119. // case "w":
  120. // case "a":
  121. // this.$store.commit(PREVIOUS_PAGE);
  122. // break;
  123. // case "c":
  124. // this.cleanCanvas();
  125. // break;
  126. // case "q":
  127. // case "z":
  128. // this.$refs.pointerCanvas.undo();
  129. // break;
  130. // case "e":
  131. // case "y":
  132. // this.$refs.pointerCanvas.redo();
  133. // break;
  134. // case "[":
  135. // case "b":
  136. // this.box = !this.box;
  137. // break;
  138. // case "p":
  139. // case "v":
  140. // this.pointer = !this.pointer;
  141. // break;
  142. // }
  143. // }
  144. // },
  145. // load(src) {
  146. // console.log("load:" + src.substring(48));
  147. // const loadingTask = pdfJS.getDocument("/api/slide" + src.substring(48));
  148. // loadingTask.promise.then(pdf => {
  149. // this.loading = false;
  150. // this._pdf = pdf;
  151. // this.$store.commit(SET_TOTAL_PAGES, {totalPages: pdf.numPages});
  152. // this.showPage();
  153. // });
  154. // },
  155. // showPage() {
  156. // this._pdf && this._pdf.getPage(this.currentPage || 1).then(page => {
  157. // const scale = 2.5;
  158. // const viewport = page.getViewport({scale: scale});
  159. //
  160. // this._canvas.height = viewport.height;
  161. // this._canvas.width = viewport.width;
  162. //
  163. // const renderContext = {
  164. // canvasContext: this._context,
  165. // viewport: viewport
  166. // };
  167. // page.render(renderContext);
  168. // }).catch(() => {
  169. // console.log("PDF 当前页解析错误");
  170. // //this.$setInfoMessage('PDF 当前页解析错误')
  171. // });
  172. // }
  173. // },
  174. // };
  175. </script>
  176. <!--<style lang="scss" scoped>-->
  177. <!-- .pdf-reader {-->
  178. <!-- display: flex;-->
  179. <!-- align-items: center;-->
  180. <!-- justify-content: center;-->
  181. <!-- min-height: 100vh;-->
  182. <!-- }-->
  183. <!-- .mybuttton {-->
  184. <!-- position: absolute;-->
  185. <!-- left: 16px;-->
  186. <!-- top: 16px;-->
  187. <!-- background-color: rgba(160, 180, 200, .1);-->
  188. <!-- color: #7a8a9a;-->
  189. <!-- align-items: center;-->
  190. <!-- justify-content: center;-->
  191. <!-- padding: 8px;-->
  192. <!-- width: 44px;-->
  193. <!-- height: 44px;-->
  194. <!-- &:hover {-->
  195. <!-- background-color: rgba(218, 234, 250, 0.67);-->
  196. <!-- }-->
  197. <!-- }-->
  198. <!-- .myicon {-->
  199. <!-- font-size: 25px;-->
  200. <!-- }-->
  201. <!-- .show-discussion, .hide-discussion {-->
  202. <!-- transition: .2s;-->
  203. <!-- }-->
  204. <!-- .hide-discussion {-->
  205. <!-- transform: translateY(100%);-->
  206. <!-- opacity: 0;-->
  207. <!-- }-->
  208. <!-- .pointer-actions {-->
  209. <!-- position: fixed;-->
  210. <!-- left: 6px;-->
  211. <!-- bottom: 8px;-->
  212. <!-- .c-button {-->
  213. <!-- background-color: white;-->
  214. <!-- }-->
  215. <!-- }-->
  216. <!--</style>-->