index.vue 27 KB

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