Browse Source

批量设置整体富文本格式

dsy 1 month ago
parent
commit
03171c58ce

+ 1 - 1
.env

@@ -11,4 +11,4 @@ VUE_APP_BookWebSI = '/GCLSBookWebSI/ServiceInterface'
 VUE_APP_EepServer = '/EEPServer/SI'
 
 #version
-VUE_APP_VERSION = '2026.07.03'
+VUE_APP_VERSION = '2026.07.05'

+ 2 - 2
src/components/PinyinText.vue

@@ -768,7 +768,7 @@ export default {
 
       const blockColor = this.getBlockColor(block);
       if (blockColor) {
-        baseStyle.color = blockColor;
+        baseStyle.color = `${blockColor} !important`;
       }
 
       if (this.isAllSetting) {
@@ -840,7 +840,7 @@ export default {
 
       const blockColor = this.getBlockColor(block);
       if (blockColor) {
-        styles['color'] = blockColor;
+        styles['color'] = `${blockColor} !important`;
       }
 
       // 如果设置了全局字号,优先使用全局字号

+ 37 - 9
src/components/RichText.vue

@@ -820,6 +820,27 @@ export default {
       });
     },
     /**
+     * 批量设置整体富文本格式
+     * @param {Array<{type: string, val: string}>} formats 格式数组,每个元素是一个对象,包含 type 和 val
+     */
+    patchSetRichFormat(formats) {
+      let editor = tinymce.get(this.id);
+      if (!editor) return;
+      editor.execCommand('SelectAll');
+      formats.forEach(({ type, val }) => {
+        this.handleEditorFormatter(editor, type, val);
+      });
+      editor.selection.collapse(false);
+      editor.fire('change');
+
+      if (this.isViewPinyin) {
+        this.$nextTick(() => {
+          let styles = this.getFirstCharStyles();
+          this.$emit('createParsedTextInfoPinyin', null, styles);
+        });
+      }
+    },
+    /**
      * 设置整体富文本格式
      * @param {string} type 格式名称
      * @param {string} val 格式值
@@ -828,7 +849,23 @@ export default {
       let editor = tinymce.get(this.id);
       if (!editor) return;
       editor.execCommand('SelectAll');
+      this.handleEditorFormatter(editor, type, val);
+      editor.selection.collapse(false);
+      editor.fire('change'); // 触发内容变化事件,确保内容更新
 
+      if (this.isViewPinyin) {
+        this.$nextTick(() => {
+          let styles = this.getFirstCharStyles();
+          this.$emit('createParsedTextInfoPinyin', null, styles);
+        });
+      }
+    },
+    /**
+     * 设置整体富文本格式
+     * @param {string} type 格式名称
+     * @param {string} val 格式值
+     */
+    handleEditorFormatter(editor, type, val) {
       switch (type) {
         case 'bold': {
           if (this.isAllBold()) {
@@ -867,15 +904,6 @@ export default {
           editor.formatter.toggle(type);
         }
       }
-      editor.selection.collapse(false);
-      editor.fire('change'); // 触发内容变化事件,确保内容更新
-
-      if (this.isViewPinyin) {
-        this.$nextTick(() => {
-          let styles = this.getFirstCharStyles();
-          this.$emit('createParsedTextInfoPinyin', null, styles);
-        });
-      }
     },
     setRichTitleFormat(config) {
       if (!this.editorIsInited) {

+ 16 - 10
src/views/book/courseware/create/components/CreateCanvas.vue

@@ -461,11 +461,14 @@ export default {
       this.$refs.component.forEach((item) => {
         item.updateProperty('view_pinyin', data.view_pinyin);
         item.updateProperty('pinyin_position', data.pinyin_position);
-        item.updateRichTextProperty('fontFamily', data.font);
-        item.updateRichTextProperty('fontSize', data.font_size);
-        item.updateRichTextProperty('lineHeight', data.line_height);
-        item.updateRichTextProperty('color', data.text_color);
-        item.updateRichTextProperty('align', data.align);
+        const formats = [
+          { type: 'fontFamily', val: data.font },
+          { type: 'fontSize', val: data.font_size },
+          { type: 'lineHeight', val: data.line_height },
+          { type: 'color', val: data.text_color },
+          { type: 'align', val: data.align },
+        ];
+        item.patchSetRichFormat(formats);
 
         item.setUnifiedAttr(data);
       });
@@ -480,11 +483,14 @@ export default {
         if (item.$refs.base.checked) {
           item.updateProperty('view_pinyin', data.view_pinyin);
           item.updateProperty('pinyin_position', data.pinyin_position);
-          item.updateRichTextProperty('fontFamily', data.font);
-          item.updateRichTextProperty('fontSize', data.font_size);
-          item.updateRichTextProperty('lineHeight', data.line_height);
-          item.updateRichTextProperty('color', data.text_color);
-          item.updateRichTextProperty('align', data.align);
+          const formats = [
+            { type: 'fontFamily', val: data.font },
+            { type: 'fontSize', val: data.font_size },
+            { type: 'lineHeight', val: data.line_height },
+            { type: 'color', val: data.text_color },
+            { type: 'align', val: data.align },
+          ];
+          item.patchSetRichFormat(formats);
 
           item.setUnifiedAttr(data);
         }

+ 15 - 1
src/views/book/courseware/create/components/common/ModuleMixin.js

@@ -203,7 +203,7 @@ const mixin = {
     },
     /**
      * 批量设置富文本样式
-     * @param {Object} type 类型
+     * @param {string} type 类型
      * @param {Object} attr 属性
      */
     updateRichTextProperty(type, attr) {
@@ -217,6 +217,20 @@ const mixin = {
       });
     },
     /**
+     * 批量设置整体富文本格式
+     * @param {Array<{type: string, val: string}>} formats 格式数组,每个元素是一个对象,包含 type 和 val
+     */
+    patchSetRichFormat(formats) {
+      let richTextRefs = this.$refs.richText;
+      if (!richTextRefs) return;
+      if (!Array.isArray(richTextRefs)) {
+        richTextRefs = [richTextRefs];
+      }
+      richTextRefs?.forEach((richText) => {
+        richText.patchSetRichFormat(formats);
+      });
+    },
+    /**
      * @description 设置 unified_attrib 属性
      * @param {object} data unified_attrib数据
      */

+ 4 - 2
src/views/book/courseware/create/components/question/fill/Fill.vue

@@ -158,8 +158,10 @@ export default {
     'data.property.arrange_type': 'handleMindMap',
     'data.property.fill_font': 'handleMindMap',
     'data.property': {
-      handler() {
-        this.parsedContentPinyin();
+      handler(val) {
+        if (val.view_pinyin === 'true') {
+          this.parsedContentPinyin();
+        }
       },
       deep: true,
     },

+ 1 - 1
src/views/login/index.vue

@@ -338,7 +338,7 @@ export default {
       this.showUseragreement = false;
     },
     updateServerAddress() {
-      if (process.env.NODE_ENV === 'development') {
+      if (process.env.NODE_ENV === 'development' && this.form.server_address !== '/production') {
         return updateBaseURL('/eep');
       }
       updateBaseURL(this.form.server_address);