From 7067723946f837d0468814c28fe4971b7c331d11 Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期六, 24 八月 2024 20:12:28 +0800 Subject: [PATCH] 知识库列表修改 --- src/api/interceptor.ts | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/interceptor.ts b/src/api/interceptor.ts index aa11c4b..529dbfa 100644 --- a/src/api/interceptor.ts +++ b/src/api/interceptor.ts @@ -9,6 +9,9 @@ setToken, } from '@/utils/auth'; + + + export interface HttpResponse<T = unknown> { status: number; msg: string; @@ -17,7 +20,7 @@ } if (import.meta.env.VITE_API_BASE_URL) { - axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL; + // axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL; } axios.defaults.withCredentials = true; axios.interceptors.request.use( @@ -41,6 +44,8 @@ } config.headers.Authorization = `${authorization}`; } + // config.headers.Authorization = + // 'ImE4NGQ4ZWNjNGVmYjExZWZiZjRkMDI0MmFjMTIwMDA2Ig.ZqnIBw.ZX7_UxnSBKu8x_riQ5FrHLMAS78'; return config; }, (error) => { @@ -52,11 +57,15 @@ axios.interceptors.response.use( (response: AxiosResponse<HttpResponse>) => { const res = response.data; - // if the custom code is not 20000, it is judged as an error. + if ( (res.retcode && res.retcode == 401) || (res.code && res.code == 401) || (res.code && res.code == 4006)) + { + const userStore = useUserStore(); + userStore.logout(); + } if ( (res.retcode && res.retcode !== 0) || - (res.code && res.code !== 20000) + (res.code && res.code !== 20000 && res.code !== 200) ) { Message.error({ content: res.msg || 'Error', -- Gitblit v1.8.0