Quellcode durchsuchen

生词详情去掉标点

natasha vor 2 Jahren
Ursprung
Commit
79dd5aafbd

+ 41 - 39
src/components/Adult/preview/components/Intp.vue

@@ -190,47 +190,49 @@ export default {
       _this.antonymList = [];
       _this.termsList = [];
       _this.isHasValue2 = "";
-      _this.dataDetail.forEach((item) => {
-        if (item.request.queryType == "entity") {
-          // 读音
-          item.response.entity.forEach((items) => {
-            items.attrs.forEach((itemss) => {
-              if (itemss.key == "pronunciation") {
-                // 音频
-                let Mname = "tool-TextToVoiceFile";
-                getContentFile(Mname, { text: this.word.detail.new_word }).then(
-                  (res) => {
-                    _this.mp3Url = res.file_url;
-                  }
-                );
-                // _this.word.mp3Url = itemss.objects[0]["@value"]
-                //   ? itemss.objects[0]["@value"]
-                //   : "";
-              } else if (itemss.key == "definition") {
-                // 释义
-                _this.paraphrase = itemss.objects;
-                for (let i = 0; i < _this.paraphrase.length; i++) {
-                  if (_this.paraphrase[i]["@definitionWithSpell"]) {
-                    _this.isHasValue2 = "definitionWithSpell";
-                    return false;
-                  } else if (_this.paraphrase[i]["@definitions"]) {
-                    _this.isHasValue2 = "definitions";
-                  }
+      if(_this.dataDetail){
+        _this.dataDetail.forEach((item) => {
+            if (item.request.queryType == "entity") {
+            // 读音
+            item.response.entity.forEach((items) => {
+                items.attrs.forEach((itemss) => {
+                if (itemss.key == "pronunciation") {
+                    // 音频
+                    let Mname = "tool-TextToVoiceFile";
+                    getContentFile(Mname, { text: this.word.detail.new_word }).then(
+                    (res) => {
+                        _this.mp3Url = res.file_url;
+                    }
+                    );
+                    // _this.word.mp3Url = itemss.objects[0]["@value"]
+                    //   ? itemss.objects[0]["@value"]
+                    //   : "";
+                } else if (itemss.key == "definition") {
+                    // 释义
+                    _this.paraphrase = itemss.objects;
+                    for (let i = 0; i < _this.paraphrase.length; i++) {
+                    if (_this.paraphrase[i]["@definitionWithSpell"]) {
+                        _this.isHasValue2 = "definitionWithSpell";
+                        return false;
+                    } else if (_this.paraphrase[i]["@definitions"]) {
+                        _this.isHasValue2 = "definitions";
+                    }
+                    }
+                } else if (itemss.key == "synonym") {
+                    // 近义词
+                    _this.synonymList = itemss.objects;
+                } else if (itemss.key == "antonym") {
+                    // 反义词
+                    _this.antonymList = itemss.objects;
+                } else if (itemss.key == "terms") {
+                    // 组词
+                    _this.termsList = itemss.objects;
                 }
-              } else if (itemss.key == "synonym") {
-                // 近义词
-                _this.synonymList = itemss.objects;
-              } else if (itemss.key == "antonym") {
-                // 反义词
-                _this.antonymList = itemss.objects;
-              } else if (itemss.key == "terms") {
-                // 组词
-                _this.termsList = itemss.objects;
-              }
+                });
             });
-          });
-        }
-      });
+            }
+        });
+      }
     },
   },
   //生命周期 - 创建完成(可以访问当前this实例)

+ 61 - 24
src/components/Adult/preview/components/WordPhraseDetail.vue

@@ -42,10 +42,11 @@
                 ? 'red-border'
                 : 'brown-border',
             ]"
+            v-if="data.new_word_str.length<=4"
           >
             <div
               class="strockplay"
-              v-for="(conItem, conindex) in data.new_word"
+              v-for="(conItem, conindex) in data.new_word_str"
               :key="'new_word_' + conindex"
             >
               <Strockplayredline
@@ -53,7 +54,7 @@
                 :Book_text="conItem"
                 :playStorkes="true"
                 :targetDiv="'bwcHanziIntp' + conItem + detailIndex + conindex"
-                :wordNum="data.new_word.length"
+                :wordNum="data.new_word_str.length"
                 :themeColor="themeColor"
               />
               <div
@@ -65,10 +66,22 @@
                     ? 'red-bg'
                     : 'brown-bg',
                 ]"
