From 34de3fced68d1f0c4cb8df6e55f5ad2111af1f12 Mon Sep 17 00:00:00 2001 From: Mac666 Date: Sat, 5 Aug 2023 10:39:17 +0000 Subject: [PATCH] =?UTF-8?q?get=E6=9F=A5=E8=AF=A2=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=20=E6=97=A0=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mac666 --- src/utils/request.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/utils/request.ts b/src/utils/request.ts index ab0864cf..66c2c983 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -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) {