yangfeng
2024-02-05 b26933c801fbf69df56fd81df3e127e39a14b31d
src/common/utils/request.ts
@@ -2,6 +2,7 @@
import type { AxiosRequestConfig } from 'axios'
import { ElMessage } from 'element-plus'
import { getToken } from '@/common/utils/index'
import router from '../../router/index'
const instance = axiosClient.create({
  responseType: 'json',
@@ -15,7 +16,11 @@
  (config) => {
    // 若是有做鉴权token , 就给头部带上token
    const token = getToken()
    if (token) {
    if (token == null || token == '' || token == 'undefined') {
      router.push('/login')
      return config
      // window.location = `//${window.location.hostname}:9080`+'/login'
    } else if (token) {
      config.headers.Authorization = 'Bearer ' + token
    }