flat: 暂存
This commit is contained in:
@@ -24,5 +24,9 @@ module.exports = {
|
||||
url: ""
|
||||
}
|
||||
]
|
||||
},
|
||||
// 接口替换字符串
|
||||
replaceStr: {
|
||||
'{oss_file_url}': 'https://dy12333.org.cn/api'
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,9 @@ import store from '@/store/';
|
||||
import {
|
||||
baseUrl
|
||||
} from '@/config/env.js'
|
||||
import {
|
||||
replaceStr
|
||||
} from "../config";
|
||||
|
||||
let showModal = true
|
||||
/**
|
||||
@@ -122,9 +125,34 @@ async function DoAjax(options, config = {}) {
|
||||
});
|
||||
throw new Error(message);
|
||||
}
|
||||
return res;
|
||||
return transformRepalceString(res);
|
||||
}
|
||||
|
||||
// 递归替换 url
|
||||
function transformRepalceString(props) {
|
||||
if (typeof props !== 'object' || props === null) {
|
||||
for (const key in replaceStr) {
|
||||
if (typeof props === 'string') {
|
||||
props = props.replace(key, replaceStr[key]);
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
let result;
|
||||
if (props instanceof Array) {
|
||||
result = [];
|
||||
} else {
|
||||
result = {};
|
||||
}
|
||||
for (let key in props) {
|
||||
if (props.hasOwnProperty(key)) {
|
||||
result[key] = transformRepalceString(props[key]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 时间格式化
|
||||
* @param {*} str
|
||||
|
||||
Reference in New Issue
Block a user