Parcourir la source

fix:完善新接口的替换

Wind-Breaker1 il y a 1 an
Parent
commit
a55d5ee64a

Fichier diff supprimé car celui-ci est trop grand
+ 177 - 350
pnpm-lock.yaml


+ 5 - 6
src/services/api.ts

@@ -52,8 +52,7 @@ export async function getCollectionList(
   data: any,
   config: any
 ) {
-  // return await axios.post(`/api/data/${collection}/list`, data, config);
-  return await axios.post(`/api/data/v/list`, data, config);
+  return await axios.post(`/api/data/${collection}/list`, data, config);
 }
 
 export async function getLe5leV(id: string, projection?: any) {
@@ -64,17 +63,17 @@ export async function getLe5leV(id: string, projection?: any) {
 }
 
 export async function getComponents(id: string) {
-  return await axios.post(`/api/data/v-components/get`, {
+  return await axios.post(`/api/data/v.component/get`, {
     id,
   });
 }
 
 export async function getComponentsList(data: any, config: any) {
-  return await axios.post('/api/data/v-components/list', data, config);
+  return await axios.post('/api/data/v.component/list', data, config);
 }
 
 export async function getLe5le3d(id: string, projection?: any) {
-  return await axios.post(`/api/data/le5le3d/get`, {
+  return await axios.post(`/api/data/3d/get`, {
     id,
     projection,
   });
@@ -85,7 +84,7 @@ export async function getProjectsList(data: any, config: any) {
 }
 
 export async function getLe5le2d(id: string, projection?: any) {
-  return await axios.post('/api/data/le5le2d/get', {
+  return await axios.post('/api/data/2d/get', {
     id,
     projection,
   });

+ 48 - 31
src/services/common.ts

@@ -127,7 +127,7 @@ export const _save = async (
     return;
   }
   if (
-    vType === 'v-components' &&
+    vType === 'v.component' &&
     meta2d.store.active &&
     meta2d.store.active.length === 1 &&
     meta2d.store.active[0].name === 'combine'
@@ -150,7 +150,7 @@ export const _save = async (
       return;
     }
 
-    const file = await upload(blob, true);
+    const file:any = await upload(blob, true);
     if (!file) {
       return;
     }
@@ -167,7 +167,7 @@ export const _save = async (
     comData.name =
       (meta2d.store.active[0] as any).description ||
       `meta2d.${new Date().toLocaleString()}`;
-    let ret: any = await addCollection('v-components', comData); // 新增
+    let ret: any = await addCollection('v.component.', comData); // 新增
     if (ret.error) {
       return;
     }
@@ -186,7 +186,7 @@ export const _save = async (
     return;
   }
   if (!data.tags.includes('系统模板') && !data.tags.includes('系统方案')) {
-    if (vType === 'v-template') {
+    if (vType === 'v.template') {
       if (data.tags && !data.tags.includes('模板')) {
         delete data._id;
         delete data.id;
@@ -233,7 +233,7 @@ export const _save = async (
       }
     }
 
-    const file = await upload(blob, true);
+    const file:any = await upload(blob, true);
     if (!file) {
       return;
     }
@@ -244,7 +244,7 @@ export const _save = async (
     // }, 1000);
   }
   // setTimeout(async () => {
-  if (data.component || vType === 'v-components') {
+  if (data.component || vType === 'v.component') {
     data.component = true;
     // pens 存储原数据用于二次编辑 ; componentDatas 组合后的数据,用于复用
     data.componentDatas = meta2d.toComponent(
@@ -255,7 +255,7 @@ export const _save = async (
   } else {
     data.component = false; // 必要值
   }
-  let collection = data.component ? 'v-components' : 'v';
+  let collection = data.component ? 'v.component' : 'v';
   let ret: any;
   if (!data.name) {
     // 文件名称
@@ -380,7 +380,8 @@ export const _save = async (
 export const save = async (
   type: SaveType = SaveType.Save,
   vType?: string,
-  notice?: boolean
+  notice?: boolean,
+  userFlag?:number
 ) => {
   if (!saveFlag) {
     return;
@@ -392,7 +393,7 @@ export const save = async (
   saveTimer = setTimeout(() => {
     saveFlag = true;
   }, 2000);
-
+  // 区分是模板还是方案
   meta2d.stopAnimate();
   const data: Meta2dBackData = meta2d.data();
   console.log('data',deepClone(data))
@@ -403,7 +404,7 @@ export const save = async (
   }
   // 保存为组件
   if (
-    vType === 'v-components' &&
+    vType === 'v.component' &&
     meta2d.store.active &&
     meta2d.store.active.length === 1 &&
     meta2d.store.active[0].name === 'combine'
@@ -416,9 +417,10 @@ export const save = async (
       x: data.x,
       y: data.y,
     };
-    comData.name =
-      (meta2d.store.active[0] as any).description ||
-      `meta2d.${new Date().toLocaleString()}`;
+    // comData.name =
+    //   (meta2d.store.active[0] as any).description ||
+    //   `meta2d.${new Date().toLocaleString()}`;
+    comData.name =  comData.name = (meta2d.store.active[0] as any).description ||'新建项目';
     let blob: Blob;
     try {
       blob = dataURLtoBlob(meta2d.activeToPng(0) + '');
@@ -429,14 +431,14 @@ export const save = async (
       return;
     }
     //todo 传参数
-    const file = await upload(blob, true, comData.name, `/大屏/组件/默认`);
+    const file:any = await upload(blob, true, comData.name, `/大屏/组件/默认`,'new');
     if (!file) {
       return;
     }
 
-    // 缩略图
+    // // 缩略图
     comData.image = file.url;
-    comData.filename = file.filename;
+    comData.fullname = file.fullname;
     comData.component = true;
     const allPens = meta2d.canvas.getAllByPens(meta2d.store.active);
     comData.componentDatas = meta2d.toComponent(
@@ -444,7 +446,14 @@ export const save = async (
       (meta2d.store.data as Meta2dBackData).showChild,
       false
     );
-    let ret: any = await addCollection('v-components', comData); // 新增
+    const body = {
+      data:comData,
+      image:comData.image,
+      name:comData.name,
+      folder: '',
+      userFlag
+    }
+    let ret: any = await addCollection('v.component', body); // 新增
     if (ret.error) {
       return;
     }
@@ -452,7 +461,6 @@ export const save = async (
     return;
   }
   //删除老图片  新图片上传
-
   checkData(data);
   if (
     (globalThis as any).beforeSaveMeta2d &&
@@ -468,23 +476,30 @@ export const save = async (
     if (vType === 'v-template') {
       if (data.tags && !data.tags.includes('模板')) {
         delete data.id;
-        delete data.id;
+        delete data._id;
         delete data.folder;
       }
       data.tags = ['模板'];
     } else if (!vType) {
       if (data.tags && !data.tags.includes('方案')) {
         delete data.id;
-        delete data.id;
+        delete data._id;
         delete data.folder;
       }
       data.tags = ['方案'];
+    } else if(vType === 'v.component') {
+      if (data.tags && (!data.tags.includes('组件'))) {
+        delete data.id;
+        delete data._id;
+        delete data.folder;
+      }
+      data.tags = ['组件'];
     }
   }
   const thumbFolder =
     vType === 'v-template'
       ? '模板'
-      : vType === 'v-components'
+      : vType === 'v.component'
       ? '组件'
       : '方案';
   if (type === SaveType.SaveAs) {
@@ -516,9 +531,9 @@ export const save = async (
       );
       return;
     }
-    let conflict = undefined;
-    console.log()
+    let conflict = 'new';
     if (data.id && type === SaveType.Save) {
+      conflict = undefined
       if (data.image && !(await delImage(data.image))) {
         return;
       }
@@ -526,7 +541,7 @@ export const save = async (
 
     const file:any = await upload(
       blob,
-      // true,
+      true,
       data.image?.split('/').pop() || data.name,
       `/大屏/${thumbFolder}/${data.folder || '默认'}`,
       conflict
@@ -541,7 +556,7 @@ export const save = async (
     (meta2d.store.data as Meta2dBackData).image = data.image;
     (meta2d.store.data as Meta2dBackData).filename = data.filename;
   }
-  if (data.component || vType === 'v-components') {
+  if (data.component || vType === 'v.component') {
     data.component = true;
     // pens 存储原数据用于二次编辑 ; componentDatas 组合后的数据,用于复用
     data.componentDatas = meta2d.toComponent(
@@ -552,7 +567,7 @@ export const save = async (
   } else {
     data.component = false; // 必要值
   }
-  let collection = data.component ? 'v-components' : 'v';
+  let collection = data.component ? 'v.component' : 'v';
   let ret: any;
 
   !data.version && (data.version = baseVer);
@@ -565,7 +580,8 @@ export const save = async (
     image:data.image,
     name:data.name,
     folder:data.folder,
-    shared:true
+    shared:true,
+    userFlag
   }
   if (type === SaveType.SaveAs) {
     // 另存为一定走 新增 ,由于后端 未控制 userId 等属性,清空一下
@@ -575,15 +591,16 @@ export const save = async (
     if (!data.tags || !data.tags.length) {
       data.tags = ['方案'];
     }
-    ret = await addCollection(collection, data);
+    ret = await addCollection(collection, body);
   } else {
     // if (data._id && data.teams && data.owner?.id !== user.id) {
     //   // 团队图纸 不允许修改文件夹信息
     //   delete data.folder;
     //   ret = await updateCollection(collection, data);
     // } else
-    if (data.id) {
-      ret = await updateCollection(collection, {id:data.id,...body});
+    
+    if (data.id || data._id) {
+      ret = await updateCollection(collection, {id:data.id || data._id,...body});
     } else {
       ret = await addCollection(collection, body); // 新增
     }
@@ -605,7 +622,7 @@ export const save = async (
       query: {
         id: data.id,
         r: Date.now() + '',
-        c: data.component ? 1 : undefined,
+        c: vType === 'v.component' ? 1 : undefined,
       },
     });
   }

+ 2 - 2
src/services/file.ts

@@ -2,7 +2,7 @@ import axios from 'axios';
 
 export async function upload(
   blob: Blob,
-  // shared = false,
+  shared = false,
   filename = 'thumb.png',
   directory = '/大屏/图片/默认',
   conflict?:string
@@ -10,7 +10,7 @@ export async function upload(
   const form = new FormData();
   form.append('filename', filename);
   form.append('directory', directory);
-  // form.append('shared', shared + '');
+  form.append('shared', shared + '');
   form.append('file', blob);
   // let ret;
   if(conflict) {

+ 1 - 1
src/views/components/FileProps.vue

@@ -204,7 +204,7 @@
                     </div>
                     <div v-else class="desc mt-4">
                       支持添加iconfont。
-                      <a :href="getEnterprise.account" target="_blank">VIP</a>
+                      <a :href="(getEnterprise as any).account" target="_blank">VIP</a>
                       功能
                     </div>
                   </div>

+ 120 - 87
src/views/components/Graphics.vue

@@ -57,10 +57,9 @@
         <template v-else>
           <div
             v-if="
-              activedGroup === '组件' ||
               activedGroup === '图片' ||
               (activeAssets === 'user' &&
-                (activedGroup === '方案' || activedGroup === '模板'))
+                (activedGroup === '方案' || activedGroup === '模板' || activedGroup === '组件'))
             "
             class="px-16 mt-12 mb-8 ml-4"
           >
@@ -92,12 +91,9 @@
               <template #headerRightContent>
                 <t-space size="small" @click.stop tabindex="0">
                   <t-upload
-                    v-if="
-                      item.canEdited &&
-                      (activedGroup === '组件' || activedGroup === '图片')
-                    "
+                    v-if="item.canEdited && activedGroup === '图片'"
                     action="/api/image/upload"
-                    :accept="activedGroup === '组件' ? '.svg' : 'image/*'"
+                    accept="image/*"
                     :headers="headers"
                     :data="{
                       directory: `/大屏/${activedGroup}/${item.name}`,
@@ -378,6 +374,12 @@ const systemGroups = [
     name: '模板',
     key: '',
   },
+  {
+    icon: 'l-zujian',
+    name: '组件',
+    key: 'chart',
+    type: 'iconfont',
+  },
   {
     icon: 'chart',
     name: '图表',
@@ -446,6 +448,7 @@ const activedPanels = reactive<any>({});
 
 const caseCaches = [];
 const templateCaches = [];
+const componentCaches = [];
 const materials = [];
 const pngs = [];
 
@@ -489,7 +492,7 @@ const groupChange = async (name: string) => {
       if (activeAssets.value === 'system') {
         if (!caseCaches.length) {
           loading.value = true;
-          caseCaches.push(...(await getCaseProjects('系统方案')));
+          caseCaches.push(...(await getCaseProjects('系统方案',1)));
           for (const group of cases) {
             group.list = [];
             for (const item of caseCaches) {
@@ -511,7 +514,7 @@ const groupChange = async (name: string) => {
         // userLastName = name;
 
         //用户方案
-        subGroups.value = await getCollectionImageList('方案', 'v');
+        subGroups.value = await getCollectionImageList('方案', 'v',1);
         groupType.value = 1;
         userLastName = name;
       }
@@ -520,7 +523,7 @@ const groupChange = async (name: string) => {
       if (activeAssets.value === 'system') {
         if (!templateCaches.length) {
           loading.value = true;
-          templateCaches.push(...(await getCaseProjects('系统模板')));
+          templateCaches.push(...(await getCaseProjects('系统模板',2)));
           for (const group of templates) {
             group.list = [];
             for (const item of templateCaches) {
@@ -540,7 +543,7 @@ const groupChange = async (name: string) => {
         // groupType.value = 1;
         // await getPrivateProjects('le5leV-template');
         // userLastName = name;
-        subGroups.value = await getCollectionImageList('模板', 'le5leV');
+        subGroups.value = await getCollectionImageList('模板', 'v',2);
         groupType.value = 1;
         userLastName = name;
       }
@@ -588,16 +591,28 @@ const groupChange = async (name: string) => {
       lastName = name;
       break;
     case '组件':
-      // subGroups.value = await getUserComponents();
-      // groupType.value = 1;
-      // await getPrivateGraphics();
-      // userLastName = name;
-      subGroups.value = await getCollectionImageList(
-        '组件',
-        'le5leV-components'
-      );
-      groupType.value = 1;
-      userLastName = name;
+      if (activeAssets.value === 'system') {
+        if (!componentCaches.length) {
+          loading.value = true;
+          componentCaches.push(...(await getCaseProjects('系统组件',1)));
+          loading.value = false;
+        }
+        groupType.value = 1;
+        subGroups.value = componentCaches;
+        lastName = name;
+      } else {
+          // subGroups.value = await getUserComponents();
+        // groupType.value = 1;
+        // await getPrivateGraphics();
+        // userLastName = name;
+        subGroups.value = await getCollectionImageList(
+          '组件',
+          'v.component',
+          1
+        );
+        groupType.value = 1;
+        userLastName = name;
+      }
       break;
     case '图片':
       loading.value = true;
@@ -628,7 +643,7 @@ const groupChange = async (name: string) => {
 };
 // TODO 获取方案文件
 //获取方案文件夹
-const getCollectionImageList = async (name?: string, collection?: string) => {
+const getCollectionImageList = async (name?: string, collection?: string, userFlag?:number) => {
   //1. 获取网盘文件夹
   const fullpath = `/大屏/${name}`;
   let ret: { list: any[] } = await axios.post('/api/directory/list', {
@@ -647,13 +662,13 @@ const getCollectionImageList = async (name?: string, collection?: string) => {
       list.push(i);
     }
   }
-
   const data = {
-    directory: "/大屏/方案/123",
+    // directory: `/大屏/${name}`,
     // query: {
     //   // folder: '',
     //   tags: name !== '组件' ? name : undefined,
     // },
+    userFlag,
     projection: {
       image: 1,
       id: 1,
@@ -743,15 +758,15 @@ const getImageList = async () => {
       let list = _ret.list.map((_item) => {
         return {
           ..._item,
-          image: _item.metadata.url || `/file${_item.filename}`,
+          image: _item.url || `/file${_item.filename}`,
           visible: true,
           folder: item.fullpath,
-          _id: _item._id,
+          id: _item.id || _item._id,
         };
       });
       return {
         name: secondDir[3],
-        _id: item._id,
+        id: item.id || item._id,
         canEdited: secondDir[3] !== '默认',
         list: list,
       };
@@ -759,11 +774,11 @@ const getImageList = async () => {
   );
 };
 
-const getCaseProjects = async (name: string, current = 1, pageSize = 1000) => {
+const getCaseProjects = async (name: string,systemFlag = 1, current = 1, pageSize = 1000) => {
   const query: any = { tags: name };
-
+  let collection = name == '系统组件' ? 'v.vomponent' : 'v';
   const ret: any = await axios.post(
-    '/api/data/le5leV/list',
+    `/api/data/${collection}/list`,
     {
       query,
       shared: 'true',
@@ -776,6 +791,7 @@ const getCaseProjects = async (name: string, current = 1, pageSize = 1000) => {
         case: 1,
       },
       sort: { createdAt: 1 },
+      systemFlag
     },
     {
       params: {
@@ -857,9 +873,9 @@ const getPrivateGroups = async () => {
         name: 1,
         list: 1,
       },
-      query: {
-        type: `le5leV-components`,
-      },
+      // query: {
+      //   type: `v-components`,
+      // },
       sort: { createdAt: 1 },
     },
     config
@@ -904,7 +920,7 @@ const getUserComponents = async () => {
         list: 1,
       },
       query: {
-        type: `le5leV-components`,
+        type: `v.component`,
       },
       sort: { createdAt: 1 },
     },
@@ -969,7 +985,7 @@ const getPrivateProjects = async (type: string) => {
         const data = {
           query: {
             folder: '',
-            tags: type === 'le5leV-template' ? '模板' : '方案',
+            tags: type === 'v-template' ? '模板' : '方案',
           },
           projection: {
             image: 1,
@@ -984,7 +1000,7 @@ const getPrivateProjects = async (type: string) => {
             pageSize: 1000,
           },
         };
-        const res: any = await getCollectionList('le5leV', data, config);
+        const res: any = await getCollectionList('v', data, config);
         if (res?.list) {
           // res.list.forEach((item) => {
           //   item.draggable = false;
@@ -1056,7 +1072,7 @@ const dragStart = async (event: DragEvent | MouseEvent, item: any) => {
     // 默认
     if (!item.componentDatas && !item.componentData) {
       isAsync = true;
-      const ret: any = await axios.post(`/api/data/le5leV-components/get`, {
+      const ret: any = await axios.post(`/api/data/v.component/get`, {
         id,
       });
       item.componentDatas = ret.componentDatas;
@@ -1196,7 +1212,7 @@ const getPrivateGraphics = async () => {
           },
         };
         const res: any = await axios.post(
-          '/api/data/le5le3d/list',
+          '/api/data/3d/list',
           data,
           config
         );
@@ -1249,7 +1265,7 @@ const createFoder = async () => {
   if (activeAssets.value !== 'user') {
     return;
   }
-  if (editedFolder.value.id) {
+  if (editedFolder.value.id || editedFolder.value._id) {
     const ret: any = await axios.post('/api/directory/update', {
       oldFullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.oldLabel,
       newFullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.label,
@@ -1261,11 +1277,11 @@ const createFoder = async () => {
     //更新图纸的folder
     if (['组件', '方案', '模板'].includes(activedGroup.value)) {
       const collection =
-        activedGroup.value === '组件' ? 'le5leV-components' : 'le5leV';
+        activedGroup.value === '组件' ? 'v.component' : 'v';
       editedFolder.value.list?.forEach(async (item) => {
         item.folder = editedFolder.value.label;
         await updateCollection(collection, {
-          id: item.id,
+          id: item.id || item._id,
           folder: editedFolder.value.label,
         });
       });
@@ -1276,7 +1292,7 @@ const createFoder = async () => {
     });
     if (ret) {
       editedFolder.value.name = editedFolder.value.label;
-      editedFolder.value._id = ret._id || ret.id;
+      editedFolder.value.id = ret.id;
       editedFolder.value.edited = false;
     }
   }
@@ -1314,10 +1330,10 @@ const _createFoder = async () => {
     } else {
       let type =
         activedGroup.value === '组件'
-          ? 'le5leV-components'
+          ? 'v.component'
           : activedGroup.value === '模板'
-          ? 'le5leV-template'
-          : 'le5leV';
+          ? 'v-template'
+          : 'v';
       const ret: any = await axios.post('/api/data/folders/add', {
         name: editedFolder.value.label,
         type,
@@ -1362,11 +1378,11 @@ const onEditHeader = (item: any) => {
 const onAdd = (item: any) => {
   blank();
   if (activedGroup.value === '方案') {
-    item.vType = 'le5leV';
+    item.vType = 'v';
   } else if (activedGroup.value === '模板') {
-    item.vType = 'le5leV-template';
+    item.vType = 'v-template';
   } else if (activedGroup.value === '组件') {
-    item.vType = 'le5leV-components';
+    item.vType = 'v.component';
   }
   setFolder(item);
   const query: any = {
@@ -1468,7 +1484,8 @@ const onMenu = async (val: string) => {
         contextmenu.activeValue = 0;
         return;
       }
-      if (contextmenu.component.component) {
+      // if (contextmenu.component.component) {
+      if (activedGroup.value == '组件') {
         autoSave();
         router.push({
           path: '/',
@@ -1545,8 +1562,8 @@ const onMenu = async (val: string) => {
         }
       });
       if (activedGroup.value !== '图片') {
-        let collection = contextmenu.component.component
-          ? 'v-components'
+        let collection = activedGroup.value === '组件'
+          ? 'v.component'
           : 'v';
         // 更新后端组件信息
         let ret = await updateCollection(collection, {
@@ -1578,10 +1595,16 @@ const onMenu = async (val: string) => {
       if (imageDrive && filename.startsWith(imageDrive)) {
         filename = filename.slice(imageDrive.length);
       }
+      let fullname: string =
+        contextmenu.component.filename || contextmenu.component.image;
       //更新缩略图位置
-      await axios.post('/api/files/update', {
-        filenames: [filename],
-        'metadata.directory': `/大屏/${activedGroup.value}/${val || '默认'}`,
+      // await axios.post('/api/files/update', {
+      //   filenames: [filename],
+      //   'metadata.directory': `/大屏/${activedGroup.value}/${val || '默认'}`,
+      // });
+      await axios.patch(`/api${fullname}`, {
+        // filenames: [filename],
+        directory: `/大屏/${activedGroup.value}/${val || '默认'}`,
       });
       break;
   }
@@ -1596,8 +1619,8 @@ const _delComponent = async () => {
   // const id = contextmenu.component._id || contextmenu.component.id;
   if (['组件', '方案', '模板'].includes(activedGroup.value)) {
     let collection = delDialog.contextmenuObj.component.component
-      ? 'le5leV-components'
-      : 'le5leV';
+      ? 'v.component'
+      : 'v';
     const id =
       delDialog.contextmenuObj.component._id ||
       delDialog.contextmenuObj.component.id;
@@ -1649,7 +1672,7 @@ const _delComponent = async () => {
       }
     );
     await axios.post(`/api/files/delete`, {
-      filenames: [delDialog.contextmenuObj.component.filename],
+      fullnames: [delDialog.contextmenuObj.component.filename],
       physically: false,
     });
   }
@@ -1662,9 +1685,15 @@ const _delComponent = async () => {
 const delComponent = async () => {
   // const id = contextmenu.component._id || contextmenu.component.id;
   if (['组件', '方案', '模板'].includes(activedGroup.value)) {
-    let collection = delDialog.contextmenuObj.component.component
-      ? 'v-components'
-      : 'v';
+    // let collection = delDialog.contextmenuObj.component.component
+    //   ? 'v.component'
+    //   : 'v';
+    let collection = '';
+    if(activedGroup.value == '组件') {
+      collection = 'v.component'
+    } else {
+      collection = 'v'
+    }
     const id =
       delDialog.contextmenuObj.component._id ||
       delDialog.contextmenuObj.component.id;
@@ -1701,14 +1730,17 @@ const delComponent = async () => {
       }
     );
   }
-  let filename: string =
-    delDialog.contextmenuObj.component.filename ||
+  let fullname: string =
+    delDialog.contextmenuObj.component.fullname ||
     delDialog.contextmenuObj.component.image;
-  if (imageDrive && filename.startsWith(imageDrive)) {
-    filename = filename.slice(imageDrive.length);
+  if (imageDrive && fullname.startsWith(imageDrive)) {
+    fullname = fullname.slice(imageDrive.length);
+  }
+  if(fullname.startsWith('/file')) {
+    fullname = fullname.slice('/file'.length);
   }
   await axios.post(`/api/files/delete`, {
-    filenames: [filename],
+    fullnames: [fullname],
     physically: false,
   });
   delDialog.show = false;
@@ -1729,7 +1761,7 @@ const drop = (obj: any) => {
 
 const onSubmitOrder = async () => {
   const result: any = await axios.post('/api/order/datas/submit', {
-    collection: 'le5leV',
+    collection: 'v',
     id: chargeDialog.data._id,
   });
   if (result) {
@@ -1844,21 +1876,22 @@ function processFileObj(fileObj, c) {
 }
 
 const fileSuccessed = async (content: any) => {
-  if (activedGroup.value === '组件') {
-    const c: any = {
-      name: filename(content.file.name),
-      image:
-        content.response.url ||
-        content.response.metadata.url ||
-        `/file${content.response.filename}`,
-      folder: uploadGroup.name === '默认' ? '' : uploadGroup.name,
-    };
-    let rst = await processFileObj(
-      { raw: content.file.raw, name: content.file.name },
-      c
-    );
-    const ret: any = await addCollection('le5leV-components', rst);
-    c._id = ret._id || ret.id;
+  // 组件中去掉了上传图片入口
+  // if (activedGroup.value === '组件') {
+  //   const c: any = {
+  //     name: filename(content.file.name),
+  //     image:
+  //       content.response.url ||
+  //       content.response.metadata.url ||
+  //       `/file${content.response.filename}`,
+  //     folder: uploadGroup.name === '默认' ? '' : uploadGroup.name,
+  //   };
+  //   let rst = await processFileObj(
+  //     { raw: content.file.raw, name: content.file.name },
+  //     c
+  //   );
+  //   const ret: any = await addCollection('v.component', rst);
+  //   c._id = ret._id || ret.id;
     // if (ret && uploadGroup.name !== '默认') {
     //   if (!uploadGroup.list) {
     //     uploadGroup.list = [];
@@ -1875,8 +1908,8 @@ const fileSuccessed = async (content: any) => {
     //   }
     //   uploadGroup.list.push(c);
     // }
-    uploadGroup.list.push(c);
-  } else if (activedGroup.value === '图片') {
+  //   uploadGroup.list.push(c);
+  // } else if (activedGroup.value === '图片') {
     uploadGroup.list.push({
       ...content.response,
       image:
@@ -1884,9 +1917,9 @@ const fileSuccessed = async (content: any) => {
         content.response.metadata.url ||
         `/file${content.response.filename}`,
       visible: true,
-      folder: content.response.metadata.directory,
+      folder: content.response.directory || content.response.metadata.directory,
     });
-  }
+  // }
   MessagePlugin.success('上传成功');
 };
 
@@ -1928,9 +1961,9 @@ const reloadCurrent = () => {
 
 const updateAfterSave = (e) => {
   if (activeAssets.value === 'user') {
-    if (e === 'le5leV-components' && activedGroup.value === '组件') {
+    if (e === 'v.component' && activedGroup.value === '组件') {
       groupChange('组件');
-    } else if (e === 'le5leV-template' && activedGroup.value === '模板') {
+    } else if (e === 'v-template' && activedGroup.value === '模板') {
       groupChange('模板');
     } else if (e === '' && activedGroup.value === '方案') {
       groupChange('方案');

+ 4 - 3
src/views/components/View.vue

@@ -15,7 +15,7 @@
             <t-icon
               name="save"
               class="hover"
-              @click="!route.query.c && save(SaveType.Save, '', true)"
+              @click="!route.query.c && save(SaveType.Save, '', true,1)"
             />
           </t-badge>
         </a>
@@ -32,7 +32,7 @@
               name="root-list"
               class="hover"
               @click="
-                !route.query.c && save(SaveType.Save, 'le5leV-template', true)
+                !route.query.c && save(SaveType.Save, 'v-template', true,2)
               "
             />
           </t-badge>
@@ -47,7 +47,7 @@
             /> -->
             <i
               class="l-icon l-zujian hover"
-              @click="save(SaveType.Save, 'le5leV-components', true)"
+              @click="save(SaveType.Save, 'v.component', true,1)"
             >
             </i>
           </t-badge>
@@ -895,6 +895,7 @@ const open = async (flag: boolean = false) => {
         return;
       }
       ret.data.id = ret.id;
+      ret.data.folder = ret.folder;
       meta2d.open(ret.data);
       if (!route.query.c) {
         shared.value = ret.shared;

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff