Bläddra i källkod

生词表多语言显示问题修改

natasha 1 vecka sedan
förälder
incheckning
2fd84dbe55

+ 7 - 9
src/views/book/courseware/create/components/question/new_word/NewWord.vue

@@ -878,17 +878,15 @@ export default {
       this.$set(this.data, 'lrc_arr', []);
     },
     handleMultilingual() {
-      this.multilingualText = this.data.title_con ? this.data.title_con : '<p>&nbsp;</p>';
+      this.multilingualText = this.data.title_con ? this.data.title_con + '\n' : '<p>&nbsp;</p>\n';
       this.data.new_word_list.forEach((item) => {
-        this.multilingualText += `<p>${item.new_word}</p>`;
-        this.multilingualText += item.cixing ? item.cixing : '<p>&nbsp;</p>';
-        this.multilingualText += item.definition_list ? item.definition_list : '<p>&nbsp;</p>';
-        this.multilingualText += item.collocation ? item.collocation : '<p>&nbsp;</p>';
-        this.multilingualText += item.liju_list ? item.liju_list : '<p>&nbsp;</p>';
-        this.multilingualText += `<p>${item.header_con}</p>`;
-        this.multilingualText += `<p>${item.label}</p>`;
+        this.multilingualText += `<p>${item.new_word}</p>\n`;
+        this.multilingualText += item.cixing ? item.cixing + '\n' : '<p>&nbsp;</p>\n';
+        this.multilingualText += item.definition_list ? item.definition_list + '\n' : '<p>&nbsp;</p>\n';
+        this.multilingualText += item.collocation ? item.collocation + '\n' : '<p>&nbsp;</p>\n';
+        this.multilingualText += item.liju_list ? item.liju_list + '\n' : '<p>&nbsp;</p>\n';
         this.data.addCol.forEach((items) => {
-          this.multilingualText += `<p>${item[items.key]}</p>`;
+          this.multilingualText += `<p>${item[items.key]}</p>\n`;
         });
       });
       this.multilingualVisible = true;

+ 64 - 37
src/views/book/courseware/preview/components/new_word/NewWordPreview.vue

@@ -522,8 +522,8 @@
                                   showObj.newWord
                                 "
                                 class="NPC-word-tab-common"
+                                v-html="multilingualTextList[getLang()][index][0]"
                               >
-                                {{ multilingualTextList[getLang()][index][0] }}
                               </span>
                             </div>
                             <span>
@@ -550,8 +550,8 @@
                                   showObj.cixing
                                 "
                                 class="NPC-word-tab-common"
+                                v-html="multilingualTextList[getLang()][index][1]"
                               >
-                                {{ multilingualTextList[getLang()][index][1] }}
                               </span>
                             </span>
                           </template>
@@ -595,8 +595,8 @@
                                   multilingualTextList[getLang()][index][0]
                                 "
                                 class="NPC-word-tab-common"
+                                v-html="multilingualTextList[getLang()][index][0]"
                               >
-                                {{ multilingualTextList[getLang()][index][0] }}
                               </span>
                             </span>
                             <span
@@ -638,8 +638,8 @@
                                   multilingualTextList[getLang()][index][1]
                                 "
                                 class="NPC-word-tab-common"
+                                v-html="multilingualTextList[getLang()][index][1]"
                               >
-                                {{ multilingualTextList[getLang()][index][1] }}
                               </span>
                             </span>
                           </template>
@@ -666,8 +666,8 @@
                               multilingualTextList[getLang()][index][2]
                             "
                             class="NPC-word-tab-common"
+                            v-html="multilingualTextList[getLang()][index][2]"
                           >
-                            {{ multilingualTextList[getLang()][index][2] }}
                           </span>
                         </span>
                         <div v-if="sItem.collocation && showObj.collocation">
@@ -682,14 +682,18 @@
                               v-html="convertText(sanitizeHTML(sItem.collocation))"
                             ></b
                           ></span>
-                          <span v-if="showLang" class="">
-                            {{
+                          <span
+                            v-if="showLang"
+                            class="1"
+                            v-html="
                               multilingualTextList[getLang()] &&
                               multilingualTextList[getLang()][index] &&
-                              multilingualTextList[getLang()][index][3]
+                              multilingualTextList[getLang()][index][3] &&
+                              multilingualTextList[getLang()][index][3].trim() !== '&nbsp;'
                                 ? multilingualTextList[getLang()][index][3]
                                 : ''
-                            }}
+                            "
+                          >
                           </span>
                         </div>
                         <div v-if="sItem.liju_list && showObj.liju">
@@ -706,14 +710,18 @@
                               ></b>
                             </div>
                           </span>
-                          <span v-if="showLang" class="">
-                            {{
+                          <span
+                            v-if="showLang"
+                            class="2"
+                            v-html="
                               multilingualTextList[getLang()] &&
                               multilingualTextList[getLang()][index] &&
-                              multilingualTextList[getLang()][index][4]
+                              multilingualTextList[getLang()][index][4] &&
+                              multilingualTextList[getLang()][index][4].trim() !== '&nbsp;'
                                 ? multilingualTextList[getLang()][index][4]
                                 : ''
-                            }}
+                            "
+                          >
                           </span>
                         </div>
                         <template v-for="(itemC, indexC) in data.addCol">
@@ -731,14 +739,18 @@
                                 ></b>
                               </div>
                             </span>
-                            <span v-if="showLang" class="">
-                              {{
+                            <span
+                              v-if="showLang"
+                              class="3"
+                              v-html="
                                 multilingualTextList[getLang()] &&
                                 multilingualTextList[getLang()][index] &&
-                                multilingualTextList[getLang()][index][5 + indexC]
+                                multilingualTextList[getLang()][index][5 + indexC] &&
+                                multilingualTextList[getLang()][index][5 + indexC].trim() !== '&nbsp;'
                                   ? multilingualTextList[getLang()][index][5 + indexC]
                                   : ''
-                              }}
+                              "
+                            >
                             </span>
                           </div>
                         </template>
@@ -1007,8 +1019,8 @@
                               width: data.col_width[0].value + 'px',
                               flex: !data.col_width[0].value || data.col_width[0].value === '0' ? '1' : '',
                             }"
