Explorar o código

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

dsy hai 1 mes
pai
achega
ced98f30e2
Modificáronse 1 ficheiros con 26 adicións e 0 borrados
  1. 26 0
      src/components/PinyinText.vue

+ 26 - 0
src/components/PinyinText.vue

@@ -849,6 +849,32 @@ export default {
         this.isAllSetting = false;
       }
 
+      // 优先取文字单独的字号
+      let _fontSize = block.styleObj && block.styleObj.fontSize ? block.styleObj.fontSize : null;
+      // 如果没有,取继承的字号
+      if (!_fontSize && item.activeTextStyle && item.activeTextStyle.fontSize) {
+        _fontSize = item.activeTextStyle.fontSize;
+      }
+      // 如果没有,取组件的字号
+      if (!_fontSize && this.bodyStyles.fontSize) _fontSize = this.bodyStyles.fontSize;
+      // 如果没有,取全局字号
+      if (!_fontSize && this.fontSize) _fontSize = this.fontSize;
+
+      if (_fontSize) {
+        // 取出字号里面的数字,做计算处理之后,自动加上原来的单位
+        const fontSizeMatch = _fontSize.match(/^([\d.]+)(\D*)$/);
+        if (fontSizeMatch) {
+          const fontSizeValue = parseFloat(fontSizeMatch[1]);
+          const fontSizeUnit = fontSizeMatch[2] || 'px';
+
+          // 根据字号大小确定比例:16号及以下75%,16号以上60%
+          const ratio = fontSizeValue <= 16 ? 0.75 : 0.6;
+          const calculatedSize = Math.round(fontSizeValue * ratio);
+
+          // 保留原始单位
+          styles['font-size'] = `${calculatedSize}${fontSizeUnit}`;
+        }
+      }
       // 明确重置不应该继承的样式
       styles['text-decoration'] = 'none';
       styles['font-style'] = 'normal';