浏览代码

feat:actions-props

ananzhusen 1 年之前
父节点
当前提交
b01d2ed823
共有 2 个文件被更改,包括 85 次插入43 次删除
  1. 82 43
      src/views/components/Actions.vue
  2. 3 0
      src/views/components/PenEvents.vue

+ 82 - 43
src/views/components/Actions.vue

@@ -153,7 +153,7 @@
                         />
                       </t-dropdown-item>
                       <t-dropdown-item
-                        v-for="prop in a.props"
+                        v-for="prop in cprops"
                         :key="prop.value"
                         :value="prop.value"
                       >
@@ -253,7 +253,7 @@
                         />
                       </t-dropdown-item>
                       <t-dropdown-item
-                        v-for="prop in a.props"
+                        v-for="prop in cprops"
                         :key="prop.value"
                         :value="prop.value"
                       >
@@ -460,45 +460,84 @@ const onChangeAction = (action: any) => {
   }
 };
 
+let cprops = [
+  {
+    value: 'x',
+    label: 'X',
+  },
+  {
+    value: 'y',
+    label: 'Y',
+  },
+  {
+    value: 'width',
+    label: '宽',
+  },
+  {
+    value: 'height',
+    label: '高',
+  },
+  {
+    value: 'visible',
+    label: '显示',
+  },
+  {
+    value: 'text',
+    label: '文字',
+  },
+  {
+    value: 'progress',
+    label: '进度',
+  },
+  {
+    value: 'showChild',
+    label: '状态',
+  },
+  {
+    value: 'rotate',
+    label: '旋转',
+  },
+];
+
 const getProps = (c: any) => {
-  c.props = [
-    {
-      value: 'x',
-      label: 'X',
-    },
-    {
-      value: 'y',
-      label: 'Y',
-    },
-    {
-      value: 'width',
-      label: '宽',
-    },
-    {
-      value: 'height',
-      label: '高',
-    },
-    {
-      value: 'visible',
-      label: '显示',
-    },
-    {
-      value: 'text',
-      label: '文字',
-    },
-    {
-      value: 'progress',
-      label: '进度',
-    },
-    {
-      value: 'showChild',
-      label: '状态',
-    },
-    {
-      value: 'rotate',
-      label: '旋转',
-    },
-  ];
+  // c.props = [
+  //   {
+  //     value: 'x',
+  //     label: 'X',
+  //   },
+  //   {
+  //     value: 'y',
+  //     label: 'Y',
+  //   },
+  //   {
+  //     value: 'width',
+  //     label: '宽',
+  //   },
+  //   {
+  //     value: 'height',
+  //     label: '高',
+  //   },
+  //   {
+  //     value: 'visible',
+  //     label: '显示',
+  //   },
+  //   {
+  //     value: 'text',
+  //     label: '文字',
+  //   },
+  //   {
+  //     value: 'progress',
+  //     label: '进度',
+  //   },
+  //   {
+  //     value: 'showChild',
+  //     label: '状态',
+  //   },
+  //   {
+  //     value: 'rotate',
+  //     label: '旋转',
+  //   },
+  // ];
 
   let target: any;
   if (c.params) {
@@ -508,9 +547,9 @@ const getProps = (c: any) => {
   }
   if (target?.realTimes) {
     for (const item of target.realTimes) {
-      const found = c.props.findIndex((elem: any) => elem.value === item.key);
+      const found = cprops.findIndex((elem: any) => elem.value === item.key);
       if (found < 0) {
-        c.props.push({
+        cprops.push({
           value: item.key,
           label: item.label,
         });
@@ -520,7 +559,7 @@ const getProps = (c: any) => {
 };
 
 const getPropDesc = (a: any, key: any) => {
-  const found = a.props.find((elem: any) => elem.value === key);
+  const found = cprops.find((elem: any) => elem.value === key);
   if (found) {
     return found.label;
   }

+ 3 - 0
src/views/components/PenEvents.vue

@@ -124,6 +124,9 @@ onBeforeMount(() => {
 });
 
 const addEvent = (e: any) => {
+  if (!props.pen.events) {
+    props.pen.events = [];
+  }
   props.pen.events.push({ name: e.value });
 };