get查询参数序列化 无效问题修复

Signed-off-by: Mac666 <support@mail.pigx.vip>
This commit is contained in:
Mac666 2023-08-05 10:39:17 +00:00 committed by Gitee
parent 080bbbed27
commit 34de3fced6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -10,6 +10,9 @@ import other from './other';
const service: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_API_URL,
timeout: 50000, // 全局超时时间
paramsSerializer: (params: any) => {
return qs.stringify(params, { arrayFormat: 'repeat' });
}
});
/**
@ -21,14 +24,6 @@ const service: AxiosInstance = axios.create({
*/
service.interceptors.request.use(
(config: AxiosRequestConfig) => {
// 对get请求参数进行序列化
if (config.method === 'get') {
// @ts-ignore 使用qs库来序列化查询参数
config.paramsSerializer = (params: any) => {
return qs.stringify(params, { arrayFormat: 'repeat' });
};
}
// 统一增加Authorization请求头, skipToken 跳过增加token
const token = Session.getToken();
if (token && !config.headers?.skipToken) {