增加全局http参数
This commit is contained in:
@@ -67,6 +67,7 @@ const dealParamsBody = (options) => {
|
||||
options.params.equals = ids.join(',');
|
||||
}
|
||||
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
@@ -121,7 +122,13 @@ async function req(url, options) {
|
||||
* @param options
|
||||
*/
|
||||
async function get(url, params = {}, options = {}) {
|
||||
return req(url, {...options, method: 'GET', params});
|
||||
let obj = {...params}
|
||||
if(GlobalConfig.getConfig().httpParams){
|
||||
|
||||
obj = {...params,...GlobalConfig.getConfig().httpParams()};
|
||||
|
||||
}
|
||||
return req(url, {...options, method: 'GET', params:obj});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +143,15 @@ async function post(url, data = {}, options = {}) {
|
||||
if (Storage.getEncryptBody()) {
|
||||
newData.encryptData = crypto.encrypt(JSON.stringify(data));
|
||||
} else {
|
||||
|
||||
newData = {...data};
|
||||
|
||||
if(GlobalConfig.getConfig().httpParams){
|
||||
|
||||
newData = {...data,...GlobalConfig.getConfig().httpParams()};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return req(url, {...options, method: 'POST', data: newData});
|
||||
|
||||
@@ -6,9 +6,13 @@ const defaultConfig = {
|
||||
base64Key: "WmdUzPJXbngVNiaSsQrihg==",
|
||||
prefix: "",
|
||||
onHttpError: (res) => {
|
||||
},
|
||||
httpParams:(res)=>{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取网络请求配置
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user