|
@@ -3,6 +3,15 @@ import { MessageBox, Message } from '@zjlib/element-ui2'
|
|
|
import store from '@/store'
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
|
|
|
+export function replaceStringInObject(obj, target, replacement) {
|
|
|
+ // 将对象转换为字符串
|
|
|
+ let str = JSON.stringify(obj)
|
|
|
+ // 替换所有目标字符串为替换字符串
|
|
|
+ str = str.replace(new RegExp(target, 'g'), replacement)
|
|
|
+ // 将字符串转换回对象
|
|
|
+ return JSON.parse(str)
|
|
|
+}
|
|
|
+
|
|
|
// create an axios instance
|
|
|
const service = axios.create({
|
|
|
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
|
|
@@ -43,7 +52,11 @@ service.interceptors.response.use(
|
|
|
* Here is just an example
|
|
|
* You can also judge the status by HTTP Status Code
|
|
|
*/ response => {
|
|
|
- const res = response.data
|
|
|
+ const res = replaceStringInObject(
|
|
|
+ response.data,
|
|
|
+ 'https://zfire-jsm-h.oss-cn-shenzhen.aliyuncs.com/',
|
|
|
+ `${process.env.VUE_APP_BASE_API}img/get?key=`
|
|
|
+ )
|
|
|
|
|
|
// if the custom code is not 20000, it is judged as an error.
|
|
|
if (whiteCodes.indexOf(res.code) < 0) {
|