fix(web): 修复前端请求配置与自定义配置合并逻辑
This commit is contained in:
@@ -172,20 +172,20 @@ function createRequestFunction(service: any) {
|
|||||||
return function (config: any) {
|
return function (config: any) {
|
||||||
const configDefault = {
|
const configDefault = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': get(config, 'headers.Content-Type', 'application/json'),
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
baseURL: getBaseURL(),
|
baseURL: getBaseURL(),
|
||||||
data: {},
|
data: {},
|
||||||
};
|
};
|
||||||
|
Object.assign(configDefault, config);
|
||||||
// const token = userStore.getToken;
|
// const token = userStore.getToken;
|
||||||
const token = Session.get('token');
|
const token = Session.get('token');
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
configDefault.headers.Authorization = 'JWT ' + token;
|
configDefault.headers.Authorization = 'JWT ' + token;
|
||||||
}
|
}
|
||||||
return service(Object.assign(configDefault, config));
|
return service(configDefault);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user