|
@@ -3,30 +3,11 @@
|
|
<div class="NNPE-ArticleView" v-if="articleInfo">
|
|
<div class="NNPE-ArticleView" v-if="articleInfo">
|
|
<template v-if="resArr[0]&&resArr[0].wordsList">
|
|
<template v-if="resArr[0]&&resArr[0].wordsList">
|
|
<h2>
|
|
<h2>
|
|
- <span v-for="(itemR,indexR) in resArr[0].wordsList" :key="indexR" :style="{color:colorObj.titleColor,fontSize:(wordFontsize+30)+'px',lineHeight:(wordFontsize+38)+'px',marginRight:'10px',fontWeight:'700',cursor:'pointer'}"
|
|
|
|
- :class="[
|
|
|
|
- itemR.tokens[9]===''?'marginRight':'',itemR.marginRight?'marginSingleRight':'',
|
|
|
|
- itemR.isExplain||itemR.explainNumber?'hasExplain':''
|
|
|
|
- ]">
|
|
|
|
- <template v-if="itemR.isShow">
|
|
|
|
|
|
+ <span v-for="(itemR,indexR) in resArr[0].wordsList" :key="indexR" :style="{color:colorObj.titleColor,fontSize:(wordFontsize+30)+'px',lineHeight:(wordFontsize+38)+'px',marginRight:'10px',fontWeight:'700',cursor:'pointer'}">
|
|
<span
|
|
<span
|
|
- class="NNPE-chs"
|
|
|
|
- :class="[
|
|
|
|
- itemR.type,itemR.tokens[9]===''?'marginRight':'',itemR.highIndex?'fontWeight':'',itemR.marginRight?'marginSingleRight':'',
|
|
|
|
- ]"
|
|
|
|
- >{{ itemR.tokens[2] }}</span
|
|
|
|
- >
|
|
|
|
- <span
|
|
|
|
- class="NNPE-chs NNPE-chs-both"
|
|
|
|
- v-if="resArr[0].wordsList[indexR + 1] &&
|
|
|
|
- resArr[0].wordsList[indexR + 1].tokens[2] &&
|
|
|
|
- enFhList.indexOf(resArr[0].wordsList[indexR + 1].tokens[2]) > -1"
|
|
|
|
- :class="[
|
|
|
|
- resArr[0].wordsList[indexR + 1].type,resArr[0].wordsList[indexR + 1].tokens[8]===''?'marginLeft':'',resArr[0].wordsList[indexR + 1].highIndex?'fontWeight':'',resArr[0].wordsList[indexR + 1].marginRight?'marginSingleRight':'',
|
|
|
|
- ]"
|
|
|
|
- >{{ resArr[0].wordsList[indexR + 1].tokens[2] }}</span
|
|
|
|
- >
|
|
|
|
- </template>
|
|
|
|
|
|
+ class="NNPE-chs"
|
|
|
|
+ >{{ itemR.text }}</span
|
|
|
|
+ >
|
|
<!-- {{itemR.tokens[2]}} -->
|
|
<!-- {{itemR.tokens[2]}} -->
|
|
</span>
|
|
</span>
|
|
</h2>
|
|
</h2>
|
|
@@ -58,41 +39,11 @@
|
|
v-for="(item, index) in resArr"
|
|
v-for="(item, index) in resArr"
|
|
:key="'detail' + index"
|
|
:key="'detail' + index"
|
|
>
|
|
>
|
|
- <div class="wordsList-box">
|
|
|
|
<template v-if="index!==0">
|
|
<template v-if="index!==0">
|
|
- <div class="nnpe-sentence-box">
|
|
|
|
- <div v-for="(pItem, pIndex) in item.wordsList" :key="'wordsList' + pIndex" class="word-box" :class="[pItem.isExplain||pItem.explainNumber?'hasExplain':'']">
|
|
|
|
- <template v-if="pItem.isShow">
|
|
|
|
- <div
|
|
|
|
- :class="[
|
|
|
|
- 'NNPE-words',
|
|
|
|
- ]"
|
|
|
|
- >
|
|
|
|
- <span
|
|
|
|
- class="NNPE-chs"
|
|
|
|
- :class="[
|
|
|
|
- pItem.type,pItem.tokens[9]===''?'marginRight':'',pItem.highIndex?'fontWeight':'',pItem.marginRigh?'marginSingleRight':''
|
|
|
|
- ]"
|
|
|
|
- :style="{fontSize:wordFontsize + 'px',color: colorObj.contentColor}"
|
|
|
|
- >{{ pItem.tokens[2] }}</span
|
|
|
|
- >
|
|
|
|
- <span
|
|
|
|
- class="NNPE-chs NNPE-chs-both"
|
|
|
|
- v-if="item.wordsList[pIndex + 1] &&
|
|
|
|
- item.wordsList[pIndex + 1].tokens[2] &&
|
|
|
|
- enFhList.indexOf(item.wordsList[pIndex + 1].tokens[2]) > -1"
|
|
|
|
- :class="[
|
|
|
|
- item.wordsList[pIndex + 1].type,item.wordsList[pIndex + 1].tokens[8]===''?'marginLeft':'',item.wordsList[pIndex + 1].highIndex?'fontWeight':'',item.wordsList[pIndex + 1].marginRight?'marginSingleRight':''
|
|
|
|
- ]"
|
|
|
|
- :style="{fontSize:wordFontsize + 'px',color: colorObj.contentColor}"
|
|
|
|
- >{{ item.wordsList[pIndex + 1].tokens[2] }}</span
|
|
|
|
- >
|
|
|
|
- </div>
|
|
|
|
- </template>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <span v-for="(pItem, pIndex) in item.wordsList" :key="'wordsList' + pIndex" class="word-box" :style="{fontSize:wordFontsize + 'px',color: colorObj.contentColor}">
|
|
|
|
+ {{ pItem.text }}
|
|
|
|
+ </span>
|
|
</template>
|
|
</template>
|
|
- </div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -102,6 +53,10 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import AudioLine from "@/components/common/AudioLine.vue"
|
|
import AudioLine from "@/components/common/AudioLine.vue"
|
|
|
|
+import Highlighter from 'web-highlighter';
|
|
|
|
+const highlighter = new Highlighter({
|
|
|
|
+ exceptSelectors: ['pre', 'code']
|
|
|
|
+});
|
|
export default {
|
|
export default {
|
|
name: "ArticleView",
|
|
name: "ArticleView",
|
|
props: [ "titleFontsize", "wordFontsize", "colorObj","articleType","articleInfo"],
|
|
props: [ "titleFontsize", "wordFontsize", "colorObj","articleType","articleInfo"],
|
|
@@ -153,7 +108,7 @@ export default {
|
|
],
|
|
],
|
|
articleImg: {}, // 文章图片
|
|
articleImg: {}, // 文章图片
|
|
tokensArr: [],
|
|
tokensArr: [],
|
|
- sentenceList: [],
|
|
|
|
|
|
+ sentenceList: []
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -196,10 +151,7 @@ export default {
|
|
resArr.push(obj)
|
|
resArr.push(obj)
|
|
}
|
|
}
|
|
this.sentenceList.forEach((item,index) => {
|
|
this.sentenceList.forEach((item,index) => {
|
|
- item.StyleTokens.forEach((items,indexs)=>{
|
|
|
|
- items.isShow = this.enFhList.indexOf(items.tokens[2])==-1
|
|
|
|
- resArr[item.pno].wordsList.push(items)
|
|
|
|
- })
|
|
|
|
|
|
+ resArr[item.pno].wordsList.push(item)
|
|
});
|
|
});
|
|
this.resArr = resArr;
|
|
this.resArr = resArr;
|
|
},
|
|
},
|
|
@@ -210,6 +162,22 @@ export default {
|
|
mounted() {
|
|
mounted() {
|
|
if (this.articleInfo) {
|
|
if (this.articleInfo) {
|
|
this.handleData();
|
|
this.handleData();
|
|
|
|
+ highlighter
|
|
|
|
+ .on('selection:hover', ({id}) => {
|
|
|
|
+ // 通过添加 class,实现类似 hover 效果
|
|
|
|
+ highlighter.addClass('highlight-wrap-hover', id);
|
|
|
|
+ })
|
|
|
|
+ .on('selection:hover-out', ({id}) => {
|
|
|
|
+ // 鼠标离开时清除悬停样式
|
|
|
|
+ highlighter.removeClass('highlight-wrap-hover', id);
|
|
|
|
+ })
|
|
|
|
+ .on('selection:create', ({sources}) => {
|
|
|
|
+ // sources = sources.map(hs => ({hs}));
|
|
|
|
+ console.log(sources)
|
|
|
|
+ // 存储
|
|
|
|
+ // store.save(sources);
|
|
|
|
+ });
|
|
|
|
+ highlighter.run()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
beforeCreate() {}, //生命周期 - 创建之前
|
|
beforeCreate() {}, //生命周期 - 创建之前
|
|
@@ -299,61 +267,15 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.NNPE-detail {
|
|
.NNPE-detail {
|
|
- clear: both;
|
|
|
|
- overflow: hidden;
|
|
|
|
- display: flex;
|
|
|
|
- .NNPE-words {
|
|
|
|
- float: left;
|
|
|
|
- padding: 0;
|
|
|
|
- &.noPadding{
|
|
|
|
- padding:0;
|
|
|
|
- }
|
|
|
|
- &.sentActive {
|
|
|
|
- background: rgba(24, 144, 255, 0.1);
|
|
|
|
- }
|
|
|
|
- &.overActive {
|
|
|
|
- background: rgba(0, 0, 0, 0.06);
|
|
|
|
- }
|
|
|
|
- > span {
|
|
|
|
- float: left;
|
|
|
|
- cursor: pointer;
|
|
|
|
- &.NNPE-chs {
|
|
|
|
- // font-size: 24px;
|
|
|
|
- font-family: 'Smartisan';
|
|
|
|
- line-height: 150%;
|
|
|
|
- color: #000000;
|
|
|
|
- padding: 0 3px;
|
|
|
|
- &.wordActive {
|
|
|
|
- color: #175DFF !important;
|
|
|
|
- }
|
|
|
|
- &.marginRight{
|
|
|
|
- padding-right: 0;
|
|
|
|
- }
|
|
|
|
- &.marginLeft{
|
|
|
|
- padding-left: 0;
|
|
|
|
- }
|
|
|
|
- &.marginSingleRight{
|
|
|
|
- padding-right: 3px;
|
|
|
|
- }
|
|
|
|
- &.fontWeight{
|
|
|
|
- font-weight: bold;
|
|
|
|
- }
|
|
|
|
- &.newWord{
|
|
|
|
- color: #3459D2 !important;
|
|
|
|
- }
|
|
|
|
- &.phrase{
|
|
|
|
- color: #FF802B !important;
|
|
|
|
- }
|
|
|
|
- &.explain{
|
|
|
|
- // color: #23C847 !important;
|
|
|
|
- font-weight: 400;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- &.padding {
|
|
|
|
- padding: 0 3px;
|
|
|
|
- cursor: pointer;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // clear: both;
|
|
|
|
+ // overflow: hidden;
|
|
|
|
+ // display: flex;
|
|
|
|
+ padding: 6px 0 12px 3px;
|
|
|
|
+ .word-box {
|
|
|
|
+ font-family: 'Smartisan';
|
|
|
|
+ line-height: 150%;
|
|
|
|
+ color: #000000;
|
|
|
|
+ word-break: break-word;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|