11import Vue from 'vue'
22import axios from 'axios'
33import store from '@/store'
4- import { VueAxios } from './axios'
4+ import {
5+ VueAxios
6+ } from './axios'
57import notification from 'ant-design-vue/es/notification'
6- import { ACCESS_TOKEN } from '@/store/mutation-types'
8+ import {
9+ ACCESS_TOKEN
10+ } from '@/store/mutation-types'
711
812// 创建 axios 实例
913const service = axios . create ( {
@@ -16,10 +20,16 @@ const err = (error) => {
1620 const data = error . response . data
1721 const token = Vue . ls . get ( ACCESS_TOKEN )
1822 if ( error . response . status === 403 ) {
19- notification . error ( { message : 'Forbidden' , description : data . message } )
23+ notification . error ( {
24+ message : 'Forbidden' ,
25+ description : data . message
26+ } )
2027 }
2128 if ( error . response . status === 401 ) {
22- notification . error ( { message : 'Unauthorized' , description : 'Authorization verification failed' } )
29+ notification . error ( {
30+ message : 'Unauthorized' ,
31+ description : 'Authorization verification failed'
32+ } )
2333 if ( token ) {
2434 store . dispatch ( 'Logout' ) . then ( ( ) => {
2535 setTimeout ( ( ) => {
@@ -36,7 +46,7 @@ const err = (error) => {
3646service . interceptors . request . use ( config => {
3747 const token = Vue . ls . get ( ACCESS_TOKEN )
3848 if ( token ) {
39- config . headers [ 'Access-Token' ] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
49+ config . headers [ 'Access-Token' ] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
4050 }
4151 return config
4252} , err )
@@ -48,8 +58,8 @@ service.interceptors.response.use((response) => {
4858
4959const installer = {
5060 vm : { } ,
51- install ( Vue , router = { } ) {
52- Vue . use ( VueAxios , router , service )
61+ install ( Vue ) {
62+ Vue . use ( VueAxios , service )
5363 }
5464}
5565
0 commit comments