Browse Source

fix:修复线条动画添加自定义元素时名字为空的bug

Grnetsky 3 weeks ago
parent
commit
a5423842a3
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/views/components/PenAnimates.vue

+ 7 - 4
src/views/components/PenAnimates.vue

@@ -270,6 +270,7 @@
     v-model:visible="drawFuncDialog.show"
     :header="drawFuncDialog.edit ? '编辑动画元素' : '添加动画元素'"
     :width="800"
+    :closeOnOverlayClick="false"
     :destroy-on-close="true"
     @confirm="confirmLineDarwFunc"
     @close="drawFuncDialog.show = false"
@@ -434,8 +435,9 @@ const height = 10 // 此处定义图形高度
 ctx.translate(state.x + (width/2 * scale), state.y + (height/2 * scale));  // 平移到中心点
 ctx.rotate((state.rotate * Math.PI) / 180); // 配置旋转角度
 ctx.scale(scale, scale); // 配置缩放
-ctx.translate(-(width/2 * scale), -(he1/22 * scale));  // 平移回左上角
+ctx.translate(-(width/2 * scale), -(height/2 * scale));  // 平移回左上角
 
+ctx.beginPath();
 //在此处编写你的图形定义代码...
 
 ctx.restore()`, // 插入的文本
@@ -480,7 +482,7 @@ const confirmLineDarwFunc = ()=>{
       code
     });
   }else{
-    addLineDarwFunc()
+    if(!addLineDrawFunc()) return
   }
   syncLineAnimateDraws()
   drawFuncDialog.value.show = false;
@@ -503,15 +505,16 @@ const syncLineAnimateDraws = ()=>{
   })
 }
 
-const addLineDarwFunc = ()=>{
+const addLineDrawFunc = ()=>{
   if(!drawFuncDialog.value.name) {
     MessagePlugin.warning('请输入名称!');
-    return;
+    return false;
   }
   const code = `(ctx,pen,state,index)=>{
       ${drawFuncDialog.value.code}
     }`
   meta2d.registerLineAnimateDraws(drawFuncDialog.value.name,code);
+  return true
 }
 
 const penTree: any = ref([]);