From 38b2ebcdd71d5f59b79c2e9db9f6a857fef34c63 Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期四, 04 七月 2024 12:00:33 +0800 Subject: [PATCH] 艺术戏剧(文本框样式修改) --- src/books/English/view/index.vue | 85 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/books/English/view/index.vue b/src/books/English/view/index.vue index 487bb80..8d3f387 100644 --- a/src/books/English/view/index.vue +++ b/src/books/English/view/index.vue @@ -1,15 +1,84 @@ <template> - <div class="english-book"> - + <div + class="english-book" + @mouseup="handleMouseUp" + :style="{ + fontSize: fontSize ? fontSize + 'px' : '16px', + transform: `scale(${pageZoom ? pageZoom : 1})`, + }" + > + <pageContent></pageContent> </div> </template> <script> - export default { - name:'english-book' - } +import pageContent from "./components/index.vue"; +export default { + name: "english-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" scoped> - -</style> \ No newline at end of file +<style lang="less"> +@import "../assets/main.less"; +</style> -- Gitblit v1.9.1