flat: 暂存

This commit is contained in:
Apcallover
2024-04-18 16:42:36 +08:00
parent a044630563
commit bb7e57c361
2 changed files with 237 additions and 205 deletions

View File

@@ -24,5 +24,9 @@ module.exports = {
url: ""
}
]
},
// 接口替换字符串
replaceStr: {
'{oss_file_url}': 'https://dy12333.org.cn/api'
}
}

View File

@@ -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