From c586c74934e71d694d6775e761c9616206fd7190 Mon Sep 17 00:00:00 2001 From: qinjie Date: Mon, 23 Aug 2021 14:44:35 +0800 Subject: [PATCH] =?UTF-8?q?request.js=20=E5=8A=A0=E9=BB=98=E8=AE=A4token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index d3a5815..45e0aa2 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,7 +3,7 @@ import store from '@/store' import storage from 'store' import notification from 'ant-design-vue/es/notification' 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 SUCCESS_CODE = 'ok' @@ -54,6 +54,7 @@ request.interceptors.request.use(config => { // 让每个请求携带自定义 token 请根据实际情况自行修改 if (token) { config.headers[ACCESS_TOKEN] = token + config.headers[TOKEN_NAME] = 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjdhYTViMGZiLTkyOWQtNDhhZS04ODU1LWJkNzM5MjdlOTNiZCJ9.CZzowaB-w2krGpNttPZBNLfq1mw775Lh-sx1K8onfgSwNzA6bw-P7CqC4vgH29xjDv3ey4zEFDzV9pHnrAGrDA' } if (config.method === 'post') { if (!config.data) { @@ -83,7 +84,7 @@ request.interceptors.response.use((response) => { const installer = { vm: {}, - install (Vue) { + install(Vue) { Vue.use(VueAxios, request) } }