| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088 |
- <!-- eslint-disable vue/no-v-html -->
- <template>
- <div class="article-preview" :style="[getAreaStyle(), getComponentStyle()]">
- <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
- <div class="main">
- <div class="NPC-ArticleView NPC-ArticleView-container">
- <div class="ArticleView-header">
- <a class="ArticleView-full" :title="convertText('黑板模式')" @click="fullScreen">
- <svg-icon
- icon-class="icon-full"
- size="24"
- :style="{
- color: data.unified_attrib && data.unified_attrib.topic_color ? data.unified_attrib.topic_color : '',
- }"
- />
- </a>
- <div>
- <!-- v-if="
- (tokenData && tokenData.popedom_code_list && tokenData.popedom_code_list.indexOf(2100001) != -1) ||
- (tokenData && tokenData.user_type === 'APP')
- " -->
- <div
- class="left"
- :style="{ marginLeft: '40px', cursor: 'pointer' }"
- :title="convertText('文本分析')"
- @click="submit"
- >
- <!-- <img src="@/assets/wbfx-icon.png" alt="" /> -->
- <svg-icon
- icon-class="icon-wbfx"
- size="24"
- :style="{
- color: data.unified_attrib && data.unified_attrib.topic_color ? data.unified_attrib.topic_color : '',
- }"
- />
- </div>
- </div>
- <div class="right">
- <!-- <template v-if="data.property.is_enable_new_word === 'true'">
- <el-switch
- v-model="showPhrases"
- style="display: block"
- :active-color="bookInfo.theme_color"
- inactive-color="rgba(0,0,0,0.1)"
- active-text=""
- inactive-text="本课生词"
- @change="handleSwitchChange('showPractice', 'showWord')"
- />
- </template>
- <template v-if="data.property.is_enable_read === 'true'">
- <el-switch
- v-model="showPractice"
- style="display: block"
- :active-color="bookInfo.theme_color"
- inactive-color="rgba(0,0,0,0.1)"
- active-text=""
- inactive-text="语音练习"
- @change="handleSwitchChange('showPhrases', 'showWord')"
- />
- </template>
- <template v-if="data.property.is_enable_word === 'true'">
- <el-switch
- v-model="showWord"
- style="display: block"
- :active-color="bookInfo.theme_color"
- inactive-color="rgba(0,0,0,0.1)"
- active-text=""
- inactive-text="取词"
- @change="handleSwitchChange('showPhrases', 'showPractice')"
- />
- </template> -->
- <a
- v-if="data.property.is_enable_new_word === 'true'"
- :style="{
- color:
- showPhrases && data.unified_attrib && data.unified_attrib.topic_color
- ? data.unified_attrib.topic_color
- : '',
- }"
- :title="convertText('本课生词')"
- @click="handleSwitchChange('showPractice', 'showWord', 'showPhrases')"
- >
- <svg-icon icon-class="icon-article-ci" size="24" />
- </a>
- <a
- v-if="data.property.is_enable_read === 'true'"
- :style="{
- color:
- showPractice && data.unified_attrib && data.unified_attrib.topic_color
- ? data.unified_attrib.topic_color
- : '',
- }"
- :title="convertText('语音练习')"
- @click="handleSwitchChange('showPhrases', 'showWord', 'showPractice')"
- >
- <svg-icon icon-class="icon-article-practice" size="24" />
- </a>
- <a
- v-if="data.property.is_enable_word === 'true'"
- :style="{
- color:
- showWord && data.unified_attrib && data.unified_attrib.topic_color
- ? data.unified_attrib.topic_color
- : '',
- }"
- :title="convertText('取词模式')"
- @click="handleSwitchChange('showPhrases', 'showPractice', 'showWord')"
- >
- <svg-icon icon-class="icon-article-phrase" size="24" />
- </a>
- </div>
- </div>
- <div ref="ArticleViewbody" class="ArticleView-body">
- <NormalModelChs
- v-if="!showPhrases && !showPractice && !showWord"
- :cur-que="data"
- :title-fontsize="titleFontsize"
- :word-fontsize="wordFontsize"
- :body-left="bodyLeft"
- :body-width="bodyWidth"
- :attrib="data.unified_attrib"
- :is-mobile="isMobile"
- :no-font="noFont"
- :config="config"
- :NNPEAnnotationList="NNPEAnnotationList"
- :col-length="colLength"
- :multilingual="showLang && getLang() ? getLang() : ''"
- @changeConfig="changeConfig"
- />
- <PhraseModel
- v-if="showPhrases"
- :cur-que="data"
- :title-fontsize="titleFontsize"
- :word-fontsize="wordFontsize"
- :NNPENewWordList="NNPENewWordList"
- :attrib="data.unified_attrib"
- :is-mobile="isMobile"
- :no-font="noFont"
- :body-left="bodyLeft"
- :config="config"
- :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
- :NNPEAnnotationList="NNPEAnnotationList"
- :col-length="colLength"
- :NpcNewWordMp3="NpcNewWordMp3"
- :multilingual="showLang && getLang() ? getLang() : ''"
- @changeConfig="changeConfig"
- />
- <Practice
- v-if="showPractice"
- :cur-que="data"
- :title-fontsize="titleFontsize"
- :word-fontsize="wordFontsize"
- :attrib="data.unified_attrib"
- :is-mobile="isMobile"
- :no-font="noFont"
- :NNPENewWordList="NNPENewWordList"
- :NNPEAnnotationList="NNPEAnnotationList"
- :config="config"
- :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
- :col-length="colLength"
- :NpcNewWordMp3="NpcNewWordMp3"
- :is-full="isFull"
- :multilingual="showLang && getLang() ? getLang() : ''"
- @changeConfig="changeConfig"
- />
- <WordModel
- v-if="showWord"
- :cur-que="data"
- :title-fontsize="titleFontsize"
- :word-fontsize="wordFontsize"
- :body-left="bodyLeft"
- :body-width="bodyWidth"
- :NNPENewWordList="NNPENewWordList"
- :attrib="data.unified_attrib"
- :is-mobile="isMobile"
- :no-font="noFont"
- :config="config"
- :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
- :col-length="colLength"
- :multilingual="showLang && getLang() ? getLang() : ''"
- @changeConfig="changeConfig"
- />
- </div>
- <div :id="'screen-' + mathNum" class="voice-full-screen">
- <Voicefullscreen
- v-if="isFull && resObj"
- :theme-color="bookInfo.theme_color"
- :cur-que="data"
- :sent-list="resObj.sentList"
- :sent-index="0"
- :mp3="data.mp3_list && data.mp3_list[0] ? data.mp3_list[0].url : ''"
- :no-font="noFont"
- :NNPENewWordList="NNPENewWordList"
- :NNPEAnnotationList="NNPEAnnotationList"
- :is-full="isFull"
- :config="config"
- :TaskModel="isJudgingRightWrong ? 'ANSWER' : ''"
- :NpcNewWordMp3="NpcNewWordMp3"
- :attrib="data.unified_attrib"
- :is-mobile="isMobile"
- @handleWav="handleWav"
- @changePinyin="changePinyins"
- @changeEN="changeENs"
- @exitFullscreen="exitFullscreen"
- @changeIsFull="changeIsFull"
- />
- </div>
- </div>
- <template
- v-if="
- data.new_word_list &&
- data.new_word_list.new_word_list &&
- data.new_word_list.new_word_list.length > 0 &&
- data.new_word_list.property.is_show === 'true'
- "
- >
- <NewWordPreview :new-data="data.new_word_list" :is-mobile="isMobile" />
- </template>
- <template
- v-if="
- data.other_word_list &&
- data.other_word_list.new_word_list &&
- data.other_word_list.new_word_list.length > 0 &&
- data.other_word_list.property.is_show === 'true'
- "
- >
- <NewWordPreview :new-data="data.other_word_list" :is-mobile="isMobile" />
- </template>
- <template
- v-if="
- data.notes_list &&
- data.notes_list.option &&
- data.notes_list.option.length > 0 &&
- data.notes_list.property.is_show === 'true'
- "
- >
- <NotesPreview :notes-data="data.notes_list" :is-mobile="isMobile" />
- </template>
- </div>
- </div>
- </template>
- <script>
- import { getArticleData } from '@/views/book/courseware/data/dialogueArticle';
- import PreviewMixin from '../common/PreviewMixin';
- import PhraseModel from './PhraseModelChs.vue';
- import NormalModelChs from './NormalModelChs.vue';
- import Practice from './Practicechs.vue'; // 语音练习模式
- import WordModel from './WordModelChs.vue'; // 语音练习模式
- import Voicefullscreen from '../article/Voicefullscreen.vue';
- import { getToken } from '@/utils/auth';
- import { GetFileURLMap } from '@/api/app';
- import { analysSubmit, getSysConfig } from '@/api/article';
- import NewWordPreview from '../new_word/NewWordPreview.vue';
- import NotesPreview from '../notes/NotesPreview.vue';
- export default {
- name: 'DialogueArticlePreview',
- components: {
- NormalModelChs,
- Practice,
- WordModel,
- PhraseModel,
- Voicefullscreen,
- NewWordPreview,
- NotesPreview,
- },
- mixins: [PreviewMixin],
- inject: ['bookInfo'],
- props: ['isMobile'],
- data() {
- return {
- data: getArticleData(),
- showPreview: true, // 全文预览
- showPhrases: false, // 显示单词和短语
- showPractice: false, // 语音练习
- showWord: false, // 取词
- titleFontsize: 20, // 标题字号初始值
- wordFontsize: 16, // 文章内容字号初始值
- bodyLeft: 0,
- bodyWidth: 0,
- noFont: ['~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '/'],
- config: {
- isShowEN: false,
- isHasEN: false,
- isShowPY: false,
- isHasPY: false,
- },
- userAnswer: {
- normalModel: {
- recordList: [],
- },
- writeModel: {}, // 生词/取词模式
- practiceModel: {}, // 练习模式
- wordModel: {
- recordList: [],
- },
- },
- tokenData: getToken(),
- mathNum: Math.random().toString(36).substr(2),
- isFull: false,
- resObj: null,
- chsFhList: [',', '。', '”', ':', '》', '?', '!', ';', '、'],
- highWords: null,
- highWordsArr: [],
- highIndex: 0,
- newWordList: [],
- NNPEAnnotationList: [],
- NNPENewWordList: [],
- NpcNewWordMp3: [],
- colLength: 1,
- multilingualTextList: {},
- analyser_url: '',
- };
- },
- computed: {},
- watch: {
- showLang: {
- handler(val) {
- if (val) {
- this.data.multilingual.forEach((item) => {
- let trans_arr = item.translation ? item.translation.split('\n') : [];
- this.data.detail.forEach((items) => {
- let items_trans_arr = [];
- if (items && !items.hasOwnProperty('multilingualTextList')) {
- this.$set(items, 'multilingualTextList', {});
- }
- if (items.para) {
- items_trans_arr = trans_arr.splice(0, items.sentences.length);
- }
- this.$set(items.multilingualTextList, item.type, items_trans_arr);
- });
- });
- }
- },
- deep: true,
- immediate: true,
- },
- 'data.detail.length': {
- handler(val) {
- if (val) {
- this.handleData();
- let _this = this;
- _this.$nextTick(() => {
- _this.bodyLeft = _this.$refs.ArticleViewbody.getBoundingClientRect().left;
- });
- for (let i = 0; i < this.data.detail.length; i++) {
- let enStr = this.data.detail[i].sentencesEn ? this.data.detail[i].sentencesEn.join('') : '';
- if (enStr) {
- this.config.isShowEN = false;
- this.config.isHasEN = true;
- }
- let pinyin = this.handleObj(this.data.detail[i].wordsList);
- if (pinyin && this.isEnable(this.data.property.view_pinyin)) {
- this.config.isShowPY = true;
- this.config.isHasPY = true;
- }
- if (enStr && pinyin) {
- break;
- }
- }
- }
- },
- deep: true,
- immediate: true,
- },
- isJudgingRightWrong(val) {
- if (!val) return;
- this.data.Bookanswer = this.answer.answer_list;
- },
- },
- created() {},
- methods: {
- changeConfig(obj) {
- this.config[obj] = !this.config[obj];
- },
- changeIsFull() {
- this.isFull = false;
- },
- // 拼音的显示和隐藏
- changePinyins() {
- if (this.config.isHasPY) {
- this.changeConfig('isShowPY');
- }
- },
- // 英文的显示和隐藏
- changeENs() {
- if (this.config.isHasEN) {
- this.changeConfig('isShowEN');
- }
- },
- // 处理字体大小
- handleFontsize(symbol) {
- if (symbol === '+') {
- if (this.wordFontsize < 24) {
- this.titleFontsize += 2;
- this.wordFontsize += 2;
- }
- } else if (symbol === '-') {
- if (this.wordFontsize > 12) {
- this.titleFontsize -= 2;
- this.wordFontsize -= 2;
- }
- }
- },
- // 切换开关
- handleSwitchChange(obj1, obj2, obj3) {
- this[obj1] = false;
- this[obj2] = false;
- this[obj3] = !this[obj3];
- this.showPreview = false;
- },
- handleObj(list) {
- let pinyin = '';
- list.forEach((item) => {
- item.forEach((items) => {
- if (items.pinyin) pinyin += items.pinyin;
- });
- });
- return pinyin;
- },
- submit() {
- let access_token =
- this.tokenData && this.tokenData.gcls_sys_session_info
- ? this.tokenData.gcls_sys_session_info.access_token
- : this.tokenData && this.tokenData.access_token
- ? this.tokenDataaccess_token
- : '';
- let loading = this.$loading({
- lock: true,
- text: 'Loading',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)',
- });
- getSysConfig()
- .then((ress) => {
- let content = '';
- this.data.detail.forEach((item) => {
- content += `${item.para}\n`;
- });
- analysSubmit({
- app_user_id: '',
- text: content,
- })
- .then((res) => {
- window.open(
- `${ress.text_analyser_page_address}GCLS-TC/#/textanalysis/Result?id=${res.record.id}&type=文本分析&AccessToken=${access_token}&fromEEP=true`,
- );
- loading.close();
- })
- .catch((res) => {
- loading.close();
- });
- })
- .catch((res) => {
- loading.close();
- });
- },
- // 语音全屏
- fullScreen() {
- this.pauseAudio();
- this.pauseVideo();
- this.isFull = true;
- // this.goFullscreen();
- },
- pauseAudio() {
- let audio = document.getElementsByTagName('audio');
- if (audio && audio.length > 0 && window.location.href.indexOf('GCLS-Learn') === -1 && audio.forEach) {
- audio.forEach((item) => {
- item.pause();
- });
- }
- },
- pauseVideo() {
- let video = document.getElementsByTagName('video');
- if (video && video.length > 0 && window.location.href.indexOf('GCLS-Learn') === -1 && video.forEach) {
- video.forEach((item) => {
- item.pause();
- });
- }
- },
- goFullscreen() {
- let id = `screen-${this.mathNum}`;
- let element = document.getElementById(id);
- if (element.requestFullscreen) {
- element.requestFullscreen();
- } else if (element.msRequestFullscreen) {
- element.msRequestFullscreen();
- } else if (element.mozRequestFullScreen) {
- element.mozRequestFullScreen();
- } else if (element.webkitRequestFullscreen) {
- element.webkitRequestFullscreen();
- }
- },
- exitFullscreen() {
- this.isFull = false;
- // if (document.exitFullscreen) {
- // document.exitFullscreen();
- // } else if (document.msExitFullscreen) {
- // document.msExitFullscreen();
- // } else if (document.mozCancelFullScreen) {
- // document.mozCancelFullScreen();
- // } else if (document.webkitExitFullscreen) {
- // document.webkitExitFullscreen();
- // }
- },
- handleData() {
- if (this.data.new_word_list) {
- this.$set(this.data.new_word_list, 'unified_attrib', this.data.unified_attrib);
- }
- if (this.data.other_word_list) {
- this.$set(this.data.other_word_list, 'unified_attrib', this.data.unified_attrib);
- }
- if (this.data.notes_list) {
- this.$set(this.data.notes_list, 'unified_attrib', this.data.unified_attrib);
- }
- if (this.showLang) {
- this.data.multilingual.forEach((item) => {
- let trans_arr = item.translation ? item.translation.split('\n') : [];
- this.data.detail.forEach((items) => {
- let items_trans_arr = [];
- if (!items.hasOwnProperty('multilingualTextList')) {
- this.$set(items, 'multilingualTextList', {});
- }
- if (items.para) {
- items_trans_arr = trans_arr.splice(0, items.sentences.length);
- }
- this.$set(items.multilingualTextList, item.type, items_trans_arr);
- });
- });
- }
- let userAnswer = JSON.parse(JSON.stringify(this.userAnswer));
- this.$set(this.data, 'Bookanswer', userAnswer);
- if (!this.isJudgingRightWrong) {
- this.answer.answer_list = this.data.Bookanswer;
- }
- if (this.data.mp3_list && this.data.mp3_list.length > 0) {
- this.data.mp3_list[0].url = this.data.mp3_list[0].temporary_url;
- // GetFileURLMap({ file_id_list: [this.data.mp3_list[0].file_id] }).then(({ url_map }) => {
- // this.data.mp3_list[0].url = url_map[this.data.mp3_list[0].file_id];
- // });
- }
- // 处理课文里生词表的音频和时间
- if (this.data.new_word_list && this.data.new_word_list.new_word_list) {
- if (this.data.new_word_list.audio_data && this.data.new_word_list.audio_data.temporary_url) {
- // 如果大音频存在
- this.data.new_word_list.new_word_list.forEach((item, index) => {
- this.$set(item, 'audio_file_url', this.data.new_word_list.audio_data.temporary_url);
- this.$set(
- item,
- 'audio_begin_time',
- this.data.new_word_list.lrc_arr[index] ? this.data.new_word_list.lrc_arr[index].bg : null,
- );
- this.$set(
- item,
- 'audio_end_time',
- this.data.new_word_list.lrc_arr[index] ? this.data.new_word_list.lrc_arr[index].ed : null,
- );
- });
- } else {
- let mp3_list = [];
- this.data.new_word_list.new_word_list.forEach((item, index) => {
- mp3_list.push(item.mp3_list);
- });
- GetFileURLMap({ file_id_list: mp3_list }).then(({ url_map }) => {
- this.data.new_word_list.new_word_list.forEach((item, index) => {
- this.$set(item, 'audio_file_url', url_map[item.mp3_list]);
- this.$set(item, 'audio_begin_time', null);
- this.$set(item, 'audio_end_time', null);
- });
- });
- }
- }
- // 处理课文里其他词汇表的音频和时间
- if (this.data.other_word_list && this.data.other_word_list.new_word_list) {
- if (this.data.other_word_list.audio_data && this.data.other_word_list.audio_data.temporary_url) {
- // 如果大音频存在
- this.data.other_word_list.new_word_list.forEach((item, index) => {
- this.$set(item, 'audio_file_url', this.data.other_word_list.audio_data.temporary_url);
- this.$set(
- item,
- 'audio_begin_time',
- this.data.other_word_list.lrc_arr[index] ? this.data.other_word_list.lrc_arr[index].bg : -1,
- );
- this.$set(
- item,
- 'audio_end_time',
- this.data.other_word_list.lrc_arr[index] ? this.data.other_word_list.lrc_arr[index].ed : -1,
- );
- });
- } else {
- let mp3_list = [];
- this.data.other_word_list.new_word_list.forEach((item, index) => {
- mp3_list.push(item.mp3_list);
- });
- GetFileURLMap({ file_id_list: mp3_list }).then(({ url_map }) => {
- this.data.other_word_list.new_word_list.forEach((item, index) => {
- this.$set(item, 'audio_file_url', url_map[item.mp3_list]);
- this.$set(item, 'audio_begin_time', null);
- this.$set(item, 'audio_end_time', null);
- });
- });
- }
- }
- if (this.data.new_word_list_other_component_input) {
- this.data.new_word_list_other_component_input.forEach((item) => {
- if (item.audio_begin_time === -1) {
- item.audio_begin_time = null;
- item.audio_end_time = null;
- }
- });
- }
- this.NNPENewWordList = (
- this.data.new_word_list_other_component_input ? this.data.new_word_list_other_component_input : []
- )
- .concat(
- this.data.new_word_list && this.data.new_word_list.new_word_list ? this.data.new_word_list.new_word_list : [],
- )
- .concat(
- this.data.other_word_list && this.data.other_word_list.new_word_list
- ? this.data.other_word_list.new_word_list
- : [],
- );
- this.NNPEAnnotationList = this.data.notes_list && this.data.notes_list.option ? this.data.notes_list.option : [];
- let resArr = [];
- let sentArrTotal = [];
- let timeArr = [];
- let curQue = JSON.parse(JSON.stringify(this.data));
- let wordTimeList = curQue.wordTime;
- let dhaspinyin = false; // 每段是否有拼音
- let dhaspinyinArr = [];
- curQue.detail.forEach((dItem, dIndex) => {
- dhaspinyin = false;
- dItem.wordsList.forEach((sItem, sIndex) => {
- let sentArr = [];
- let sentence = dItem.sentences[sIndex];
- sItem.forEach((wItem, wIndex) => {
- let startIndex = wIndex === 0 ? 0 : sentArr[wIndex - 1].startIndex + sentArr[wIndex - 1].chs.length;
- let endIndex = wIndex === 0 ? wItem.chs.length : sentArr[wIndex - 1].endIndex + wItem.chs.length;
- // this.judgePad(sItem, wItem, wIndex);
- this.mergeWordSymbol(wItem);
- let words = '';
- if (this.newWordList.length > 0) {
- if (!this.highWords) {
- this.findLightWord(wItem, wIndex, sentence, sItem);
- words = this.highWords ? this.highWords.words : '';
- } else if (wIndex > this.highWords.endIndex - 1) {
- this.highWords = null;
- this.findLightWord(wItem, wIndex, sentence, sItem);
- words = this.highWords ? this.highWords.words : '';
- } else {
- words = this.highWords ? this.highWords.words : '';
- }
- }
- let obj = {
- paraIndex: dIndex, // 段落索引
- sentIndex: sIndex, // 在段落中句子索引
- wordIndex: wIndex, // 单词的索引
- pinyin: wItem.pinyin,
- chs: wItem.chs,
- padding: true,
- className: wItem.className,
- isShow: wItem.isShow,
- startIndex,
- endIndex,
- leg: wItem.chs.length,
- timeList: [],
- words,
- config: {
- fontFamily: wItem.fontFamily,
- color: wItem.color,
- textDecoration: wItem.textDecoration,
- border: wItem.border,
- fontWeight: wItem.fontWeight,
- },
- matchWords: wItem.matchWords,
- matchNotes: wItem.matchNotes,
- notesColor: wItem.notesColor,
- matchNotesObj: wItem.matchNotesObj,
- img: wItem.img,
- imgPosition: wItem.imgPosition,
- };
- sentArr.push(obj);
- if (wItem.pinyin) dhaspinyin = true;
- });
- let objs = {
- sentArr,
- enwords: dItem.sentencesEn && dItem.sentencesEn[sIndex] && dItem.sentencesEn[sIndex].replace(/'/g, '’'),
- };
- sentArrTotal.push(sentArr);
- resArr.push(objs);
- });
- timeArr.push(dItem.timeList);
- if (this.isEnable(curQue.property.view_pinyin)) {
- dhaspinyinArr.push(dhaspinyin);
- }
- });
- if (wordTimeList && wordTimeList.length > 0) {
- this.mergeWordTime(sentArrTotal, wordTimeList);
- }
- let timeList = [];
- timeArr.forEach((item) => {
- item.forEach((aItem) => {
- if (timeList.indexOf(aItem) < 0) {
- timeList.push(aItem);
- }
- });
- });
- this.resObj = {
- sentList: resArr,
- timeList,
- dhaspinyinArr,
- };
- },
- mergeWordTime(resArr, wordTimeList) {
- resArr.forEach((item, index) => {
- let wordsResultList = wordTimeList[index].wordsResultList;
- item.forEach((wItem) => {
- let startIndex = wItem.startIndex;
- let endIndex = wItem.endIndex;
- wItem.timeList = wordsResultList.slice(startIndex, endIndex);
- });
- });
- },
- findLightWord(wItem, startIndex, sentence, sItem) {
- let endIndex = 0;
- let words = '';
- this.newWordList.forEach((item) => {
- if (item.length === 1) {
- if (item === wItem.chs && !wItem.banLight) {
- words = wItem.chs;
- endIndex = startIndex + 1;
- }
- } else if (item[0] === wItem.chs && sentence.indexOf(item) > -1) {
- let index = null;
- let chsStr = '';
- for (let i = startIndex; i < sItem.length + 1; i++) {
- index = i;
- if (chsStr.length === item.length) {
- break;
- } else {
- chsStr += sItem[i] ? sItem[i].chs : '';
- }
- }
- if (chsStr === item && !wItem.banLight) {
- words = item;
- endIndex = index;
- }
- } else if (wItem.new_word && wItem.new_word === item && !wItem.banLight) {
- words = item;
- endIndex = startIndex + 1;
- }
- });
- if (words) {
- this.highWords = { words, endIndex };
- } else {
- this.highWords = null;
- }
- },
- // 词和标点合一起
- mergeWordSymbol(wItem) {
- if (this.chsFhList.indexOf(wItem.chs) > -1) {
- wItem.isShow = false;
- } else {
- wItem.isShow = true;
- }
- },
- handleWav(list, tmIndex) {
- let i = tmIndex || 0;
- this.data.Bookanswer.practiceModel[i] = {
- recordList: [],
- };
- this.$set(this.data.Bookanswer.practiceModel[i], 'recordList', list);
- },
- handleNewword() {
- let NewWordList = [];
- this.NNPENewWordList.forEach((wItem) => {
- // item.forEach((wItem) => {
- if (wItem.new_word) {
- NewWordList.push(wItem.new_word);
- } else if (wItem.detail && wItem.detail.sentence) {
- NewWordList.push(wItem.detail.sentence);
- }
- // });
- });
- this.newWordList = JSON.parse(JSON.stringify(NewWordList));
- },
- /**
- * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
- */
- getNoTextContentData() {
- let noTextContentData = JSON.parse(JSON.stringify(this.data));
- const resetFieldMap = {
- content: '', // 课文内容
- mp3_list: [], // 音频列表
- detail: [], // 分段分句分词详情
- wordTime: [], // 字幕时间
- new_word_list: {
- title_con: '',
- property: {
- audio_generation_method: 'upload',
- pinyin_position: 'front',
- auto_wrap: 'true', // 自动换行
- is_has_infor: 'true',
- voice_type: '', // 音色
- emotion: '', // 风格,情感
- speed_ratio: '', // 语速
- is_show: 'false',
- },
- new_word_list: [],
- lrc_arr: [], // lrc 文件解析后的数据
- // lrc 文件数据
- lrc_data: {
- name: '',
- url: '',
- id: '',
- file_id: '',
- },
- // 音频文件数据
- audio_data: {
- name: '',
- media_duration: 0,
- temporary_url: '',
- url: '',
- file_id: '',
- },
- wordTime: [], // 字幕时间节点
- taskId: '',
- file_id_list: [], // 文件 id
- multilingual: [], // 多语言
- }, // 生词列表
- other_word_list: {
- title_con: '',
- property: {
- audio_generation_method: 'upload',
- pinyin_position: 'front',
- auto_wrap: 'true', // 自动换行
- is_has_infor: 'true',
- voice_type: '', // 音色
- emotion: '', // 风格,情感
- speed_ratio: '', // 语速
- is_show: 'false',
- },
- new_word_list: [],
- lrc_arr: [], // lrc 文件解析后的数据
- // lrc 文件数据
- lrc_data: {
- name: '',
- url: '',
- id: '',
- file_id: '',
- },
- // 音频文件数据
- audio_data: {
- name: '',
- media_duration: 0,
- temporary_url: '',
- url: '',
- file_id: '',
- },
- wordTime: [], // 字幕时间节点
- taskId: '',
- file_id_list: [], // 文件 id
- multilingual: [], // 多语言
- },
- notes_list: {
- title_con: '',
- option: [],
- multilingual: [], // 多语言
- file_id_list: [], // 文件 id
- property: {
- view_pinyin: 'false', // 显示拼音
- pinyin_position: 'back', // top bottom
- is_first_sentence_first_hz_pinyin_first_char_upper_case: 'true', // 句首大写
- is_show: 'false',
- },
- },
- sentence_list_mp: [], // 句子+分词数组
- pinyin_type: 'pinyin',
- };
- Object.assign(noTextContentData, resetFieldMap);
- return noTextContentData;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- @use '@/styles/mixin.scss' as *;
- .article-preview {
- @include preview-base;
- .main {
- display: grid;
- row-gap: 24px;
- // align-items: center;
- }
- .NPC-ArticleView {
- width: 100%;
- .ArticleView-full {
- position: absolute;
- top: 0;
- left: 0;
- z-index: 1;
- font-size: 16px;
- font-weight: bold;
- line-height: 24px;
- color: #000;
- cursor: pointer;
- // background: url('@/assets/full-screen-red.png') left center no-repeat;
- // background-size: 20px 20px;
- }
- .ArticleView-header {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 24px;
- margin-bottom: 16px;
- .left {
- display: flex;
- align-items: center;
- justify-content: center;
- // padding-left: 24px;
- font-size: 16px;
- font-weight: bold;
- line-height: 24px;
- cursor: pointer;
- // background: url('@/assets/wbfx-icon.png') left center no-repeat;
- // background-size: 20px;
- img {
- width: 20px;
- height: 20px;
- margin-right: 4px;
- }
- }
- .right {
- display: flex;
- gap: 24px;
- a {
- display: flex;
- gap: 4px;
- align-items: center;
- color: rgba(0, 0, 0, 65%);
- cursor: pointer;
- }
- }
- .setting-fontsize {
- display: flex;
- margin-left: 24px;
- a {
- box-sizing: border-box;
- display: block;
- width: 24px;
- height: 24px;
- border: 1px solid rgba(0, 0, 0, 10%);
- border-radius: 4px;
- }
- img {
- width: 100%;
- }
- > img {
- width: 24px;
- margin: 0 8px;
- }
- }
- }
- .ArticleView-body {
- box-sizing: border-box;
- border: 1px solid rgba(0, 0, 0, 10%);
- border-radius: 4px;
- .aduioLine-box {
- width: 100%;
- border-bottom: 1px solid rgba(0, 0, 0, 10%);
- &-bottom {
- border-top: 1px solid rgba(0, 0, 0, 10%);
- border-bottom: none;
- }
- }
- }
- }
- }
- </style>
- <style lang="scss">
- .NPC-ArticleView {
- .ArticleView-header {
- .el-switch {
- margin-left: 24px;
- }
- .el-switch__core {
- width: 44px !important;
- height: 24px;
- border-radius: 20px;
- }
- .el-switch__core::after {
- top: 3px;
- left: 3px;
- }
- .el-switch.is-checked .el-switch__core::after {
- left: 100%;
- margin-left: -19px;
- }
- .el-switch__label {
- color: #000;
- }
- .el-switch__label.is-active {
- color: rgba($color: #000, $alpha: 30%);
- }
- .el-switch__label--left {
- margin-right: 8px;
- }
- }
- .pinyin-16 {
- cursor: pointer;
- // background: url('@/assets/icon/pinyin-16-normal-red.png') no-repeat left top;
- // background-size: 100% 100%;
- // &.disabled {
- // background: url('@/assets/icon/pinyin-16-disable-Black.png') no-repeat left top;
- // background-size: 100% 100%;
- // }
- }
- .EN-16 {
- cursor: pointer;
- // background: url('@/assets/icon/EN-16-normal-red.png') no-repeat left top;
- // background-size: 100% 100%;
- // &.disabled {
- // background: url('@/assets/icon/EN-16-disable-Black.png') no-repeat left top;
- // background-size: 100% 100%;
- // }
- }
- }
- .ArticleView-body {
- .aduioLine-box {
- width: 100%;
- border-bottom: 1px solid rgba(0, 0, 0, 10%);
- &-bottom {
- border-top: 1px solid rgba(0, 0, 0, 10%);
- border-bottom: none;
- }
- }
- .el-slider {
- flex: 1;
- width: auto !important;
- }
- }
- </style>
|