index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. <!-- eslint-disable vue/no-v-html -->
  2. <template>
  3. <div class="article-preview" :style="getAreaStyle()">
  4. <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
  5. <div class="main">
  6. <div class="NPC-ArticleView NPC-ArticleView-container">
  7. <div class="ArticleView-header">
  8. <a class="ArticleView-full" @click="fullScreen" title="黑板模式">
  9. <svg-icon
  10. icon-class="icon-full"
  11. size="24"
  12. :style="{
  13. color: data.unified_attrib && data.unified_attrib.topic_color ? data.unified_attrib.topic_color : '',
  14. }"
  15. />
  16. </a>
  17. <div>
  18. <!-- v-if="
  19. (tokenData && tokenData.popedom_code_list && tokenData.popedom_code_list.indexOf(2100001) != -1) ||
  20. (tokenData && tokenData.user_type === 'APP')
  21. " -->
  22. <div class="left" :style="{ marginLeft: '40px', cursor: 'pointer' }" @click="submit" title="文本分析">
  23. <!-- <img src="@/assets/wbfx-icon.png" alt="" /> -->
  24. <svg-icon
  25. icon-class="icon-wbfx"
  26. size="24"
  27. :style="{
  28. color: data.unified_attrib && data.unified_attrib.topic_color ? data.unified_attrib.topic_color : '',
  29. }"
  30. />
  31. </div>
  32. </div>
  33. <div class="right">
  34. <!-- <template v-if="data.property.is_enable_new_word === 'true'">
  35. <el-switch
  36. v-model="showPhrases"
  37. style="display: block"
  38. :active-color="bookInfo.theme_color"
  39. inactive-color="rgba(0,0,0,0.1)"
  40. active-text=""
  41. inactive-text="本课生词"
  42. @change="handleSwitchChange('showPractice', 'showWord')"
  43. />
  44. </template>
  45. <template v-if="data.property.is_enable_read === 'true'">
  46. <el-switch
  47. v-model="showPractice"
  48. style="display: block"
  49. :active-color="bookInfo.theme_color"
  50. inactive-color="rgba(0,0,0,0.1)"
  51. active-text=""
  52. inactive-text="语音练习"
  53. @change="handleSwitchChange('showPhrases', 'showWord')"
  54. />
  55. </template>
  56. <template v-if="data.property.is_enable_word === 'true'">
  57. <el-switch
  58. v-model="showWord"
  59. style="display: block"
  60. :active-color="bookInfo.theme_color"
  61. inactive-color="rgba(0,0,0,0.1)"
  62. active-text=""
  63. inactive-text="取词"
  64. @change="handleSwitchChange('showPhrases', 'showPractice')"
  65. />
  66. </template> -->
  67. <a
  68. v-if="data.property.is_enable_new_word === 'true'"
  69. @click="handleSwitchChange('showPractice', 'showWord', 'showPhrases')"
  70. :style="{
  71. color:
  72. showPhrases && data.unified_attrib && data.unified_attrib.topic_color
  73. ? data.unified_attrib.topic_color
  74. : '',
  75. }"
  76. title="本课生词"
  77. ><svg-icon icon-class="icon-article-ci" size="24"
  78. /></a>
  79. <a
  80. v-if="data.property.is_enable_read === 'true'"
  81. @click="handleSwitchChange('showPhrases', 'showWord', 'showPractice')"
  82. :style="{
  83. color:
  84. showPractice && data.unified_attrib && data.unified_attrib.topic_color
  85. ? data.unified_attrib.topic_color
  86. : '',
  87. }"
  88. title="语音练习"
  89. ><svg-icon icon-class="icon-article-practice" size="24"
  90. /></a>
  91. <a
  92. v-if="data.property.is_enable_word === 'true'"
  93. @click="handleSwitchChange('showPhrases', 'showPractice', 'showWord')"
  94. :style="{
  95. color:
  96. showWord && data.unified_attrib && data.unified_attrib.topic_color
  97. ? data.unified_attrib.topic_color
  98. : '',
  99. }"
  100. title="取词模式"
  101. ><svg-icon icon-class="icon-article-phrase" size="24"
  102. /></a>
  103. </div>
  104. </div>
  105. <div ref="ArticleViewbody" class="ArticleView-body">
  106. <NormalModelChs
  107. v-if="!showPhrases && !showPractice && !showWord"
  108. :cur-que="data"
  109. :title-fontsize="titleFontsize"
  110. :word-fontsize="wordFontsize"
  111. :body-left="bodyLeft"
  112. :body-width="bodyWidth"
  113. :attrib="data.unified_attrib"
  114. :no-font="noFont"
  115. :config="config"
  116. :NNPEAnnotationList="NNPEAnnotationList"
  117. :col-length="colLength"
  118. :multilingual="showLang && getLang() ? getLang() : ''"
  119. @changeConfig="changeConfig"
  120. />
  121. <PhraseModel
  122. v-if="showPhrases"
  123. :cur-que="data"
  124. :title-fontsize="titleFontsize"
  125. :word-fontsize="wordFontsize"
  126. :NNPENewWordList="NNPENewWordList"
  127. :attrib="data.unified_attrib"
  128. :no-font="noFont"
  129. :body-left="bodyLeft"
  130. :config="config"
  131. :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
  132. :NNPEAnnotationList="NNPEAnnotationList"
  133. :col-length="colLength"
  134. :NpcNewWordMp3="NpcNewWordMp3"
  135. :multilingual="showLang && getLang() ? getLang() : ''"
  136. @changeConfig="changeConfig"
  137. />
  138. <Practice
  139. v-if="showPractice"
  140. :cur-que="data"
  141. :title-fontsize="titleFontsize"
  142. :word-fontsize="wordFontsize"
  143. :attrib="data.unified_attrib"
  144. :no-font="noFont"
  145. :NNPENewWordList="NNPENewWordList"
  146. :config="config"
  147. :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
  148. :col-length="colLength"
  149. :NpcNewWordMp3="NpcNewWordMp3"
  150. :is-full="isFull"
  151. :multilingual="showLang && getLang() ? getLang() : ''"
  152. @changeConfig="changeConfig"
  153. />
  154. <WordModel
  155. v-if="showWord"
  156. :cur-que="data"
  157. :title-fontsize="titleFontsize"
  158. :word-fontsize="wordFontsize"
  159. :body-left="bodyLeft"
  160. :body-width="bodyWidth"
  161. :NNPENewWordList="NNPENewWordList"
  162. :attrib="data.unified_attrib"
  163. :no-font="noFont"
  164. :config="config"
  165. :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
  166. :col-length="colLength"
  167. :multilingual="showLang && getLang() ? getLang() : ''"
  168. @changeConfig="changeConfig"
  169. />
  170. </div>
  171. <div :id="'screen-' + mathNum" class="voice-full-screen">
  172. <Voicefullscreen
  173. v-if="isFull && resObj"
  174. :theme-color="bookInfo.theme_color"
  175. :cur-que="data"
  176. :sent-list="resObj.sentList"
  177. :sent-index="0"
  178. :mp3="data.mp3_list && data.mp3_list[0] ? data.mp3_list[0].url : ''"
  179. :no-font="noFont"
  180. :NNPENewWordList="NNPENewWordList"
  181. :is-full="isFull"
  182. :config="config"
  183. :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
  184. :NpcNewWordMp3="NpcNewWordMp3"
  185. :attrib="data.unified_attrib"
  186. @handleWav="handleWav"
  187. @changePinyin="changePinyins"
  188. @changeEN="changeENs"
  189. @exitFullscreen="exitFullscreen"
  190. @changeIsFull="changeIsFull"
  191. />
  192. </div>
  193. </div>
  194. <template
  195. v-if="data.new_word_list && data.new_word_list.new_word_list && data.new_word_list.new_word_list.length > 0"
  196. >
  197. <NewWordPreview :new-data="data.new_word_list" />
  198. </template>
  199. <template
  200. v-if="
  201. data.other_word_list && data.other_word_list.new_word_list && data.other_word_list.new_word_list.length > 0
  202. "
  203. >
  204. <NewWordPreview :new-data="data.other_word_list" />
  205. </template>
  206. <template v-if="data.notes_list && data.notes_list.option && data.notes_list.option.length > 0">
  207. <NotesPreview :notes-data="data.notes_list" />
  208. </template>
  209. </div>
  210. </div>
  211. </template>
  212. <script>
  213. import { getArticleData } from '@/views/book/courseware/data/dialogueArticle';
  214. import PreviewMixin from '../common/PreviewMixin';
  215. import PhraseModel from './PhraseModelChs.vue';
  216. import NormalModelChs from './NormalModelChs.vue';
  217. import Practice from './Practicechs.vue'; // 语音练习模式
  218. import WordModel from './WordModelChs.vue'; // 语音练习模式
  219. import Voicefullscreen from '../article/Voicefullscreen.vue';
  220. import { getToken } from '@/utils/auth';
  221. import { GetFileURLMap } from '@/api/app';
  222. import { analysSubmit, getSysConfig } from '@/api/article';
  223. import NewWordPreview from '../new_word/NewWordPreview.vue';
  224. import NotesPreview from '../notes/NotesPreview.vue';
  225. export default {
  226. name: 'DialogueArticlePreview',
  227. components: {
  228. NormalModelChs,
  229. Practice,
  230. WordModel,
  231. PhraseModel,
  232. Voicefullscreen,
  233. NewWordPreview,
  234. NotesPreview,
  235. },
  236. mixins: [PreviewMixin],
  237. inject: ['bookInfo'],
  238. data() {
  239. return {
  240. data: getArticleData(),
  241. showPreview: true, // 全文预览
  242. showPhrases: false, // 显示单词和短语
  243. showPractice: false, // 语音练习
  244. showWord: false, // 取词
  245. titleFontsize: 20, // 标题字号初始值
  246. wordFontsize: 16, // 文章内容字号初始值
  247. bodyLeft: 0,
  248. bodyWidth: 0,
  249. noFont: ['~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '/'],
  250. config: {
  251. isShowEN: false,
  252. isHasEN: false,
  253. isShowPY: false,
  254. isHasPY: false,
  255. },
  256. userAnswer: {
  257. normalModel: {
  258. recordList: [],
  259. },
  260. writeModel: {}, // 生词/取词模式
  261. practiceModel: {}, // 练习模式
  262. wordModel: {
  263. recordList: [],
  264. },
  265. },
  266. tokenData: getToken(),
  267. mathNum: Math.random().toString(36).substr(2),
  268. isFull: false,
  269. resObj: null,
  270. chsFhList: [',', '。', '”', ':', '》', '?', '!', ';', '、'],
  271. highWords: null,
  272. highWordsArr: [],
  273. highIndex: 0,
  274. newWordList: [],
  275. NNPEAnnotationList: [],
  276. NNPENewWordList: [],
  277. NpcNewWordMp3: [],
  278. colLength: 1,
  279. multilingualTextList: {},
  280. analyser_url: '',
  281. };
  282. },
  283. computed: {},
  284. watch: {
  285. showLang: {
  286. handler(val) {
  287. if (val) {
  288. this.data.multilingual.forEach((item) => {
  289. let trans_arr = item.translation ? item.translation.split('\n') : [];
  290. this.data.detail.forEach((items) => {
  291. let items_trans_arr = [];
  292. if (items && !items.hasOwnProperty('multilingualTextList')) {
  293. this.$set(items, 'multilingualTextList', {});
  294. }
  295. if (items.para) {
  296. items_trans_arr = trans_arr.splice(0, items.sentences.length);
  297. }
  298. this.$set(items.multilingualTextList, item.type, items_trans_arr);
  299. });
  300. });
  301. }
  302. },
  303. deep: true,
  304. immediate: true,
  305. },
  306. 'data.detail.length': {
  307. handler(val) {
  308. if (val) {
  309. this.handleData();
  310. let _this = this;
  311. // if (!this.isJudgingRightWrong) {
  312. // let userAnswer = JSON.parse(JSON.stringify(_this.userAnswer));
  313. // _this.$set(this.data, 'Bookanswer', userAnswer);
  314. // }
  315. _this.$nextTick(() => {
  316. _this.bodyLeft = _this.$refs.ArticleViewbody.getBoundingClientRect().left;
  317. });
  318. for (let i = 0; i < this.data.detail.length; i++) {
  319. let enStr = this.data.detail[i].sentencesEn ? this.data.detail[i].sentencesEn.join('') : '';
  320. if (enStr) {
  321. this.config.isShowEN = false;
  322. this.config.isHasEN = true;
  323. }
  324. let pinyin = this.handleObj(this.data.detail[i].wordsList);
  325. if (pinyin && this.isEnable(this.data.property.view_pinyin)) {
  326. this.config.isShowPY = true;
  327. this.config.isHasPY = true;
  328. }
  329. if (enStr && pinyin) {
  330. break;
  331. }
  332. }
  333. }
  334. },
  335. deep: true,
  336. immediate: true,
  337. },
  338. },
  339. created() {},
  340. methods: {
  341. changeConfig(obj) {
  342. this.config[obj] = !this.config[obj];
  343. },
  344. changeIsFull() {
  345. this.isFull = false;
  346. },
  347. // 拼音的显示和隐藏
  348. changePinyins() {
  349. if (this.config.isHasPY) {
  350. this.changeConfig('isShowPY');
  351. }
  352. },
  353. // 英文的显示和隐藏
  354. changeENs() {
  355. if (this.config.isHasEN) {
  356. this.changeConfig('isShowEN');
  357. }
  358. },
  359. // 处理字体大小
  360. handleFontsize(symbol) {
  361. if (symbol == '+') {
  362. if (this.wordFontsize < 24) {
  363. this.titleFontsize += 2;
  364. this.wordFontsize += 2;
  365. }
  366. } else if (symbol == '-') {
  367. if (this.wordFontsize > 12) {
  368. this.titleFontsize -= 2;
  369. this.wordFontsize -= 2;
  370. }
  371. }
  372. },
  373. // 切换开关
  374. handleSwitchChange(obj1, obj2, obj3) {
  375. this[obj1] = false;
  376. this[obj2] = false;
  377. this[obj3] = !this[obj3];
  378. this.showPreview = false;
  379. },
  380. handleObj(list) {
  381. let pinyin = '';
  382. list.forEach((item) => {
  383. item.forEach((items) => {
  384. if (items.pinyin) pinyin += items.pinyin;
  385. });
  386. });
  387. return pinyin;
  388. },
  389. submit() {
  390. let access_token =
  391. this.tokenData && this.tokenData.gcls_sys_session_info ? this.tokenData.gcls_sys_session_info.access_token : '';
  392. let loading = this.$loading({
  393. lock: true,
  394. text: 'Loading',
  395. spinner: 'el-icon-loading',
  396. background: 'rgba(0, 0, 0, 0.7)',
  397. });
  398. getSysConfig()
  399. .then((ress) => {
  400. let content = '';
  401. this.data.detail.forEach((item) => {
  402. content += item.para + '\n';
  403. });
  404. analysSubmit({
  405. app_user_id: '',
  406. text: content,
  407. })
  408. .then((res) => {
  409. window.open(
  410. `${ress.text_analyser_page_address}GCLS-TC/#/textanalysis/Result?id=${res.record.id}&type=文本分析&AccessToken=${access_token}`,
  411. );
  412. loading.close();
  413. })
  414. .catch((res) => {
  415. loading.close();
  416. });
  417. })
  418. .catch((res) => {
  419. loading.close();
  420. });
  421. },
  422. // 语音全屏
  423. fullScreen() {
  424. this.pauseAudio();
  425. this.pauseVideo();
  426. this.isFull = true;
  427. this.goFullscreen();
  428. },
  429. pauseAudio() {
  430. let audio = document.getElementsByTagName('audio');
  431. if (audio && audio.length > 0 && window.location.href.indexOf('GCLS-Learn') == -1 && audio.forEach) {
  432. audio.forEach((item) => {
  433. item.pause();
  434. });
  435. }
  436. },
  437. pauseVideo() {
  438. let video = document.getElementsByTagName('video');
  439. if (video && video.length > 0 && window.location.href.indexOf('GCLS-Learn') == -1 && video.forEach) {
  440. video.forEach((item) => {
  441. item.pause();
  442. });
  443. }
  444. },
  445. goFullscreen() {
  446. let id = `screen-${this.mathNum}`;
  447. let element = document.getElementById(id);
  448. if (element.requestFullscreen) {
  449. element.requestFullscreen();
  450. } else if (element.msRequestFullscreen) {
  451. element.msRequestFullscreen();
  452. } else if (element.mozRequestFullScreen) {
  453. element.mozRequestFullScreen();
  454. } else if (element.webkitRequestFullscreen) {
  455. element.webkitRequestFullscreen();
  456. }
  457. },
  458. exitFullscreen() {
  459. this.isFull = false;
  460. if (document.exitFullscreen) {
  461. document.exitFullscreen();
  462. } else if (document.msExitFullscreen) {
  463. document.msExitFullscreen();
  464. } else if (document.mozCancelFullScreen) {
  465. document.mozCancelFullScreen();
  466. } else if (document.webkitExitFullscreen) {
  467. document.webkitExitFullscreen();
  468. }
  469. },
  470. handleData() {
  471. if (this.data.new_word_list) {
  472. this.$set(this.data.new_word_list, 'unified_attrib', this.data.unified_attrib);
  473. }
  474. if (this.data.other_word_list) {
  475. this.$set(this.data.other_word_list, 'unified_attrib', this.data.unified_attrib);
  476. }
  477. if (this.data.notes_list) {
  478. this.$set(this.data.notes_list, 'unified_attrib', this.data.unified_attrib);
  479. }
  480. if (this.showLang) {
  481. this.data.multilingual.forEach((item) => {
  482. let trans_arr = item.translation ? item.translation.split('\n') : [];
  483. this.data.detail.forEach((items) => {
  484. let items_trans_arr = [];
  485. if (!items.hasOwnProperty('multilingualTextList')) {
  486. this.$set(items, 'multilingualTextList', {});
  487. }
  488. if (items.para) {
  489. items_trans_arr = trans_arr.splice(0, items.sentences.length);
  490. }
  491. this.$set(items.multilingualTextList, item.type, items_trans_arr);
  492. });
  493. });
  494. }
  495. let userAnswer = JSON.parse(JSON.stringify(this.userAnswer));
  496. this.$set(this.data, 'Bookanswer', userAnswer);
  497. if (this.data.mp3_list && this.data.mp3_list.length > 0) {
  498. GetFileURLMap({ file_id_list: [this.data.mp3_list[0].file_id] }).then(({ url_map }) => {
  499. this.data.mp3_list[0].url = url_map[this.data.mp3_list[0].file_id];
  500. });
  501. }
  502. this.NNPENewWordList = (
  503. this.data.new_word_list_other_component_input ? this.data.new_word_list_other_component_input : []
  504. )
  505. .concat(
  506. this.data.new_word_list && this.data.new_word_list.new_word_list ? this.data.new_word_list.new_word_list : [],
  507. )
  508. .concat(
  509. this.data.other_word_list && this.data.other_word_list.new_word_list
  510. ? this.data.other_word_list.new_word_list
  511. : [],
  512. );
  513. this.NNPEAnnotationList = this.data.notes_list && this.data.notes_list.option ? this.data.notes_list.option : [];
  514. let resArr = [];
  515. let sentArrTotal = [];
  516. let timeArr = [];
  517. let curQue = JSON.parse(JSON.stringify(this.data));
  518. let wordTimeList = curQue.wordTime;
  519. let dhaspinyin = false; // 每段是否有拼音
  520. let dhaspinyinArr = [];
  521. curQue.detail.forEach((dItem, dIndex) => {
  522. dhaspinyin = false;
  523. dItem.wordsList.forEach((sItem, sIndex) => {
  524. let sentArr = [];
  525. let sentence = dItem.sentences[sIndex];
  526. sItem.forEach((wItem, wIndex) => {
  527. let startIndex = wIndex == 0 ? 0 : sentArr[wIndex - 1].startIndex + sentArr[wIndex - 1].chs.length;
  528. let endIndex = wIndex == 0 ? wItem.chs.length : sentArr[wIndex - 1].endIndex + wItem.chs.length;
  529. // this.judgePad(sItem, wItem, wIndex);
  530. this.mergeWordSymbol(wItem);
  531. let words = '';
  532. if (this.newWordList.length > 0) {
  533. if (!this.highWords) {
  534. this.findLightWord(wItem, wIndex, sentence, sItem);
  535. words = this.highWords ? this.highWords.words : '';
  536. } else if (wIndex > this.highWords.endIndex - 1) {
  537. this.highWords = null;
  538. this.findLightWord(wItem, wIndex, sentence, sItem);
  539. words = this.highWords ? this.highWords.words : '';
  540. } else {
  541. words = this.highWords ? this.highWords.words : '';
  542. }
  543. }
  544. let obj = {
  545. paraIndex: dIndex, // 段落索引
  546. sentIndex: sIndex, // 在段落中句子索引
  547. wordIndex: wIndex, // 单词的索引
  548. pinyin: wItem.pinyin,
  549. chs: wItem.chs,
  550. padding: true,
  551. className: wItem.className,
  552. isShow: wItem.isShow,
  553. startIndex,
  554. endIndex,
  555. leg: wItem.chs.length,
  556. timeList: [],
  557. words,
  558. config: {
  559. fontFamily: wItem.fontFamily,
  560. },
  561. };
  562. sentArr.push(obj);
  563. if (wItem.pinyin) dhaspinyin = true;
  564. });
  565. let objs = {
  566. sentArr,
  567. enwords: dItem.sentencesEn && dItem.sentencesEn[sIndex] && dItem.sentencesEn[sIndex].replace(/\'/g, '’'),
  568. };
  569. sentArrTotal.push(sentArr);
  570. resArr.push(objs);
  571. });
  572. timeArr.push(dItem.timeList);
  573. if (this.isEnable(curQue.property.view_pinyin)) {
  574. dhaspinyinArr.push(dhaspinyin);
  575. }
  576. });
  577. if (wordTimeList && wordTimeList.length > 0) {
  578. this.mergeWordTime(sentArrTotal, wordTimeList);
  579. }
  580. let timeList = [];
  581. timeArr.forEach((item) => {
  582. item.forEach((aItem) => {
  583. if (timeList.indexOf(aItem) < 0) {
  584. timeList.push(aItem);
  585. }
  586. });
  587. });
  588. this.resObj = {
  589. sentList: resArr,
  590. timeList,
  591. dhaspinyinArr,
  592. };
  593. },
  594. mergeWordTime(resArr, wordTimeList) {
  595. resArr.forEach((item, index) => {
  596. let wordsResultList = wordTimeList[index].wordsResultList;
  597. item.forEach((wItem) => {
  598. let startIndex = wItem.startIndex;
  599. let endIndex = wItem.endIndex;
  600. wItem.timeList = wordsResultList.slice(startIndex, endIndex);
  601. });
  602. });
  603. },
  604. findLightWord(wItem, startIndex, sentence, sItem) {
  605. let endIndex = 0;
  606. let words = '';
  607. this.newWordList.forEach((item) => {
  608. if (item.length == 1) {
  609. if (item == wItem.chs && !wItem.banLight) {
  610. words = wItem.chs;
  611. endIndex = startIndex + 1;
  612. }
  613. } else if (item[0] == wItem.chs && sentence.indexOf(item) > -1) {
  614. let index = null;
  615. let chsStr = '';
  616. for (let i = startIndex; i < sItem.length + 1; i++) {
  617. index = i;
  618. if (chsStr.length == item.length) {
  619. break;
  620. } else {
  621. chsStr += sItem[i] ? sItem[i].chs : '';
  622. }
  623. }
  624. if (chsStr == item && !wItem.banLight) {
  625. words = item;
  626. endIndex = index;
  627. }
  628. } else if (wItem.new_word && wItem.new_word == item && !wItem.banLight) {
  629. words = item;
  630. endIndex = startIndex + 1;
  631. }
  632. });
  633. if (words) {
  634. this.highWords = { words, endIndex };
  635. } else {
  636. this.highWords = null;
  637. }
  638. },
  639. // 词和标点合一起
  640. mergeWordSymbol(wItem) {
  641. if (this.chsFhList.indexOf(wItem.chs) > -1) {
  642. wItem.isShow = false;
  643. } else {
  644. wItem.isShow = true;
  645. }
  646. },
  647. handleWav(list, tmIndex) {
  648. tmIndex = tmIndex || 0;
  649. this.data.Bookanswer.practiceModel[tmIndex] = {
  650. recordList: [],
  651. };
  652. this.$set(this.data.Bookanswer.practiceModel[tmIndex], 'recordList', list);
  653. },
  654. handleNewword() {
  655. let NewWordList = [];
  656. this.NNPENewWordList.forEach((wItem) => {
  657. // item.forEach((wItem) => {
  658. if (wItem.new_word) {
  659. NewWordList.push(wItem.new_word);
  660. } else if (wItem.detail && wItem.detail.sentence) {
  661. NewWordList.push(wItem.detail.sentence);
  662. }
  663. // });
  664. });
  665. this.newWordList = JSON.parse(JSON.stringify(NewWordList));
  666. },
  667. },
  668. };
  669. </script>
  670. <style lang="scss" scoped>
  671. @use '@/styles/mixin.scss' as *;
  672. .article-preview {
  673. @include preview-base;
  674. .main {
  675. display: grid;
  676. row-gap: 24px;
  677. align-items: center;
  678. }
  679. .NPC-ArticleView {
  680. width: 100%;
  681. .ArticleView-full {
  682. position: absolute;
  683. top: 0;
  684. left: 0;
  685. z-index: 1;
  686. font-size: 16px;
  687. font-weight: bold;
  688. line-height: 24px;
  689. color: #000;
  690. cursor: pointer;
  691. // background: url('@/assets/full-screen-red.png') left center no-repeat;
  692. // background-size: 20px 20px;
  693. }
  694. .ArticleView-header {
  695. position: relative;
  696. display: flex;
  697. align-items: center;
  698. justify-content: space-between;
  699. height: 24px;
  700. margin-bottom: 16px;
  701. .left {
  702. display: flex;
  703. align-items: center;
  704. justify-content: center;
  705. // padding-left: 24px;
  706. font-size: 16px;
  707. font-weight: bold;
  708. line-height: 24px;
  709. cursor: pointer;
  710. // background: url('@/assets/wbfx-icon.png') left center no-repeat;
  711. // background-size: 20px;
  712. img {
  713. width: 20px;
  714. height: 20px;
  715. margin-right: 4px;
  716. }
  717. }
  718. .right {
  719. display: flex;
  720. gap: 24px;
  721. a {
  722. display: flex;
  723. gap: 4px;
  724. align-items: center;
  725. color: rgba(0, 0, 0, 65%);
  726. cursor: pointer;
  727. }
  728. }
  729. .setting-fontsize {
  730. display: flex;
  731. margin-left: 24px;
  732. a {
  733. box-sizing: border-box;
  734. display: block;
  735. width: 24px;
  736. height: 24px;
  737. border: 1px solid rgba(0, 0, 0, 10%);
  738. border-radius: 4px;
  739. }
  740. img {
  741. width: 100%;
  742. }
  743. > img {
  744. width: 24px;
  745. margin: 0 8px;
  746. }
  747. }
  748. }
  749. .ArticleView-body {
  750. box-sizing: border-box;
  751. background: #fff;
  752. border: 1px solid rgba(0, 0, 0, 10%);
  753. border-radius: 8px;
  754. .aduioLine-box {
  755. width: 100%;
  756. border-bottom: 1px solid rgba(0, 0, 0, 10%);
  757. &-bottom {
  758. border-top: 1px solid rgba(0, 0, 0, 10%);
  759. border-bottom: none;
  760. }
  761. }
  762. }
  763. }
  764. }
  765. </style>
  766. <style lang="scss">
  767. .NPC-ArticleView {
  768. .ArticleView-header {
  769. .el-switch {
  770. margin-left: 24px;
  771. }
  772. .el-switch__core {
  773. width: 44px !important;
  774. height: 24px;
  775. border-radius: 20px;
  776. }
  777. .el-switch__core::after {
  778. top: 3px;
  779. left: 3px;
  780. }
  781. .el-switch.is-checked .el-switch__core::after {
  782. left: 100%;
  783. margin-left: -19px;
  784. }
  785. .el-switch__label {
  786. color: #000;
  787. }
  788. .el-switch__label.is-active {
  789. color: rgba($color: #000, $alpha: 30%);
  790. }
  791. .el-switch__label--left {
  792. margin-right: 8px;
  793. }
  794. }
  795. .pinyin-16 {
  796. cursor: pointer;
  797. // background: url('@/assets/icon/pinyin-16-normal-red.png') no-repeat left top;
  798. // background-size: 100% 100%;
  799. // &.disabled {
  800. // background: url('@/assets/icon/pinyin-16-disable-Black.png') no-repeat left top;
  801. // background-size: 100% 100%;
  802. // }
  803. }
  804. .EN-16 {
  805. cursor: pointer;
  806. // background: url('@/assets/icon/EN-16-normal-red.png') no-repeat left top;
  807. // background-size: 100% 100%;
  808. // &.disabled {
  809. // background: url('@/assets/icon/EN-16-disable-Black.png') no-repeat left top;
  810. // background-size: 100% 100%;
  811. // }
  812. }
  813. }
  814. .ArticleView-body {
  815. .aduioLine-box {
  816. width: 100%;
  817. border-bottom: 1px solid rgba(0, 0, 0, 10%);
  818. &-bottom {
  819. border-top: 1px solid rgba(0, 0, 0, 10%);
  820. border-bottom: none;
  821. }
  822. }
  823. }
  824. </style>