From 9bec4dcae002f36aa23231da11cb03a156b40110 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周三, 30 4月 2025 16:24:16 +0800 Subject: [PATCH] 222 --- PipeLineLems/web/src/utils/request.ts | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/PipeLineLems/web/src/utils/request.ts b/PipeLineLems/web/src/utils/request.ts index 506c8e4..83e0bbd 100644 --- a/PipeLineLems/web/src/utils/request.ts +++ b/PipeLineLems/web/src/utils/request.ts @@ -1,6 +1,5 @@ import { default as axios, AxiosRequestConfig } from 'axios' import { Session } from '@/utils/storage' -import router from '@/router' // 閰嶇疆鏂板缓涓�涓� axios 瀹炰緥 const service = axios.create({ @@ -9,7 +8,7 @@ headers: { 'Content-Type': 'application/json;charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest', - 'Accept-Language': 'zh-Hans' + 'Accept-Language': 'zh-Hans', }, }) @@ -20,7 +19,7 @@ // console.log('Token', token); if (token) config.headers['Authorization'] = `Bearer ${token}` config.headers['X-Requested-With'] = 'XMLHttpRequest' - if (typeof config.data !== 'object') config.data = JSON.stringify(config.data) + // if (typeof config.data !== 'object') config.data = JSON.stringify(config.data) return config }, (error: any) => { @@ -31,16 +30,16 @@ // 鍝嶅簲鍚� service.interceptors.response.use( (response: any) => { - const { data } = response; + const { data } = response // if (data.statusCode == 401) { // ElMessage.error('璇风櫥褰�'); // router.push({ name: '/login' }) // return; // } - return data; + return data }, (error: any) => { - Session.remove('Token') + // Session.remove('Token') return Promise.reject(error) } ) @@ -51,10 +50,17 @@ <D = Data>(url: string, config?: AxiosRequestConfig): Promise<D> get<D = Data>(url: string, config?: AxiosRequestConfig): Promise<D> delete<D = Data>(url: string, config?: AxiosRequestConfig): Promise<D> - post<D = Data>(url: string, data?: any, config?: AxiosRequestConfig): Promise<D> - put<D = Data>(url: string, data?: any, config?: AxiosRequestConfig): Promise<D> + post<D = Data>( + url: string, + data?: any, + config?: AxiosRequestConfig + ): Promise<D> + put<D = Data>( + url: string, + data?: any, + config?: AxiosRequestConfig + ): Promise<D> } & typeof service const request = service as Request export { request as default, request } - -- Gitblit v1.9.3