204ba7b4 by renchao@pashanhoo.com

style:cas

1 parent 1f60e8e5
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 /* 2 /*
3 * @Description: 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器 3 * @Description: 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
4 * @Autor: renchao 4 * @Autor: renchao
5 * @LastEditTime: 2023-06-12 17:22:35 5 * @LastEditTime: 2023-06-13 09:28:21
6 */ 6 */
7 import axios from 'axios' 7 import axios from 'axios'
8 import Router from '@/router' 8 import Router from '@/router'
...@@ -34,6 +34,14 @@ service.interceptors.request.use( ...@@ -34,6 +34,14 @@ service.interceptors.request.use(
34 } else { 34 } else {
35 config.headers.delete('Authorization') 35 config.headers.delete('Authorization')
36 } 36 }
37 } else {
38 const token = Cookies.get('token')
39 // 添加请求头
40 if (token) {
41 config.headers['Authorization'] = 'Bearer ' + token
42 } else {
43 config.headers.delete('Authorization')
44 }
37 } 45 }
38 return config 46 return config
39 }, 47 },
......