Quellcode durchsuchen

点击校对拼音样式调整

zq vor 1 Monat
Ursprung
Commit
c041ec07cd

+ 7 - 2
src/views/book/courseware/create/components/base/common/CorrectPinyin.vue

@@ -34,7 +34,9 @@
         <SvgIcon icon-class="strikethrough" title="删除线" size="20" @click="setActiveTextStyle('line-through')" />
       </span>
     </div>
-    <span v-show="isEnable(dataContent.showPinyin)" class="tone-pinyin">{{ dataContent.pinyin }}</span>
+    <span v-show="isEnable(dataContent.showPinyin)" class="tone-pinyin">{{
+      dataContent.pinyin.replace(/ /g, '')
+    }}</span>
     <span class="content-text" :style="dataContent.activeTextStyle">{{ dataContent.text }}</span>
 
     <div class="pinyin-row">
@@ -187,7 +189,7 @@ export default {
     // 将数字拼音转换为声调拼音
     convertTonePinyin() {
       if (!this.numberPinyin) return;
-      this.dataContent.pinyin = this.numberPinyin
+      let newPinyin = this.numberPinyin
         .trim()
         .split(/\s+/)
         .map((item) => {
@@ -198,6 +200,9 @@ export default {
         )
         .filter((item) => item.length > 0)
         .join(' ');
+      const leading = (this.dataContent.pinyin.match(/^[ ]+/) || [''])[0];
+      const trailing = (this.dataContent.pinyin.match(/[ ]+$/) || [''])[0];
+      this.dataContent.pinyin = leading + newPinyin + trailing;
     },
     dialogClose() {
       this.$emit('update:visible', false);