/** * 默认配置 * @type {{onHttpError: defaultConfig.onHttpError, prefix: string, base64Key: string}} */ const defaultConfig = { base64Key: "WmdUzPJXbngVNiaSsQrihg==", prefix: "", onHttpError: (res) => { } } /** * 获取网络请求配置 */ const getConfig = () => { return window.httpConfig || defaultConfig; } /** * 网络请求配置 * @param obj */ function setConfig(obj = defaultConfig) { window.httpConfig = {...getConfig(), ...obj}; } module.exports = { setConfig, getConfig }