| | |
| | | <ChapterOne |
| | | v-if="showCatalogList.indexOf(2) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <ChapterTwo |
| | | v-if="showCatalogList.indexOf(3) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <ChapterThree |
| | | v-if="showCatalogList.indexOf(4) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <ChapterFour |
| | | v-if="showCatalogList.indexOf(5) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <ChapterFive |
| | | v-if="showCatalogList.indexOf(6) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | @Upload_initViewer="changeDomViewer" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <chapterSix |
| | | v-if="showCatalogList.indexOf(7) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <chapterSeven |
| | | v-if="showCatalogList.indexOf(8) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | @eventSwdt="swdtChange" |
| | | @Upload_initViewer="changeDomViewer" |
| | | :isSearch="isSearch" |
| | |
| | | <chapterEight |
| | | v-if="showCatalogList.indexOf(9) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <chapterNine |
| | | v-if="showCatalogList.indexOf(10) > -1" |
| | | :showPageList="loadPageList" |
| | | :questionData="questionData" |
| | | :questionData="questionDataMap" |
| | | :isSearch="isSearch" |
| | | /> |
| | | <chapter010 |
| | |
| | | }, |
| | | mounted() { |
| | | // 默认加载章节 |
| | | this.showCatalogList = [1]; |
| | | this.showCatalogList = [6]; |
| | | // 滚动监听节流 |
| | | this.throttledScrollHandler = _.throttle( |
| | | this.scrollFun, |
| | |
| | | this.initViewer(); |
| | | }, 500); |
| | | }, |
| | | |
| | | // 滚动监听 |
| | | scrollFun(event) { |
| | | // 判断向上滚动还是向下滚动 |
| | |
| | | |
| | | // 处理标记数据 |
| | | handelSignData(type, data) { |
| | | if (this.loadPageList.indexOf(Number(data.page)) > -1) { |
| | | // 立即渲染 |
| | | this.renderSign(type, data); |
| | | } |
| | | |
| | | // 储存数据 |
| | | if (!this.renderSignMap[type]) this.renderSignMap[type] = {}; |
| | | if (!this.renderSignMap[type][data.page]) |
| | | this.renderSignMap[type][data.page] = []; |
| | |
| | | |
| | | // 渲染标记 |
| | | renderSign(type, data) { |
| | | // 父层设置禁止渲染标记时不再进行渲染 |
| | | if (this.$store.state.qiankun.disableSign) { |
| | | return false; |
| | | } |
| | | const existence = ( |
| | | this.container ? this.container : document |
| | | ).querySelector(`[dataid="${data.id}"]`); |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 删除标记渲染 |
| | | delSign({ ids, type }) { |
| | | if (ids && ids.length) { |
| | |
| | | }); |
| | | }, |
| | | |
| | | getParentWithClass(element, className) { |
| | | while (element.parentElement) { |
| | | element = element.parentElement; |
| | | if (element.classList.contains(className)) { |
| | | return element; |
| | | } |
| | | } |
| | | }, |
| | | |
| | | pageChangeCallback(entries, observer) { |
| | | //entries:代表观察到的目标元素的集合。 observer:代表观察者对象。 |
| | | entries.forEach((entry) => { |
| | |
| | | ); |
| | | const catalog = catalogDom.getAttribute("num"); |
| | | if (!this.questionDataMap[page]) { |
| | | const token = localStorage.getItem(this.config.tokenKey); |
| | | if (testData && testData[catalog]) { |
| | | if (testData[catalog][page]) { |
| | | if (Array.isArray(testData[catalog][page])) { |
| | | if (token) { |
| | | this.questionDataMap[page] = await getQuestionList( |
| | | page, |
| | | testData[catalog][page], |
| | | this.config.activeBook |
| | | ); |
| | | } |
| | | } else { |
| | | const obj = {}; |
| | | for (let key in testData[catalog][page]) { |
| | |
| | | } |
| | | this.questionDataMap[page] = obj; |
| | | } |
| | | // console.log("题目", this.questionDataMap); |
| | | console.log("题目", this.questionDataMap); |
| | | } |
| | | } |
| | | } |
| | |
| | | // 高亮行 |
| | | setTimeout(() => { |
| | | // 获取页面所有text节点 |
| | | const pageTextList = document.createTreeWalker(target, NodeFilter.SHOW_TEXT); |
| | | const pageTextList = document.createTreeWalker( |
| | | target, |
| | | NodeFilter.SHOW_TEXT |
| | | ); |
| | | // 匹配关键字 |
| | | const allPageTextNodes = []; |
| | | let currentNode = pageTextList.nextNode(); |
| | |
| | | } |
| | | }, |
| | | |
| | | getParentWithClass(element, className) { |
| | | // console.log(element, className, "element, className"); |
| | | while (element.parentElement) { |
| | | element = element.parentElement; |
| | | if (element.classList.contains(className)) { |
| | | return element; |
| | | } |
| | | } |
| | | }, |
| | | |
| | | handleMouseUp(e) { |
| | | const selection = ( |
| | | this.container ? this.container : window |
| | |
| | | y: e.y, |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | swdtChange(data) { |
| | | if (this.$store.state.qiankun && this.$store.state.qiankun.chooseWords) { |
| | | this.$store.state.qiankun.chooseWords({ |
| | | type: data, |
| | | }); |
| | | } |
| | | }, |
| | | |
| | |
| | | } |
| | | } |
| | | // 输出搜索结果 |
| | | console.log(searchResult); |
| | | // console.log(searchResult); |
| | | return searchResult; |
| | | }, |
| | | |