From f7e83b0113c8c53a57c82a386656b18254efd17d Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期四, 17 十月 2024 16:16:05 +0800 Subject: [PATCH] 民航概论 --- src/books/civilAviation/view/index.vue | 81 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 81 insertions(+), 0 deletions(-) diff --git a/src/books/civilAviation/view/index.vue b/src/books/civilAviation/view/index.vue index e69de29..f832165 100644 --- a/src/books/civilAviation/view/index.vue +++ b/src/books/civilAviation/view/index.vue @@ -0,0 +1,81 @@ +<template> + <div class="civilAviation-book" @mouseup="handleMouseUp" :style="{ + fontSize: fontSize ? fontSize + 'px' : '16px', + transform: `scale(${pageZoom ? pageZoom : 1})`, + }"> + <pageContent></pageContent> + </div> + </template> + + <script> + import pageContent from "./components/index.vue" + export default { + name: "civilAviation-book", + components: { pageContent }, + computed: { + fontSize() { + return this.$store.state.qiankun.fontSize; + }, + pageZoom() { + return this.$store.state.qiankun.scale / 100; + }, + }, + methods: { + getParentWithClass(element, className) { + while (element.parentElement) { + element = element.parentElement; + if (element.classList.contains(className)) { + return element; + } + } + }, + handleMouseUp(e) { + const selection = ( + this.container ? this.container : window + ).getSelection(); + const txt = selection.toString(); + if (selection.type != "none" && txt) { + let node = selection.anchorNode.parentNode; + let pageHtml = this.getParentWithClass( + selection.anchorNode, + "page-box" + ); + let chapterDom = this.getParentWithClass( + selection.anchorNode, + "chapter" + ); + let chapterNum; + if (chapterDom) chapterNum = chapterDom.getAttribute("num"); + if (pageHtml) { + const page = pageHtml.getAttribute("page"); + // 鐩戝惉閫変腑鏂囨湰浜嬩欢锛屽苟瑙﹀彂鐖跺眰鏂规硶 + if (this.$store.state.qiankun.windowSelection) { + this.$store.state.qiankun.windowSelection({ + chapterNum, + txt, + page, + x: e.x, + y: e.y, + }); + } + } + } else { + if (this.$store.state.qiankun.windowSelection) { + this.$store.state.qiankun.windowSelection({ + chapterNum: "", + txt: "", + page: "", + x: e.x, + y: e.y, + }); + } + } + }, + }, + }; + </script> + + <style lang="less"> + @import "../assets/main.less"; + </style> + \ No newline at end of file -- Gitblit v1.9.1