Просмотр исходного кода

完善tab图元按钮宽度及方向调整逻辑

Wind-Breaker1 1 год назад
Родитель
Сommit
4b5ff26b04
1 измененных файлов с 14 добавлено и 11 удалено
  1. 14 11
      src/views/components/pen.ts

+ 14 - 11
src/views/components/pen.ts

@@ -39,19 +39,22 @@ export const updatePen = (pen: any, prop: string, render = true) => {
       v.whiteSpace = 'nowrap';
       pen.whiteSpace = 'nowrap';
     }
-  } else if(prop === 'btnWidth'){
-    if (pen.direction == 'vertical') {
-      v.width = ((pen.btnWidth || 100) + (pen.gap || 8) * 2);
-    } else {
-      v.width = (pen.btnWidth || 100)  * pen.data.length + (pen.gap || 8) * (pen.data.length + 1);
+  } else if(pen.name === 'tab' && (prop === 'direction'|| prop === 'btnWidth'|| prop === 'btnHeight')){
+    if(pen.btnHeight) {
+      if (pen.direction == 'vertical') {
+        v.height = pen.btnHeight * pen.data.length + (pen.gap || 8) * (pen.data.length + 1);
+      } else {
+        v.height = pen.btnHeight + (pen.gap || 8) * 2; 
+      }
     }
-  } else if(prop === 'btnHeight'){
-    if (pen.direction == 'vertical') {
-      v.height = (pen.btnHeight || 32)  * pen.data.length + (pen.gap || 8) * (pen.data.length + 1);
-    } else {
-      v.height = (pen.btnHeight || 32) + (pen.gap || 8) * 2;
+    if(pen.btnWidth) {
+      if (pen.direction == 'vertical') {
+        v.width = pen.btnWidth + (pen.gap || 8) * 2;
+      } else {
+        v.width = pen.btnWidth  * pen.data.length + (pen.gap || 8) * (pen.data.length + 1);
+      }
     }
-  } 
+  }
   meta2d.setValue(v, { render });
 };