jhzh
2024-03-23 0d29d9a2bf0d893a67f1263bb9525131a50a2128
src/axios/index.js
@@ -5,9 +5,8 @@
import axios from 'axios' // 引入axios
import qs from 'qs' // 引入qs
// import store from '@/store'
import router from '@/router'
// import router from '@/router'
import APIUrl from './api.url' // 引入api.url.js
// axios 默认配置  更多配置查看Axios中文文档
axios.defaults.timeout = 50000 // 超时默认值
@@ -21,10 +20,10 @@
// 在ajax发送之前拦截 比如对所有请求统一添加header token
axios.interceptors.request.use(
  config => {
    config.headers["lang"] = localStorage.getItem("language") ? localStorage.getItem("language") : "zh-CN";
    if (window.localStorage.getItem("USERTOKEN")) {
        // config.headers.Authorization = `USER_TOKEN = ${store.state.token}`;
        config.headers["USERTOKEN"] = window.localStorage.getItem("USERTOKEN");
    config.headers['lang'] = localStorage.getItem('language') ? localStorage.getItem('language') : 'zh-CN'
    if (window.localStorage.getItem('USERTOKEN')) {
      // config.headers.Authorization = `USER_TOKEN = ${store.state.token}`;
      config.headers['USERTOKEN'] = window.localStorage.getItem('USERTOKEN')
    }
    console.log(config)
    return config