-                v-if="conindex < data.new_word.length - 1"
+                v-if="conindex < data.new_word_str.length - 1"
               ></div>
             </div>
           </div>
+          <p v-else :class="[
+              'bwc-tolength',
+              themeColor == 'green'
+                ? 'green-border'
+                : themeColor == 'red'
+                ? 'red-border'
+                : 'brown-border',
+            ]">
+            <span v-for="(item, index) in data.new_word_str" :key="index">{{
+                item
+            }}</span>
+          </p>
           <div class="wordInfor">
             <div class="yinpin">
               <span class="pinyintext"> {{ data.pinyin.toLowerCase() }}</span>
@@ -403,6 +416,7 @@ export default {
       CurrentList: [],
       sortIndex: 0,
       chsFhList: [",", "。", "”", ":", "》", "?", "!", ";"],
+      punctuationList: ['(',')','……','(',')','…'], // 标点数组
     };
   },
   //计算属性 类似于data概念
@@ -940,31 +954,43 @@ export default {
     // 处理数据
     handleChineseDetail() {
       let _this = this;
-      _this.dataDetail.forEach((item) => {
-        if (item.request.queryType == "entity") {
-          // 读音
-          item.response.entity.forEach((items) => {
-            items.attrs.forEach((itemss) => {
-              if (itemss.key == "pronunciation") {
-                // 音频
-                let Mname = "tool-TextToVoiceFile";
-                getContentFile(Mname, { text: this.word.detail.new_word }).then(
-                  (res) => {
-                    _this.mp3Url = res.file_url;
-                  }
-                );
-                // _this.data.mp3Url = itemss.objects[0]["@value"]
-                //   ? itemss.objects[0]["@value"]
-                //   : "";
-              }
+      if(_this.dataDetail){
+        _this.dataDetail.forEach((item) => {
+            if (item.request.queryType == "entity") {
+            // 读音
+            item.response.entity.forEach((items) => {
+                items.attrs.forEach((itemss) => {
+                if (itemss.key == "pronunciation") {
+                    // 音频
+                    let Mname = "tool-TextToVoiceFile";
+                    getContentFile(Mname, { text: this.word.detail.new_word }).then(
+                    (res) => {
+                        _this.mp3Url = res.file_url;
+                    }
+                    );
+                    // _this.data.mp3Url = itemss.objects[0]["@value"]
+                    //   ? itemss.objects[0]["@value"]
+                    //   : "";
+                }
+                });
             });
-          });
-        }
-      });
+            }
+        });
+      }
+      
     },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
-  created() {},
+  created() {
+    // 去掉生词里的标点
+    let new_word_str = ""
+    for(let i = 0;i<this.data.new_word.length;i++){
+        if(this.punctuationList.indexOf(this.data.new_word[i])==-1){
+            new_word_str+=this.data.new_word[i]
+        }
+    }
+    this.data.new_word_str = new_word_str
+  },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {
     let _this = this;
@@ -1080,6 +1106,17 @@ export default {
           background: #bd8865;
         }
       }
+      .bwc-tolength {
+        color: #404040;
+        font-size: 30px;
+        line-height: 1.5;
+        font-family: FZJCGFKTK;
+        text-align: center;
+        border: 2px solid #d47064;
+        border-radius: 8px;
+        padding: 40px 0;
+        margin: 0 37px 16px 0;
+      }
       .red-border {
         border: 2px solid #ff5757;
       }