添加退出登录
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import axios from 'axios'
|
||||
import { showToast, showNotify, showConfirmDialog, closeToast } from 'vant'
|
||||
import { useUserInfoStore } from '@/stores/modules/userInfo'
|
||||
const store = useUserInfoStore()
|
||||
import { getLocal } from '@/utils/local'
|
||||
import router from '@/router/index'
|
||||
import { useOverallStore, useGenerateStore } from '@/stores'
|
||||
import { useOverallStore, useGenerateStore, useUserInfoStore } from '@/stores'
|
||||
|
||||
// 扩展 AxiosRequestConfig 接口
|
||||
declare module 'axios' {
|
||||
@@ -47,8 +45,9 @@ service.interceptors.request.use(
|
||||
}
|
||||
// 如果登录了,有token,则请求携带token
|
||||
// Do something before request is sent
|
||||
if (store.state.token) {
|
||||
config.headers.Authorization = getLocal('token') // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
||||
const token = useUserInfoStore().state.token
|
||||
if (token) {
|
||||
config.headers.Authorization = token // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
||||
// config.headers['X-Token'] = getLocal('token') // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
||||
}
|
||||
return config
|
||||
|
||||
Reference in New Issue
Block a user