Browse Source

修正拼音回填问题

zq 6 hours ago
parent
commit
af8099c3c1

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

@@ -9,7 +9,7 @@
     :append-to-body="true"
     :append-to-body="true"
     @close="dialogClose"
     @close="dialogClose"
   >
   >
-    <div ref="toolbarMenu" v-if="!newVersion" class="toolbar">
+    <div v-if="!newVersion" ref="toolbarMenu" class="toolbar">
       <el-select v-model="dataContent.activeTextStyle.fontFamily" placeholder="请选择">
       <el-select v-model="dataContent.activeTextStyle.fontFamily" placeholder="请选择">
         <el-option v-for="item in fontFamilyOptions" :key="item.value" :label="item.label" :value="item.value" />
         <el-option v-for="item in fontFamilyOptions" :key="item.value" :label="item.label" :value="item.value" />
       </el-select>
       </el-select>
@@ -34,7 +34,7 @@
         <SvgIcon icon-class="strikethrough" title="删除线" size="20" @click="setActiveTextStyle('line-through')" />
         <SvgIcon icon-class="strikethrough" title="删除线" size="20" @click="setActiveTextStyle('line-through')" />
       </span>
       </span>
     </div>
     </div>
-    <span class="tone-pinyin" v-show="isEnable(dataContent.showPinyin)">{{ dataContent.pinyin }}</span>
+    <span v-show="isEnable(dataContent.showPinyin)" class="tone-pinyin">{{ dataContent.pinyin }}</span>
     <span class="content-text" :style="dataContent.activeTextStyle">{{ dataContent.text }}</span>
     <span class="content-text" :style="dataContent.activeTextStyle">{{ dataContent.text }}</span>
 
 
     <div class="pinyin-row">
     <div class="pinyin-row">
@@ -60,8 +60,8 @@
         filterable
         filterable
         allow-create
         allow-create
         default-first-option
         default-first-option
-        @change="convertTonePinyin"
         class="pinyin-input"
         class="pinyin-input"
+        @change="convertTonePinyin"
       >
       >
         <el-option v-for="item in pinyinList" :key="item.pinyin" :value="item.pinyin.replace(/,/g, '')">
         <el-option v-for="item in pinyinList" :key="item.pinyin" :value="item.pinyin.replace(/,/g, '')">
           <span style="float: left">{{ item.pinyin ? item.pinyin.replace(/,/g, '') : '' }}</span>
           <span style="float: left">{{ item.pinyin ? item.pinyin.replace(/,/g, '') : '' }}</span>
@@ -71,8 +71,8 @@
         </el-option>
         </el-option>
       </el-select>
       </el-select>
     </div>
     </div>
-    <span v-show="isEnable(dataContent.showPinyin)" class="tips"
-      >一到四声分别用数字1-4表示,轻声用0表示,拼音间用空格隔开。</span
+    <span v-show="isEnable(dataContent.showPinyin)" class="tips">
+      一到四声分别用数字1-4表示,轻声用0表示,拼音间用空格隔开。</span
     >
     >
 
 
     <!-- <RichText
     <!-- <RichText

+ 32 - 3
src/views/book/courseware/create/components/base/rich_text/RichText.vue

@@ -390,9 +390,38 @@ export default {
     // 填充校对后的拼音
     // 填充校对后的拼音
     fillCorrectPinyin({ selectContent: { text, pinyin, activeTextStyle, note, showPinyin }, i, j, k, newVersion }) {
     fillCorrectPinyin({ selectContent: { text, pinyin, activeTextStyle, note, showPinyin }, i, j, k, newVersion }) {
       if (newVersion) {
       if (newVersion) {
-        if (pinyin) this.data.rich_text_list[j].word_list[k].pinyin = pinyin;
-        this.data.rich_text_list[j].word_list[k].showPinyin = showPinyin;
-        if (note !== null) this.data.rich_text_list[j].word_list[k].note = note;
+        // if (pinyin) this.data.rich_text_list[j].word_list[k].pinyin = pinyin;
+        // this.data.rich_text_list[j].word_list[k].showPinyin = showPinyin;
+        // if (note !== null) this.data.rich_text_list[j].word_list[k].note = note;
+
+        const targetBlock = this.data.rich_text_list[j];
+        if (!targetBlock || !targetBlock.word_list) {
+          console.error('找不到对应的文本块', { j, k });
+          return;
+        }
+
+        const targetWord = targetBlock.word_list[k];
+        if (!targetWord) {
+          console.error('找不到对应的词语', { j, k });
+          return;
+        }
+
+        if (pinyin) {
+          targetWord.pinyin = pinyin;
+          targetWord.pinyin_list = pinyin.split(/\s+/);
+        }
+
+        if (showPinyin !== undefined && showPinyin !== null) {
+          targetWord.showPinyin = showPinyin;
+        }
+
+        if (note !== null && note !== undefined) {
+          targetWord.note = note;
+        }
+
+        if (activeTextStyle && Object.keys(activeTextStyle).length > 0) {
+          targetWord.activeTextStyle = { ...targetWord.activeTextStyle, ...activeTextStyle };
+        }
       } else {
       } else {
         // 兼容历史数据
         // 兼容历史数据
         this.data.paragraph_list_parameter.pinyin_proofread_word_list.push({
         this.data.paragraph_list_parameter.pinyin_proofread_word_list.push({