Bladeren bron

no message

linwenxin 4 maanden geleden
bovenliggende
commit
fb2fa41a92
2 gewijzigde bestanden met toevoegingen van 7 en 5 verwijderingen
  1. 1 1
      src/common/http/index.js
  2. 6 4
      src/common/utils/util.js

+ 1 - 1
src/common/http/index.js

@@ -251,7 +251,7 @@ export const axios = function (obj = {}) {
         }
         const res = replaceStringInObject(
           ress.data,
-          'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/',
+          ['https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/', 'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/'],
           process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + '/common/img/get?key='
         )
         if (whiteCodes.indexOf(res.code) < 0) {

+ 6 - 4
src/common/utils/util.js

@@ -8,11 +8,13 @@ import axios2 from 'axios'
 
 import { setStorage, getStorage, removeStorage } from '@/common/utils/storage.js'
 
-export function replaceStringInObject(obj, target, replacement) {
+export function replaceStringInObject(obj, targets, replacement) {
   // 将对象转换为字符串
   let str = JSON.stringify(obj)
   // 替换所有目标字符串为替换字符串
-  str = str.replace(new RegExp(target, 'g'), replacement)
+  for (var target of targets) {
+    str = str.replace(new RegExp(target, 'g'), replacement)
+  }
   // 将字符串转换回对象
   return JSON.parse(str)
 }
@@ -410,7 +412,7 @@ export const uploadImgFull = async function (file) {
         resolve(
           replaceStringInObject(
             res.data.data,
-            'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/',
+            ['https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/', 'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/'],
             process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + '/common/img/get?key='
           )
         )
@@ -431,7 +433,7 @@ export const uploadImgFull = async function (file) {
         resolve(
           replaceStringInObject(
             JSON.parse(res.data).data,
-            'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/',
+            ['https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/', 'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/'],
             process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + '/common/img/get?key='
           )
         )