Browse Source

Merge branch 'master' of http://60.205.254.193:3000/GCLS/eep_page

dsy 4 days ago
parent
commit
79d6b62487
1 changed files with 25 additions and 11 deletions
  1. 25 11
      src/views/book/courseware/create/components/base/rich_text/RichText.vue

+ 25 - 11
src/views/book/courseware/create/components/base/rich_text/RichText.vue

@@ -71,17 +71,13 @@ export default {
   watch: {
     'data.property': {
       handler(val) {
-        let text = this.data.content.replace(/<[^>]+>/g, '');
-        if (!isEnable(val.view_pinyin)) {
-          this.data.paragraph_list = [];
-          return;
-        }
-        if (isEnable(val.view_pinyin) && text && this.data.paragraph_list.length <= 0) {
-          this.data.paragraph_list_parameter.text = text;
-          this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
-            val.is_first_sentence_first_hz_pinyin_first_char_upper_case;
-          this.createParsedTextInfoPinyin(text);
-        }
+        this.handlePinyinDisplay(val);
+      },
+      deep: true,
+    },
+    'data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case': {
+      handler() {
+        this.handlePinyinDisplay(this.data.property);
       },
       deep: true,
     },
@@ -94,6 +90,24 @@ export default {
     this.data = getRichTextData();
   },
   methods: {
+    handlePinyinDisplay(property) {
+      const text = this.data.content.replace(/<[^>]+>/g, '');
+      if (!isEnable(property.view_pinyin)) {
+        this.data.paragraph_list = [];
+        return;
+      }
+      // 当需要显示拼音时,检查是否需要重新生成
+      let isCreate =
+        this.data.paragraph_list.length <= 0 ||
+        this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case !==
+          property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
+      if (text && isCreate) {
+        this.data.paragraph_list_parameter.text = text;
+        this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
+          property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
+        this.createParsedTextInfoPinyin(text);
+      }
+    },
     showSetting() {
       this.richId = this.$refs.rich.id;
       this.$emit('showSetting', this.data.property, this.data.type, this.id, {