Alsmile 1 年之前
父节点
当前提交
d654436b97
共有 1 个文件被更改,包括 45 次插入34 次删除
  1. 45 34
      src/views/components/Graphics.vue

+ 45 - 34
src/views/components/Graphics.vue

@@ -400,40 +400,51 @@ const dragStart = async (event: DragEvent | MouseEvent, item: any) => {
     return;
   }
   let data = null;
-  if (item._id && !item.componentDatas) {
-    let res: any = await getComponents(item._id);
-    item.component = true;
-    item.componentDatas = res.componentDatas;
-    item.componentData = res.componentData;
-  }
-  if (!item.data && !item.component && item.image) {
-    let target: any = event.target;
-    target.children[0] && (target = target.children[0].children[0]);
-    // firefox naturalWidth svg 图片 可能是 0
-    const normalWidth = target.naturalWidth || target.width;
-    const normalHeight = target.naturalHeight || target.height;
-    const [name, lockedOnCombine] = isGif(item.image)
-      ? ['gif', 0]
-      : ['image', undefined];
-
+  if (item['3d']) {
     data = {
-      name,
-      width: 100,
-      height: 100 * (normalHeight / normalWidth),
-      image: item.image,
-      imageRatio: true,
-      lockedOnCombine,
+      name: 'iframe',
+      width: 400,
+      height: 300,
+      externElement: true,
+      iframe: 'https://view3d.le5le.com/?id=' + (item._id || item.id),
     };
-  } else if (item.component) {
-    if (item.componentData) {
-      const pens = convertPen([item.componentData]);
-      data = deepClone(pens);
-    } else if (item.componentDatas) {
-      data = deepClone(item.componentDatas);
-    }
   } else {
-    data = item.componentDatas || item.data;
+    if (item._id && !item.componentDatas) {
+      let res: any = await getComponents(item._id);
+      item.component = true;
+      item.componentDatas = res.componentDatas;
+      item.componentData = res.componentData;
+    }
+    if (!item.data && !item.component && item.image) {
+      let target: any = event.target;
+      target.children[0] && (target = target.children[0].children[0]);
+      // firefox naturalWidth svg 图片 可能是 0
+      const normalWidth = target.naturalWidth || target.width;
+      const normalHeight = target.naturalHeight || target.height;
+      const [name, lockedOnCombine] = isGif(item.image)
+        ? ['gif', 0]
+        : ['image', undefined];
+
+      data = {
+        name,
+        width: 100,
+        height: 100 * (normalHeight / normalWidth),
+        image: item.image,
+        imageRatio: true,
+        lockedOnCombine,
+      };
+    } else if (item.component) {
+      if (item.componentData) {
+        const pens = convertPen([item.componentData]);
+        data = deepClone(pens);
+      } else if (item.componentDatas) {
+        data = deepClone(item.componentDatas);
+      }
+    } else {
+      data = item.componentDatas || item.data;
+    }
   }
+
   if (event instanceof DragEvent) {
     meta2d.canvas.addCaches = [];
     event.dataTransfer?.setData('Meta2d', JSON.stringify(data));
@@ -561,6 +572,9 @@ const onChangeGroupPanel = async (val: string[]) => {
                   config
                 );
                 if (res?.list) {
+                  for (const item of res.list) {
+                    item['3d'] = true;
+                  }
                   item.list = res.list;
                 }
               }
@@ -761,12 +775,9 @@ const onMenu = async (val: string) => {
 
 const delComponet = async () => {
   const id = contextmenu.component._id || contextmenu.component.id;
-  const ret = await axios.post(`/api/data/le5leV-components/delete`, {
+  await axios.post(`/api/data/le5leV-components/delete`, {
     id,
   });
-  if (!ret) {
-    return;
-  }
 
   // 前端:从源文件夹移出组件
   contextmenu.group.list.forEach((item: any, index: number, arr: any[]) => {