request.js 加默认token

This commit is contained in:
qinjie 2021-08-23 14:44:35 +08:00
parent 7c1b325b3f
commit c586c74934
1 changed files with 3 additions and 2 deletions

View File

@ -3,7 +3,7 @@ import store from '@/store'
import storage from 'store' import storage from 'store'
import notification from 'ant-design-vue/es/notification' import notification from 'ant-design-vue/es/notification'
import { VueAxios } from './axios' import { VueAxios } from './axios'
import { ACCESS_TOKEN, LOGIN_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN, LOGIN_TOKEN, TOKEN_NAME } from '@/store/mutation-types'
const DATA_OWNER = 1 const DATA_OWNER = 1
const SUCCESS_CODE = 'ok' const SUCCESS_CODE = 'ok'
@ -54,6 +54,7 @@ request.interceptors.request.use(config => {
// 让每个请求携带自定义 token 请根据实际情况自行修改 // 让每个请求携带自定义 token 请根据实际情况自行修改
if (token) { if (token) {
config.headers[ACCESS_TOKEN] = token config.headers[ACCESS_TOKEN] = token
config.headers[TOKEN_NAME] = 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjdhYTViMGZiLTkyOWQtNDhhZS04ODU1LWJkNzM5MjdlOTNiZCJ9.CZzowaB-w2krGpNttPZBNLfq1mw775Lh-sx1K8onfgSwNzA6bw-P7CqC4vgH29xjDv3ey4zEFDzV9pHnrAGrDA'
} }
if (config.method === 'post') { if (config.method === 'post') {
if (!config.data) { if (!config.data) {