Browse Source

修复边框弧度bug

liwei 1 year ago
parent
commit
1e7dd15cfe

+ 1 - 1
src/modules/editor/components/CompUI/defines/createAttrsForm.tsx

@@ -158,7 +158,7 @@ export const bdColumns: ColumnItem[] = [
   },
   {
     label: "边框弧度",
-    dataIndex: "layout.border.radius",
+    dataIndex: "layout.border.radius2",
     component: Slider,
     getValue(v) {
       if (v == undefined) return 0;

+ 6 - 2
src/modules/editor/objects/DesignTemp/creates/createCompStyle.ts

@@ -10,7 +10,7 @@ export function createCompStyle(
   layout: Layout,
   comp: DesignComp
 ) {
-  const { designToNaturalSize, pxToDesignSize } = module.helper;
+  const { designToNaturalSize, pxToDesignSize , designSizeToPx} = module.helper;
   const style: any = {};
   const transform: any = {};
 
@@ -36,8 +36,12 @@ export function createCompStyle(
       style["border-radius"] = layout.border.radius / 2 + "%";
       style["overflow"] = "hidden";
     }
+    if (layout.border.radius2 !== undefined) {
+      style["border-radius"] = designSizeToPx(Math.min(layout.size[0], layout.size[1])) * layout.border.radius2 / 100.0 + "px";
+      style["overflow"] = "hidden";
+    }
   }
-
+  
   if (layout.radius !== undefined) {
     style["border-radius"] = layout.radius / 2 + "%";
     style["overflow"] = "hidden";

+ 1 - 0
src/modules/editor/typings.ts

@@ -22,6 +22,7 @@ export type Layout = {
     width?: number;
     color?: string;
     radius?: number;
+    radius2?: number;
   };
   zIndex?: number;
   margin?: string;