From 8b58e2d0c4cf9db301f17f4456b899183fca86b9 Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期二, 30 七月 2024 16:34:59 +0800 Subject: [PATCH] 注册信息 --- src/api/interceptor.ts | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/api/interceptor.ts b/src/api/interceptor.ts index 000000d..36599d4 100644 --- a/src/api/interceptor.ts +++ b/src/api/interceptor.ts @@ -2,7 +2,7 @@ import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import { Message, Modal } from '@arco-design/web-vue'; import { useUserStore } from '@/store'; -import { getAuthorization, getToken, setAuthorization } from "@/utils/auth"; +import { getAuthorization, getToken, setAuthorization, setToken } from "@/utils/auth"; export interface HttpResponse<T = unknown> { status: number; @@ -14,7 +14,7 @@ if (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( (config: AxiosRequestConfig) => { // let each request carry token @@ -35,11 +35,9 @@ if (!config.headers) { config.headers = {}; } - config.headers.Authorization = authorization; - config.headers.token = getToken(); + config.headers.Authorization = `${authorization}`; } - - config.headers.Authorization = 'Ijg3NmFjZjJlNGIzMzExZWY4NzI0MDI0MmFjMTIwMDA2Ig.ZqNvxw.Kgp8PcT4n2cxpzxFrYHttO4i2Eo'; + config.headers.Authorization = 'IjFjOWY3OWM0NGUxYzExZWZhMDk0MDI0MmFjMTIwMDA2Ig.ZqhQ-w.JmA9ESUTd_JKK2wtZ4PVgVmCNj8'; return config; }, (error) => { @@ -53,7 +51,7 @@ const res = response.data; // if the custom code is not 20000, it is judged as an error. - if ((res.retcode && res.retcode !== 0) || (res.code && res.code !== 20000)) { + /*if ((res.retcode && res.retcode !== 0) || (res.code && res.code !== 20000)) { Message.error({ content: res.msg || 'Error', duration: 5 * 1000, @@ -79,9 +77,9 @@ return Promise.reject(new Error(res.msg || 'Error')); } - if(response.config.url === '/v1/user/login') { + if(response.config.url === '/v1/user/login'|| response.config.url === '/base/login') { setAuthorization(response.headers.authorization); - } + }*/ return res; }, (error) => { -- Gitblit v1.8.0