浏览代码

应用单个属性到所有组件

Co-authored-by: Copilot <copilot@github.com>
dsy 1 周之前
父节点
当前提交
a12572758f

+ 1 - 1
.env

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

+ 34 - 0
src/views/book/courseware/create/components/CreateCanvas.vue

@@ -481,6 +481,40 @@ export default {
         }
       });
     },
+    /**
+     * 应用单个属性到所有组件
+     * @param {String} attr - 属性名
+     * @param {any} val - 属性值
+     */
+    applySingleAttrToAllComponents(attr, val) {
+      this.$refs.component.forEach((item) => {
+        switch (attr) {
+          case 'view_pinyin':
+          case 'pinyin_position':
+            item.updateProperty(attr, val);
+            break;
+          case 'font':
+            item.updateRichTextProperty('fontFamily', val);
+            break;
+          case 'font_size':
+            item.updateRichTextProperty('fontSize', val);
+            break;
+          case 'line_height':
+            item.updateRichTextProperty('lineHeight', val);
+            break;
+          case 'text_color':
+            item.updateRichTextProperty('color', val);
+            break;
+          case 'align':
+            item.updateRichTextProperty('align', val);
+            break;
+          default:
+            break;
+        }
+
+        item.setSingleUnifiedAttr(attr, val);
+      });
+    },
     getBookUnifiedAttr() {
       GetBookUnifiedAttrib({ book_id: this.project_id }).then(({ content }) => {
         if (content) {

+ 39 - 2
src/views/book/courseware/create/components/FullTextSettings.vue

@@ -1,7 +1,7 @@
 <template>
   <el-dialog
     custom-class="full-text-settings"
-    width="470px"
+    width="570px"
     :close-on-click-modal="false"
     :visible="visible"
     :before-close="handleClose"
@@ -23,6 +23,9 @@
         <el-button type="primary" class="row-button" @click="applySingleAttrToSelectedComponents('font')">
           应用选中组件
         </el-button>
+        <el-button type="primary" class="row-button" @click="applySingleAttrToAllComponents('font')">
+          应用整页
+        </el-button>
       </el-form-item>
       <el-form-item label="字号">
         <el-select v-model="unified_attrib.font_size" placeholder="请选择字号">
@@ -31,6 +34,9 @@
         <el-button type="primary" class="row-button" @click="applySingleAttrToSelectedComponents('font_size')">
           应用选中组件
         </el-button>
+        <el-button type="primary" class="row-button" @click="applySingleAttrToAllComponents('font_size')">
+          应用整页
+        </el-button>
       </el-form-item>
       <el-form-item label="拼音字号">
         <el-select v-model="unified_attrib.pinyin_size" placeholder="请选择拼音字号">
@@ -39,18 +45,27 @@
         <el-button type="primary" class="row-button" @click="applySingleAttrToSelectedComponents('pinyin_size')">
           应用选中组件
         </el-button>
+        <el-button type="primary" class="row-button" @click="applySingleAttrToAllComponents('pinyin_size')">
+          应用整页
+        </el-button>
       </el-form-item>
       <el-form-item label="行距">
         <el-input-number v-model="unified_attrib.line_height" :min="0" :max="20" :step="0.1" />
         <el-button type="primary" class="row-button" @click="applySingleAttrToSelectedComponents('line_height')">
           应用选中组件
         </el-button>
+        <el-button type="primary" class="row-button" @click="applySingleAttrToAllComponents('line_height')">
+          应用整页
+        </el-button>
       </el-form-item>
       <el-form-item label="文字颜色">
         <el-color-picker v-model="unified_attrib.text_color" />
         <el-button type="primary" class="row-button" @click="applySingleAttrToSelectedComponents('text_color')">
           应用选中组件
         </el-button>
+        <el-button type="primary" class="row-button" @click="applySingleAttrToAllComponents('text_color')">
+          应用整页
+        </el-button>
       </el-form-item>
       <el-form-item label="对齐方式">
         <el-select v-model="unified_attrib.align" placeholder="请选择对齐方式">
@@ -61,12 +76,18 @@
         <el-button type="primary" class="row-button" @click="applySingleAttrToSelectedComponents('align')">
           应用选中组件
         </el-button>
+        <el-button type="primary" class="row-button" @click="applySingleAttrToAllComponents('align')">
+          应用整页
+        </el-button>
       </el-form-item>
       <el-form-item label="拼音">
         <el-switch v-model="unified_attrib.view_pinyin" active-value="true" inactive-value="false" />
         <el-button type="primary" class="row-button" @click="applySingleAttrToSelectedComponents('view_pinyin')">
           应用选中组件
         </el-button>
+        <el-button type="primary" class="row-button" @click="applySingleAttrToAllComponents('view_pinyin')">
+          应用整页
+        </el-button>
       </el-form-item>
       <el-form-item label="拼音位置">
         <el-radio-group v-model="unified_attrib.pinyin_position" :disabled="!isEnable(unified_attrib.view_pinyin)">
@@ -82,6 +103,14 @@
         >
           应用选中组件
         </el-button>
+        <el-button
+          type="primary"
+          :disabled="!isEnable(unified_attrib.view_pinyin)"
+          class="row-button"
+          @click="applySingleAttrToAllComponents('pinyin_position')"
+        >
+          应用整页
+        </el-button>
       </el-form-item>
     </el-form>
 
@@ -167,13 +196,21 @@ export default {
       this.$emit('applyToSelectedComponents', this.unified_attrib);
     },
     /**
-     * 应用单个属性到选中组件
+     * 应用单个属性到选中组件
      * @param {String} attr - 属性名
      */
     applySingleAttrToSelectedComponents(attr) {
       this.$emit('update:visible', false);
       this.$emit('applySingleAttrToSelectedComponents', { attr, value: this.unified_attrib[attr] });
     },
+    /**
+     * 应用单个属性到所有组件
+     * @param {String} attr - 属性名
+     */
+    applySingleAttrToAllComponents(attr) {
+      this.$emit('update:visible', false);
+      this.$emit('applySingleAttrToAllComponents', { attr, value: this.unified_attrib[attr] });
+    },
   },
 };
 </script>

+ 11 - 1
src/views/personal_workbench/edit_task/edit/index.vue

@@ -72,6 +72,7 @@
       @fullTextSettings="fullTextSettings"
       @applyToSelectedComponents="applyToSelectedComponents"
       @applySingleAttrToSelectedComponents="applySingleAttrToSelectedComponents"
+      @applySingleAttrToAllComponents="applySingleAttrToAllComponents"
     />
   </div>
 </template>
@@ -250,7 +251,7 @@ export default {
       this.$refs.create.$refs.createCanvas.applyToSelectedComponents(data);
     },
     /**
-     * 应用单个属性到选中组件
+     * 应用单个属性到选中组件
      * @param {object} param
      * @param {string} param.attr - 属性名
      * @param {any} param.value - 属性值
@@ -258,6 +259,15 @@ export default {
     applySingleAttrToSelectedComponents({ attr, value }) {
       this.$refs.create.$refs.createCanvas.applySingleAttrToSelectedComponents(attr, value);
     },
+    /**
+     * 应用单个属性到所有组件
+     * @param {object} param
+     * @param {string} param.attr - 属性名
+     * @param {any} param.value - 属性值
+     */
+    applySingleAttrToAllComponents({ attr, value }) {
+      this.$refs.create.$refs.createCanvas.applySingleAttrToAllComponents(attr, value);
+    },
     goBackPreview() {
       if (this.$route.query.template_type) {
         this.$router.push({