+                            v-html="multilingualTextList[getLang()][index][0]"
                           >
-                            {{ multilingualTextList[getLang()][index][0] }}
                           </span>
                         </div>
                         <span
@@ -1039,8 +1051,8 @@
                               multilingualTextList[getLang()][index][1]
                             "
                             class="NPC-word-tab-common"
+                            v-html="multilingualTextList[getLang()][index][1]"
                           >
-                            {{ multilingualTextList[getLang()][index][1] }}
                           </span>
                         </span>
                         <span
@@ -1070,8 +1082,8 @@
                               multilingualTextList[getLang()][index][2]
                             "
                             class="NPC-word-tab-common"
+                            v-html="multilingualTextList[getLang()][index][2]"
                           >
-                            {{ multilingualTextList[getLang()][index][2] }}
                           </span>
                         </span>
                       </template>
@@ -1128,8 +1140,8 @@
                               width: data.col_width[0].value + 'px',
                               flex: !data.col_width[0].value || data.col_width[0].value === '0' ? '1' : '',
                             }"
+                            v-html="multilingualTextList[getLang()][index][0]"
                           >
-                            {{ multilingualTextList[getLang()][index][0] }}
                           </span>
                         </span>
                         <span
@@ -1179,8 +1191,8 @@
                               multilingualTextList[getLang()][index][1]
                             "
                             class="NPC-word-tab-common"
+                            v-html="multilingualTextList[getLang()][index][1]"
                           >
-                            {{ multilingualTextList[getLang()][index][1] }}
                           </span>
                         </span>
                         <span
@@ -1210,8 +1222,8 @@
                               multilingualTextList[getLang()][index][2]
                             "
                             class="NPC-word-tab-common"
+                            v-html="multilingualTextList[getLang()][index][2]"
                           >
-                            {{ multilingualTextList[getLang()][index][2] }}
                           </span>
                         </span>
                       </template>
@@ -1340,14 +1352,18 @@
                             v-html="convertText(sanitizeHTML(sItem.collocation))"
                           ></b
                         ></span>
-                        <span v-if="showLang" class="">
-                          {{
+                        <span
+                          v-if="showLang"
+                          class="4"
+                          v-html="
                             multilingualTextList[getLang()] &&
                             multilingualTextList[getLang()][index] &&
-                            multilingualTextList[getLang()][index][3]
+                            multilingualTextList[getLang()][index][3] &&
+                            multilingualTextList[getLang()][index][3].trim() !== '&nbsp;'
                               ? multilingualTextList[getLang()][index][3]
                               : ''
-                          }}
+                          "
+                        >
                         </span>
                       </div>
                       <div
@@ -1370,14 +1386,18 @@
                             ></b>
                           </div>
                         </span>
-                        <span v-if="showLang" class="">
-                          {{
+                        <span
+                          v-if="showLang"
+                          class="5"
+                          v-html="
                             multilingualTextList[getLang()] &&
                             multilingualTextList[getLang()][index] &&
-                            multilingualTextList[getLang()][index][4]
+                            multilingualTextList[getLang()][index][4] &&
+                            multilingualTextList[getLang()][index][4].trim() !== '&nbsp;'
                               ? multilingualTextList[getLang()][index][4]
                               : ''
-                          }}
+                          "
+                        >
                         </span>
                       </div>
                       <template v-for="(itemC, indexC) in data.addCol">
@@ -1403,14 +1423,18 @@
                               ></b>
                             </div>
                           </span>
-                          <span v-if="showLang" class="">
-                            {{
+                          <span
+                            v-if="showLang"
+                            class="6"
+                            v-html="
                               multilingualTextList[getLang()] &&
                               multilingualTextList[getLang()][index] &&
-                              multilingualTextList[getLang()][index][5 + indexC]
+                              multilingualTextList[getLang()][index][5 + indexC] &&
+                              multilingualTextList[getLang()][index][5 + indexC].trim() !== '&nbsp;'
                                 ? multilingualTextList[getLang()][index][5 + indexC]
                                 : ''
-                            }}
+                            "
+                          >
                           </span>
                         </div>
                       </template>
@@ -2373,11 +2397,13 @@ export default {
       if (!this.isJudgingRightWrong) {
         this.answer.answer_list = Bookanswer;
       }
-      if (this.showLang && this.data.multilingual) {
+      if (this.data.multilingual) {
         this.data.multilingual.forEach((item) => {
           let trans_arr = item.translation.split('\n');
+
           this.$set(this.titleTrans, item.type, trans_arr[0] ? trans_arr[0] : '');
-          let chunkSize = 7;
+          let chunkSize = 5 + this.data.addCol.length;
+
           let chunkedArr = trans_arr.splice(1).reduce((acc, curr, index) => {
             // 当索引是chunkSize的倍数时,开始一个新的子数组
             if (index % chunkSize === 0) {
@@ -2390,6 +2416,7 @@ export default {
           this.$set(this.multilingualTextList, item.type, chunkedArr);
         });
       }
+      // console.log(this.data);
     },
     handleChangeTab() {
       this.wordShow = !this.wordShow;