Ver código fonte

拼音提示

natasha 1 ano atrás
pai
commit
bc6c2a5d1a

+ 1 - 1
src/components/corpus/Strockplay.vue

@@ -126,7 +126,7 @@ export default {
     position: absolute;
     top: 0;
     right: 0;
-    z-index: 9999;
+    z-index: 9;
   }
 }
 .character-target-div {

+ 2 - 2
src/views/Textanalysis/CheckPinyin.vue

@@ -73,8 +73,8 @@
         </div>
         <el-input v-model="checkPinyinInput" type="text" class="checkPinyinInput" />
         <p class="tips">
-          一到四声分别用数字1-4表示,轻声用0表示。拼音间用空格隔开,例如“北语社”,输入“bei3 yu3
-          she4”;若需要连在一起显示,用_隔开,例如“哪儿”,输入“na3_er”
+          一到四声分别用数字1-4表示。如需分词,拼音间用空格隔开,例如“kàn shū”,输入“kan4
+          shu1”;若不分词,拼音间用_隔开,例如“nǎr”,输入“na3_r”。
         </p>
         <div class="btn-box">
           <el-button type="info" size="small" @click="cancleDialog">取消</el-button>

+ 36 - 34
src/views/wordcard/writeTable.vue

@@ -1,5 +1,5 @@
 <template>
-  <div :class="['writeTable']" v-if="data">
+  <div :class="['writeTable']" v-if="data" v-loading="loading">
     <div class="writeTop" :class="[data.fileList ? 'writeTop-nopadding' : '']">
       <template v-if="data.fileList">
         <UploadDrag
@@ -276,6 +276,7 @@ export default {
       },
       writer: null,
       audio_file: '',
+      loading: false,
     };
   },
   //计算属性 类似于data概念
@@ -285,12 +286,7 @@ export default {
     pageNumber: {
       handler: function (val, oldVal) {
         if (val != oldVal) {
-          let _this = this;
-          _this.$nextTick(() => {
-            if (_this.data.hz_info && _this.data.hz_info.length === 1) {
-              _this.initHanziwrite();
-            }
-          });
+          this.initHanziwrite();
         }
       },
       deep: true,
@@ -337,23 +333,39 @@ export default {
       this.infoObj[this.data.con].fileList = [];
     },
     initHanziwrite() {
-      let _this = this;
-      let node = document.getElementById(`character-target-info-div` + _this.pageNumber);
-      if (node && node.children.length > 1) {
-        node.removeChild(node.children[1]);
+      // let _this = this;
+      // let node = document.getElementById(`character-target-info-div` + _this.pageNumber);
+      // if (node && node.children.length > 1) {
+      //   node.removeChild(node.children[1]);
+      // }
+      // _this.writer = HanziWriter.default.create(
+      //   `character-target-info-div` + _this.pageNumber,
+      //   _this.data.hz_info[0].con,
+      //   {
+      //     width: 22,
+      //     height: 22,
+      //     padding: 0,
+      //     radicalColor: '#000000',
+      //     strokeColor: '#fff',
+      //   },
+      // );
+      this.loading = true;
+      if (this.data.con) {
+        let MethodName = 'tool-TextToVoiceFile';
+        let datas = {
+          text: this.data.con,
+        };
+        getLogin(MethodName, datas)
+          .then((res) => {
+            this.loading = false;
+            if (res.status === 1) {
+              this.audio_file = res.file_id;
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
       }
-      //var ren = require("hanzi-writer-data/国");
-      _this.writer = HanziWriter.default.create(
-        `character-target-info-div` + _this.pageNumber,
-        _this.data.hz_info[0].con,
-        {
-          width: 22,
-          height: 22,
-          padding: 0,
-          radicalColor: '#000000',
-          strokeColor: '#fff',
-        },
-      );
     },
     changeInfoObj(param) {
       this.infoObj[this.data.con][param] = this.data.info[param] ? this.data.info[param].trim() : '';
@@ -361,17 +373,7 @@ export default {
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
-    if (this.data.con) {
-      let MethodName = 'tool-TextToVoiceFile';
-      let datas = {
-        text: this.data.con,
-      };
-      getLogin(MethodName, datas).then((res) => {
-        if (res.status === 1) {
-          this.audio_file = res.file_id;
-        }
-      });
-    }
+    this.initHanziwrite();
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {