style:cas
Showing
2 changed files
with
3 additions
and
11 deletions
1 | /* | 1 | /* |
2 | * @Description: 项目权限 | 2 | * @Description: 项目权限 |
3 | * @Autor: renchao | 3 | * @Autor: renchao |
4 | * @LastEditTime: 2023-06-13 16:28:25 | 4 | * @LastEditTime: 2023-06-13 16:35:40 |
5 | */ | 5 | */ |
6 | import Vue from 'vue' | 6 | import Vue from 'vue' |
7 | import axios from 'axios' | 7 | import axios from 'axios' |
... | @@ -46,7 +46,7 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -46,7 +46,7 @@ router.beforeEach(async (to, from, next) => { |
46 | if (process.env.NODE_ENV === 'development') { | 46 | if (process.env.NODE_ENV === 'development') { |
47 | localStorage.setItem('token', res.data.content.accessToken) | 47 | localStorage.setItem('token', res.data.content.accessToken) |
48 | } else { | 48 | } else { |
49 | Cookies.set('ACCESS_TOKEN', res.data.content.accessToken) | 49 | Cookies.set("ACCESS_TOKEN", res.data.content.accessToken); |
50 | } | 50 | } |
51 | window.location.href = localStorage.getItem('location') | 51 | window.location.href = localStorage.getItem('location') |
52 | 52 | ... | ... |
... | @@ -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-13 16:28:57 | 5 | * @LastEditTime: 2023-06-13 16:37:19 |
6 | */ | 6 | */ |
7 | import axios from 'axios' | 7 | import axios from 'axios' |
8 | import Router from '@/router' | 8 | import Router from '@/router' |
... | @@ -34,14 +34,6 @@ service.interceptors.request.use( | ... | @@ -34,14 +34,6 @@ 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('ACCESS_TOKEN') | ||
39 | // 添加请求头 | ||
40 | if (token) { | ||
41 | config.headers['Authorization'] = 'Bearer ' + token | ||
42 | } else { | ||
43 | config.headers.delete('Authorization') | ||
44 | } | ||
45 | } | 37 | } |
46 | return config | 38 | return config |
47 | }, | 39 | }, | ... | ... |
-
Please register or sign in to post a comment