فهرست منبع

对话课文语境内容支持分词及添加样式

natasha 2 روز پیش
والد
کامیت
0f7c42f713

+ 11 - 0
src/views/book/courseware/create/components/question/article/CheckArticle.vue

@@ -219,6 +219,17 @@ export default {
             });
             item.sentenceStr.push(str);
           });
+        } else if (item.noticeSegList && item.noticeSegList.length > 0) {
+          item.sentenceStr = [];
+          item.noticeSegList.forEach((items, indexs) => {
+            let str = '';
+            items.forEach((itemss, indexss) => {
+              str += itemss;
+
+              if (indexss !== items.length - 1) str += '  ';
+            });
+            item.sentenceStr.push(str);
+          });
         }
       });
     },

+ 2 - 0
src/views/book/courseware/create/components/question/article/CheckPinyin.vue

@@ -146,6 +146,8 @@ export default {
       // 添加索引
       newdata.forEach((item, index) => {
         arr.push([]);
+        if (item.type === 'notice') return;
+
         item.wordsList.forEach((items, indexs) => {
           items.forEach((itemss, indexss) => {
             let pinyin =

+ 61 - 29
src/views/book/courseware/create/components/question/article/CheckStyle.vue

@@ -180,7 +180,7 @@ export default {
       this.loading = true;
       let newdata = [];
       this.data.detail.forEach((item) => {
-        if (item.wordsList.length !== 0) {
+        if (item.wordsList.length !== 0 || (item.noticeWordList && item.noticeWordList.length !== 0)) {
           newdata.push(item);
         }
       });
@@ -191,35 +191,67 @@ export default {
       // 添加索引
       newdata.forEach((item, index) => {
         arr.push([]);
-        item.wordsList.forEach((items, indexs) => {
-          items.forEach((itemss, indexss) => {
-            let obj = {
-              text: itemss.chs,
-              paraIndex: index,
-              sentenceIndex: indexs,
-              wordIndex: indexss,
-              marginRight: true,
-              saveIndex,
-              fontFamily: itemss.fontFamily,
-              textDecoration: itemss.textDecoration,
-              fontWeight: itemss.fontWeight,
-              border: itemss.border,
-              color: itemss.color,
-              matchWords: itemss.matchWords,
-              matchNotes: itemss.matchNotes,
-              notesColor: itemss.notesColor,
-              img: itemss.img,
-              imgPosition: itemss.imgPosition,
-            };
-            arr[index].push(obj);
-            let saveObj = {
-              word: itemss.chs,
-              // pinyin_lt: itemss.pinyin_lt?itemss.pinyin_lt:''
-            };
-            saveArr.push(saveObj);
-            saveIndex++;
+        if (item.wordsList.length > 0) {
+          item.wordsList.forEach((items, indexs) => {
+            items.forEach((itemss, indexss) => {
+              let obj = {
+                text: itemss.chs,
+                paraIndex: item.paraIndex,
+                sentenceIndex: indexs,
+                wordIndex: indexss,
+                marginRight: true,
+                saveIndex,
+                fontFamily: itemss.fontFamily,
+                textDecoration: itemss.textDecoration,
+                fontWeight: itemss.fontWeight,
+                border: itemss.border,
+                color: itemss.color,
+                matchWords: itemss.matchWords,
+                matchNotes: itemss.matchNotes,
+                notesColor: itemss.notesColor,
+                img: itemss.img,
+                imgPosition: itemss.imgPosition,
+              };
+              arr[index].push(obj);
+              let saveObj = {
+                word: itemss.chs,
+                // pinyin_lt: itemss.pinyin_lt?itemss.pinyin_lt:''
+              };
+              saveArr.push(saveObj);
+              saveIndex++;
+            });
           });
-        });
+        } else {
+          item.noticeWordList.forEach((items, indexs) => {
+            items.forEach((itemss, indexss) => {
+              let obj = {
+                text: itemss.chs,
+                paraIndex: item.paraIndex,
+                sentenceIndex: indexs,
+                wordIndex: indexss,
+                marginRight: true,
+                saveIndex,
+                fontFamily: itemss.fontFamily,
+                textDecoration: itemss.textDecoration,
+                fontWeight: itemss.fontWeight,
+                border: itemss.border,
+                color: itemss.color,
+                matchWords: itemss.matchWords,
+                matchNotes: itemss.matchNotes,
+                notesColor: itemss.notesColor,
+                img: itemss.img,
+                imgPosition: itemss.imgPosition,
+              };
+              arr[index].push(obj);
+              let saveObj = {
+                word: itemss.chs,
+                // pinyin_lt: itemss.pinyin_lt?itemss.pinyin_lt:''
+              };
+              saveArr.push(saveObj);
+              saveIndex++;
+            });
+          });
+        }
       });
       this.indexArr = arr;
       this.ArticelData = saveArr;

+ 8 - 0
src/views/book/courseware/create/components/question/article/CheckWord.vue

@@ -51,6 +51,14 @@ export default {
             });
             str += '\n';
           });
+        } else if (item.noticeSegList && item.noticeSegList.length > 0) {
+          item.sentenceStr = [];
+          item.noticeSegList.forEach((items, indexs) => {
+            items.forEach((itemss, indexss) => {
+              str += itemss + (indexss !== items.length - 1 ? '  ' : '');
+            });
+            str += '\n';
+          });
         }
 
         if (index !== this.data.detail.length - 1) {

+ 82 - 27
src/views/book/courseware/create/components/question/dialogue_article/Article.vue

@@ -586,7 +586,6 @@ export default {
           type: 'notice',
           paraIndex: 0,
           sentences: [],
-          segList: [],
           seg_words: [],
           wordsList: [],
           timeList: [],
@@ -602,9 +601,11 @@ export default {
             obj.roleIndex = null;
             obj.notice = content;
             obj.type = 'notice';
+            this.$set(obj, 'noticeSegList', []);
           } else {
             obj.para = content;
             obj.type = 'text';
+            this.$set(obj, 'segList', []);
             let role = this.data.property.role_list.find((items) => items.fullName === prefix);
             if (!role) {
               // 角色名不存在
@@ -625,6 +626,7 @@ export default {
           obj.roleIndex = this.curRole;
           obj.para = content;
           obj.type = 'text';
+          this.$set(obj, 'segList', []);
         }
         this.data.detail.push(obj);
       });
@@ -739,8 +741,11 @@ export default {
         item.paraIndex = index;
         if (item.type === 'text') {
           textList += `${item.para}\n`;
+        } else if (item.type === 'notice') {
+          textList += `${item.notice}\n`;
         }
       });
+
       BatchSegContent({
         text: textList,
         is_build_pinyin: 'true',
@@ -754,7 +759,7 @@ export default {
             let i = 0;
             this.data.detail.forEach((item, index) => {
               item.paraIndex = index;
-              if (item.type === 'text') {
+              if (item.type === 'text' || item.type === 'notice') {
                 let sentenceList = []; // 句子按段数组
                 let segList = []; // 句子分词结果
                 res.paragraph_list[i].forEach((items) => {
@@ -764,8 +769,12 @@ export default {
                   segList.push(seg);
                 });
                 this.data.detail[index].sentences = sentenceList;
-                this.data.detail[index].segList = segList;
-                this.setWordsList(res.paragraph_list[i], index);
+                if (item.type === 'text') {
+                  this.data.detail[index].segList = segList;
+                } else {
+                  this.data.detail[index].noticeSegList = segList;
+                }
+                this.setWordsList(res.paragraph_list[i], index, item.type);
                 i++;
               }
             });
@@ -833,12 +842,20 @@ export default {
       this.data.detail.forEach((item) => {
         item.sentences.forEach((items, indexs) => {
           let word_list = [];
-
-          item.segList[indexs].forEach((itemw) => {
-            word_list.push({
-              word: itemw,
+          if (item.type === 'text') {
+            item.segList[indexs].forEach((itemw) => {
+              word_list.push({
+                word: itemw,
+              });
             });
-          });
+          } else if (item.type === 'notice') {
+            item.noticeSegList[indexs].forEach((itemw) => {
+              word_list.push({
+                word: itemw,
+              });
+            });
+          }
+
           let obj = {
             sentence: items,
             word_list,
@@ -847,7 +864,7 @@ export default {
         });
       });
     },
-    setWordsList(list, paraIndex) {
+    setWordsList(list, paraIndex, type) {
       let wordsList = [];
       list.forEach((item, index) => {
         let sentArr = [];
@@ -868,7 +885,7 @@ export default {
             pinyin: sItem.pinyin,
             pinyin_up: sItem.pinyin_up,
             pinyin_tone: sItem.pinyin_tone,
-            fontFamily: '楷体',
+            fontFamily: type === 'text' ? '楷体' : '',
             textDecoration: '',
             fontWeight: '',
             border: '',
@@ -883,7 +900,11 @@ export default {
         });
         wordsList.push(sentArr);
       });
-      this.data.detail[paraIndex].wordsList = wordsList;
+      if (type === 'text') {
+        this.data.detail[paraIndex].wordsList = wordsList;
+      } else {
+        this.$set(this.data.detail[paraIndex], 'noticeWordList', wordsList);
+      }
     },
     uploadAudioSuccess(fileList) {
       if (fileList.length > 0) {
@@ -920,6 +941,8 @@ export default {
         item.paraIndex = index;
         if (item.type === 'text') {
           textList += `${item.para}\n`;
+        } else if (item.type === 'notice') {
+          textList += `${item.notice}\n`;
         }
       });
       BatchSegContent({
@@ -941,7 +964,7 @@ export default {
               let sentence = items.reduce((acc, itemss) => `${acc + itemss.text}`, '');
               let sentenceS = items.reduce((acc, itemss) => `${acc + itemss.text}  `, '');
               let seg = items.map((itemss) => itemss.text);
-              para += items.map((itemss) => itemss.text);
+              para += items.map((itemss) => itemss.text).join('');
               sentenceList.push(sentence);
               sentenceStr.push(sentenceS);
               segList.push(seg);
@@ -952,7 +975,7 @@ export default {
                   pinyin: sItem.pinyin,
                   pinyin_up: sItem.pinyin_up,
                   pinyin_tone: sItem.pinyin_tone,
-                  fontFamily: '楷体',
+                  fontFamily: this.data.detail[index] && this.data.detail[index].type === 'notice' ? '' : '楷体',
                   textDecoration: '',
                   fontWeight: '',
                   border: '',
@@ -968,17 +991,36 @@ export default {
               wordsList.push(sentArr);
             });
             if (this.data.detail[index]) {
-              this.data.detail[index].segList = segList;
               this.data.detail[index].para = para;
+
               this.data.detail[index].sentenceStr = sentenceStr;
               this.data.detail[index].sentences = sentenceList;
-              this.data.detail[index].wordsList = wordsList;
+              if (this.data.detail[index].type === 'text') {
+                this.data.detail[index].wordsList = wordsList;
+                this.data.detail[index].segList = segList;
+              } else {
+                this.$set(this.data.detail[index], 'noticeWordList', wordsList);
+                this.$set(this.data.detail[index], 'noticeSegList', segList);
+              }
             } else {
               let obj = {
+                roleIndex: this.curRole,
                 paraIndex: index,
                 para,
+                type: 'text',
+
+                remark: {
+                  chs: '',
+                  en: '',
+                  heightNumber: null,
+                  img_list: [],
+                  widthNumber: null,
+                  chsBg: '#988ed6',
+                  enBg: '#fff',
+                },
+                paraIndex: index,
                 sentences: sentenceList,
-                segList: item,
+                segList: segList,
                 seg_words: [],
                 wordsList,
                 timeList: [],
@@ -1019,16 +1061,29 @@ export default {
       img,
       imgPosition,
     ) {
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontFamily = fontFamily;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].textDecoration = textDecoration;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontWeight = fontWeight;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].border = border;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].color = color;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchWords = matchWords;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchNotes = matchNotes;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].notesColor = notesColor;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].img = img;
-      this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].imgPosition = imgPosition;
+      if (this.data.detail[paraIndex].type === 'notice') {
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].fontFamily = fontFamily;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].textDecoration = textDecoration;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].fontWeight = fontWeight;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].border = border;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].color = color;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].matchWords = matchWords;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].matchNotes = matchNotes;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].notesColor = notesColor;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].img = img;
+        this.data.detail[paraIndex].noticeWordList[sentenceIndex][wordIndex].imgPosition = imgPosition;
+      } else {
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontFamily = fontFamily;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].textDecoration = textDecoration;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].fontWeight = fontWeight;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].border = border;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].color = color;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchWords = matchWords;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].matchNotes = matchNotes;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].notesColor = notesColor;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].img = img;
+        this.data.detail[paraIndex].wordsList[sentenceIndex][wordIndex].imgPosition = imgPosition;
+      }
     },
     // 保存校对
     saveCompare() {

+ 29 - 0
src/views/book/courseware/preview/components/dialogue_article/NormalModelChs.vue

@@ -95,9 +95,34 @@
                   fontSize: curQue.property.notice_size ? curQue.property.notice_size + 'px' : '',
                   color: curQue.property.notice_color ? curQue.property.notice_color : '',
                 }"
+                v-if="item.noticeWordList.length === 0"
               >
                 {{ convertText(item.notice) }}
               </p>
+              <p
+                :class="['notice']"
+                :style="{
+                  fontSize: curQue.property.notice_size ? curQue.property.notice_size + 'px' : '',
+                  color: curQue.property.notice_color ? curQue.property.notice_color : '',
+                }"
+                v-else
+              >
+                <span v-for="(items, indexs) in item.noticeWordList" :key="indexs">
+                  <span
+                    v-for="(pItem, indexss) in items"
+                    :key="indexss"
+                    :style="{
+                      fontFamily: pItem.fontFamily,
+                      textDecoration: pItem.textDecoration,
+                      borderBottom: pItem.border === 'dotted' ? '1px dotted' : '',
+                      fontWeight: pItem.fontWeight,
+                      color: pItem.color,
+                    }"
+                  >
+                    {{ convertText(pItem.chs) }}
+                  </span>
+                </span>
+              </p>
             </template>
             <template v-else>
               <RoleChs :cur-role="item.roleDetail" :type="curQue.property.role_img_type" />
@@ -1034,6 +1059,9 @@ export default {
         let startLeg = dIndex === 0 ? 0 : curQue.detail[dIndex - 1].endLeg;
         let endLeg = startLeg + curSentencesLeg;
         dItem.endLeg = endLeg;
+        if (dItem.type === 'notice') {
+          dItem.endLeg = dIndex === 0 ? 0 : curQue.detail[dIndex - 1].endLeg;
+        }
         let timeList = [];
         if (curQue.wordTime && curQue.wordTime.length > 0 && dItem.type === 'text') {
           timeList = curQue.wordTime.slice(startLeg, endLeg);
@@ -1049,6 +1077,7 @@ export default {
           dhaspinyin,
           type: dItem.type,
           notice: dItem.notice,
+          noticeWordList: dItem.noticeWordList,
           notice_size: dItem.notice_size,
           notice_color: dItem.notice_color,
           file_url_open: dItem.file_url_open,

+ 29 - 0
src/views/book/courseware/preview/components/dialogue_article/PhraseModelChs.vue

@@ -86,9 +86,34 @@
                   fontSize: curQue.property.notice_size ? curQue.property.notice_size + 'px' : '',
                   color: curQue.property.notice_color ? curQue.property.notice_color : '',
                 }"
+                v-if="item.noticeWordList.length === 0"
               >
                 {{ convertText(item.notice) }}
               </p>
+              <p
+                :class="['notice']"
+                :style="{
+                  fontSize: curQue.property.notice_size ? curQue.property.notice_size + 'px' : '',
+                  color: curQue.property.notice_color ? curQue.property.notice_color : '',
+                }"
+                v-else
+              >
+                <span v-for="(items, indexs) in item.noticeWordList" :key="indexs">
+                  <span
+                    v-for="(pItem, indexss) in items"
+                    :key="indexss"
+                    :style="{
+                      fontFamily: pItem.fontFamily,
+                      textDecoration: pItem.textDecoration,
+                      borderBottom: pItem.border === 'dotted' ? '1px dotted' : '',
+                      fontWeight: pItem.fontWeight,
+                      color: pItem.color,
+                    }"
+                  >
+                    {{ convertText(pItem.chs) }}
+                  </span>
+                </span>
+              </p>
             </template>
             <template v-else>
               <RoleChs :cur-role="item.roleDetail" :type="curQue.property.role_img_type" />
@@ -911,6 +936,9 @@ export default {
         let startLeg = dIndex === 0 ? 0 : curQue.detail[dIndex - 1].endLeg;
         let endLeg = startLeg + curSentencesLeg;
         dItem.endLeg = endLeg;
+        if (dItem.type === 'notice') {
+          dItem.endLeg = dIndex === 0 ? 0 : curQue.detail[dIndex - 1].endLeg;
+        }
         let timeList = [];
         if (curQue.wordTime && curQue.wordTime.length > 0 && dItem.type === 'text') {
           timeList = curQue.wordTime.slice(startLeg, endLeg);
@@ -926,6 +954,7 @@ export default {
           dhaspinyin,
           type: dItem.type,
           notice: dItem.notice,
+          noticeWordList: dItem.noticeWordList,
           notice_size: dItem.notice_size,
           notice_color: dItem.notice_color,
           file_url_open: dItem.file_url_open,

+ 1 - 0
src/views/book/courseware/preview/components/dialogue_article/Practicechs.vue

@@ -1106,6 +1106,7 @@ export default {
             dhaspinyin,
             type: dItem.type,
             notice: dItem.notice,
+            noticeWordList: dItem.noticeWordList,
             notice_size: dItem.notice_size,
             notice_color: dItem.notice_color,
             file_url_open: dItem.file_url_open,

+ 29 - 0
src/views/book/courseware/preview/components/dialogue_article/WordModelChs.vue

@@ -85,9 +85,34 @@
                   fontSize: curQue.property.notice_size ? curQue.property.notice_size + 'px' : '',
                   color: curQue.property.notice_color ? curQue.property.notice_color : '',
                 }"
+                v-if="item.noticeWordList.length === 0"
               >
                 {{ convertText(item.notice) }}
               </p>
+              <p
+                :class="['notice']"
+                :style="{
+                  fontSize: curQue.property.notice_size ? curQue.property.notice_size + 'px' : '',
+                  color: curQue.property.notice_color ? curQue.property.notice_color : '',
+                }"
+                v-else
+              >
+                <span v-for="(items, indexs) in item.noticeWordList" :key="indexs">
+                  <span
+                    v-for="(pItem, indexss) in items"
+                    :key="indexss"
+                    :style="{
+                      fontFamily: pItem.fontFamily,
+                      textDecoration: pItem.textDecoration,
+                      borderBottom: pItem.border === 'dotted' ? '1px dotted' : '',
+                      fontWeight: pItem.fontWeight,
+                      color: pItem.color,
+                    }"
+                  >
+                    {{ convertText(pItem.chs) }}
+                  </span>
+                </span>
+              </p>
             </template>
             <template v-else>
               <RoleChs :cur-role="item.roleDetail" :type="curQue.property.role_img_type" />
@@ -806,6 +831,9 @@ export default {
         let startLeg = dIndex === 0 ? 0 : curQue.detail[dIndex - 1].endLeg;
         let endLeg = startLeg + curSentencesLeg;
         dItem.endLeg = endLeg;
+        if (dItem.type === 'notice') {
+          dItem.endLeg = dIndex === 0 ? 0 : curQue.detail[dIndex - 1].endLeg;
+        }
         let timeList = curQue.wordTime.slice(startLeg, endLeg);
         let enwords =
           dItem.sentencesEn && dItem.sentencesEn.length > 0 ? dItem.sentencesEn.join(' ').replace(/'/g, '’') : '';
@@ -818,6 +846,7 @@ export default {
           dhaspinyin,
           type: dItem.type,
           notice: dItem.notice,
+          noticeWordList: dItem.noticeWordList,
           notice_size: dItem.notice_size,
           notice_color: dItem.notice_color,
           file_url_open: dItem.file_url_open,