Browse Source

fix:修复适配java后端接口bug

Wind-Breaker1 1 year ago
parent
commit
119fa0c5b3

+ 1 - 1
src/services/api.ts

@@ -12,7 +12,7 @@ export async function delImage(image: string) {
   if (image.startsWith('/file') || image.startsWith('/api')) {
     await axios.delete(`${image}`);
   } else if (image.startsWith(upCdn) || image.startsWith(imageDrive)) {
-    await axios.delete('/file' + image.replace(upCdn || imageDrive, ''));
+    await axios.delete('/api/file' + image.replace(upCdn || imageDrive, ''));
   } else {
     await axios.delete(`${image}`);
   }

+ 1 - 1
src/services/common.ts

@@ -541,7 +541,7 @@ export const save = async (
     }
     let conflict = 'new';
     if (data.id && type === SaveType.Save) {
-      conflict = undefined
+      // conflict = undefined
       if (data.image && !(await delImage(data.image))) {
         return;
       }

+ 24 - 20
src/views/components/Graphics.vue

@@ -912,7 +912,7 @@ const getPrivateGroups = async () => {
       //   name: 1,
       //   list: 1,
       // },
-      projection:'image,_id,name,list',
+      projection:'image,id,name,list',
       // query: {
       //   type: `v-components`,
       // },
@@ -959,7 +959,7 @@ const getUserComponents = async () => {
       //   name: 1,
       //   list: 1,
       // },
-      projection:'image,_id,name,list',
+      projection:'image,id,name,list',
       // query: {
       //   type: `v.component`,
       // },
@@ -1000,7 +1000,7 @@ const getUserProjects = async (type: string) => {
       //   name: 1,
       //   list: 1,
       // },
-      projection:'image,_id,name,list',
+      projection:'image,id,name,list',
       // query: {
       //   type,
       // },
@@ -1035,7 +1035,7 @@ const getPrivateProjects = async (type: string) => {
           //   name: 1,
           //   tags: 1,
           // },
-          projection:'image,_id,name,tags'
+          projection:'image,id,name,tags'
         };
         const config = {
           params: {
@@ -1182,14 +1182,6 @@ const open = async (item: any) => {
   if (!item || item.draggable !== false) {
     return;
   }
-  const ret: any = await getLe5leV(item._id || item.id);
-  if (!ret) {
-    if (item.price > 0) {
-      chargeDialog.data = item;
-      chargeDialog.show = true;
-    }
-    return;
-  }
 
   if (activeAssets.value === 'user') {
     router.push({
@@ -1200,6 +1192,14 @@ const open = async (item: any) => {
       },
     });
   } else {
+    const ret: any = await getLe5leV(item._id || item.id);
+    if (!ret) {
+      if (item.price > 0) {
+        chargeDialog.data = item;
+        chargeDialog.show = true;
+      }
+      return;
+    }
     sessionStorage.setItem('opening', '1');
     router.push({
       path: '/',
@@ -1231,7 +1231,7 @@ const getPrivateGraphics = async () => {
           //   name: 1,
           //   component: 1,
           // },
-          projection:'image,_id,name,component'
+          projection:'image,id,name,component'
         };
         const config = {
           params: {
@@ -1639,11 +1639,11 @@ const onMenu = async (val: string) => {
       //     list: group.list,
       //   });
       // }
-      let filename: string =
-        contextmenu.component.filename || contextmenu.component.image;
-      if (imageDrive && filename.startsWith(imageDrive)) {
-        filename = filename.slice(imageDrive.length);
-      }
+      // let filename: string =
+      //   contextmenu.component.filename || contextmenu.component.image;
+      // if (imageDrive && filename.startsWith(imageDrive)) {
+      //   filename = filename.slice(imageDrive.length);
+      // }
       let path: string =
         contextmenu.component.filename || contextmenu.component.image;
       //更新缩略图位置
@@ -1653,8 +1653,12 @@ const onMenu = async (val: string) => {
       // });
       // 原接口路径是 /api/file/{fullname}
       // 因为img的路径中包含file,所以做如下拼接
-      if(!path.startsWith('/api')) {
-        path = '/api' + path;
+      
+      if (imageDrive && path.startsWith(imageDrive)) {
+        path = path.slice(imageDrive.length);
+      }
+      if(!path.startsWith('/api/file')) {
+        path = '/api/file' + path;
       }
       await axios.patch(`${path}`, {
         // filenames: [filename],

+ 1 - 0
src/views/components/Header.vue

@@ -333,6 +333,7 @@
         <div>
           <span style="vertical-align: middle">{{ payListDialog.title }}</span>
           <!-- <t-tooltip  content="这是Tooltip内容"> -->
+          <!-- @vue-ignore -->
           <a
             :href="payListDialog.href"
             target="_blank"

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

@@ -1275,7 +1275,7 @@ const getThumbImg = async () => {
   //   _id: 1,
   //   name: 1,
   // };
-  let projection = 'image,_id,name';
+  let projection = 'image,id,name';
   let res: any;
   if (arr[0].indexOf('2d.le5le') !== -1) {
     res = await getLe5le2d(id, projection);

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

@@ -1549,7 +1549,7 @@ const getThumbImg = async () => {
   if (!id) {
     return;
   }
-  let projection = 'image,_id,name';
+  let projection = 'image,id,name';
   let res: any;
   if (arr[0].indexOf('2d.le5le') !== -1) {
     res = await getLe5le2d(id, projection);

+ 1 - 0
src/views/components/View.vue

@@ -938,6 +938,7 @@ const open = async (flag: boolean = false) => {
       ret.data.id = ret.id;
       ret.data.folder = ret.folder;
       ret.data.name = ret.name;
+      ret.data.image = ret.image;
       meta2d.open(ret.data);
       if (!route.query.c) {
         shared.value = ret.shared;