瀏覽代碼

no message

linwenxin 5 月之前
父節點
當前提交
c9bad147fe
共有 2 個文件被更改,包括 26 次插入16 次删除
  1. 10 9
      src/main.js
  2. 16 7
      src/utils/request.js

+ 10 - 9
src/main.js

@@ -135,15 +135,16 @@ Vue.prototype.$xdocUrl = 'https://pgxtadm.greeapps.com/preview/onlinePreview?url
 
 Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_API + 'img/get?key='
 Vue.prototype.$showImgUrl = function (url) {
-  try {
-    const { pathname } = new URL(url)
-    if (pathname.startsWith('/')) {
-      return `${process.env.VUE_APP_BASE_API}img/get?key=${pathname.substring(1)}`
-    }
-    return `${process.env.VUE_APP_BASE_API}img/get?key=${pathname}`
-  } catch (error) {
-    return url
-  }
+  // try {
+  //   const { pathname } = new URL(url)
+  //   if (pathname.startsWith('/')) {
+  //     return `${process.env.VUE_APP_BASE_API}img/get?key=${pathname.substring(1)}`
+  //   }
+  //   return `${process.env.VUE_APP_BASE_API}img/get?key=${pathname}`
+  // } catch (error) {
+  //   return url
+  // }
+  return url
 }
 
 Vue.prototype.$findElem = findElem

+ 16 - 7
src/utils/request.js

@@ -52,11 +52,7 @@ service.interceptors.response.use(
    * Here is just an example
    * You can also judge the status by HTTP Status Code
    */ response => {
-    const res = replaceStringInObject(
-      response.data,
-      'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/',
-      `${process.env.VUE_APP_BASE_API}img/get?key=`
-    )
+    const res = response.data
 
     // if the custom code is not 20000, it is judged as an error.
     if (whiteCodes.indexOf(res.code) < 0) {
@@ -94,8 +90,21 @@ service.interceptors.response.use(
       }
       return Promise.reject(new Error(res.message || 'Error'))
     } else {
-      console.log(res)
-      return res
+      console.log(
+        replaceStringInObject(
+          res,
+          'https://zf-mall-test.oss-cn-shenzhen.aliyuncs.com/',
+          `${process.env.VUE_APP_BASE_API}img/get?key=`
+        ),
+        '------------'
+      )
+
+      return replaceStringInObject(
+        res,
+        'https://zf-mall-test.oss-cn-shenzhen.aliyuncs.com/',
+        `${process.env.VUE_APP_BASE_API}img/get?key=`
+      )
+      // return res
     }
   },
   error => {