flat: 暂存
This commit is contained in:
@@ -24,5 +24,9 @@ module.exports = {
|
|||||||
url: ""
|
url: ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
// 接口替换字符串
|
||||||
|
replaceStr: {
|
||||||
|
'{oss_file_url}': 'https://dy12333.org.cn/api'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,9 @@ import store from '@/store/';
|
|||||||
import {
|
import {
|
||||||
baseUrl
|
baseUrl
|
||||||
} from '@/config/env.js'
|
} from '@/config/env.js'
|
||||||
|
import {
|
||||||
|
replaceStr
|
||||||
|
} from "../config";
|
||||||
|
|
||||||
let showModal = true
|
let showModal = true
|
||||||
/**
|
/**
|
||||||
@@ -122,9 +125,34 @@ async function DoAjax(options, config = {}) {
|
|||||||
});
|
});
|
||||||
throw new Error(message);
|
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
|
* @param {*} str
|
||||||
|
|||||||
Reference in New Issue
Block a user