From 0c4042a0ced8f17c8f93f96ff3394e25b8338fa8 Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期一, 30 十二月 2024 11:56:15 +0800 Subject: [PATCH] 服务礼仪样章 --- src/books/English/view/index.vue | 70 +++++++++++++++++++++++++++++++---- 1 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/books/English/view/index.vue b/src/books/English/view/index.vue index 487bb80..9bd7e2b 100644 --- a/src/books/English/view/index.vue +++ b/src/books/English/view/index.vue @@ -1,15 +1,69 @@ <template> - <div class="english-book"> - + <div class="english-book" @mouseup="handleMouseUp"> + <pageContent></pageContent> </div> </template> <script> - export default { - name:'english-book' - } +import pageContent from "./components/index.vue" +export default { + name: "english-book", + components: { pageContent }, + 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