Merge branch 'dev'
Showing
3 changed files
with
7 additions
and
8 deletions
... | @@ -75,7 +75,7 @@ | ... | @@ -75,7 +75,7 @@ |
75 | if (process.env.NODE_ENV === 'development') { | 75 | if (process.env.NODE_ENV === 'development') { |
76 | localStorage.removeItem('token') | 76 | localStorage.removeItem('token') |
77 | } else { | 77 | } else { |
78 | Cookies.remove('token') | 78 | Cookies.remove('accessToken') |
79 | } | 79 | } |
80 | if (window._config.casEnable) { | 80 | if (window._config.casEnable) { |
81 | window.location.href = window._config.casBaseURL + '/logout?service=' + encodeURIComponent(window.location.href); | 81 | window.location.href = window._config.casBaseURL + '/logout?service=' + encodeURIComponent(window.location.href); | ... | ... |
1 | /* | 1 | /* |
2 | * @Description: 项目权限 | 2 | * @Description: 项目权限 |
3 | * @Autor: renchao | 3 | * @Autor: renchao |
4 | * @LastEditTime: 2023-06-13 10:28:05 | 4 | * @LastEditTime: 2023-06-13 10:49:43 |
5 | */ | 5 | */ |
6 | import Vue from 'vue' | 6 | import Vue from 'vue' |
7 | import axios from 'axios' | 7 | import axios from 'axios' |
... | @@ -23,7 +23,7 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -23,7 +23,7 @@ router.beforeEach(async (to, from, next) => { |
23 | let hasAddDict = store.state.dict.addDict | 23 | let hasAddDict = store.state.dict.addDict |
24 | let hasAddRoute = store.state.permission.addRoutes | 24 | let hasAddRoute = store.state.permission.addRoutes |
25 | // cas操作 | 25 | // cas操作 |
26 | const token = localStorage.getItem("token") || Cookies.get('token'); | 26 | const token = localStorage.getItem("token") || Cookies.get('accessToken'); |
27 | if (to.path === '/login') { | 27 | if (to.path === '/login') { |
28 | if (token) { | 28 | if (token) { |
29 | next('/') | 29 | next('/') |
... | @@ -43,11 +43,10 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -43,11 +43,10 @@ router.beforeEach(async (to, from, next) => { |
43 | 'service': locationUrl | 43 | 'service': locationUrl |
44 | } | 44 | } |
45 | }).then(async (res) => { | 45 | }).then(async (res) => { |
46 | debugger | ||
47 | if (process.env.NODE_ENV === 'development') { | 46 | if (process.env.NODE_ENV === 'development') { |
48 | localStorage.setItem('token', res.data.content.accessToken) | 47 | localStorage.setItem('token', res.data.content.accessToken) |
49 | } else { | 48 | } else { |
50 | Cookies.set('token', res.data.content.accessToken) | 49 | Cookies.set('accessToken', res.data.content.accessToken) |
51 | } | 50 | } |
52 | window.location.href = localStorage.getItem('location') | 51 | window.location.href = localStorage.getItem('location') |
53 | 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 09:38:06 | 5 | * @LastEditTime: 2023-06-13 10:50:32 |
6 | */ | 6 | */ |
7 | import axios from 'axios' | 7 | import axios from 'axios' |
8 | import Router from '@/router' | 8 | import Router from '@/router' |
... | @@ -35,7 +35,7 @@ service.interceptors.request.use( | ... | @@ -35,7 +35,7 @@ service.interceptors.request.use( |
35 | config.headers.delete('Authorization') | 35 | config.headers.delete('Authorization') |
36 | } | 36 | } |
37 | } else { | 37 | } else { |
38 | const token = Cookies.get('token') | 38 | const token = Cookies.get('accessToken') |
39 | // 添加请求头 | 39 | // 添加请求头 |
40 | if (token) { | 40 | if (token) { |
41 | config.headers['Authorization'] = 'Bearer ' + token | 41 | config.headers['Authorization'] = 'Bearer ' + token |
... | @@ -78,7 +78,7 @@ service.interceptors.response.use( | ... | @@ -78,7 +78,7 @@ service.interceptors.response.use( |
78 | if (process.env.NODE_ENV === 'development') { | 78 | if (process.env.NODE_ENV === 'development') { |
79 | localStorage.removeItem('token') | 79 | localStorage.removeItem('token') |
80 | } else { | 80 | } else { |
81 | Cookies.remove('token') | 81 | Cookies.remove('accessToken') |
82 | } | 82 | } |
83 | if (window._config.casEnable) { | 83 | if (window._config.casEnable) { |
84 | window.location.href = window._config.casBaseURL + '/logout?service=' + encodeURIComponent(locationUrl); | 84 | window.location.href = window._config.casBaseURL + '/logout?service=' + encodeURIComponent(locationUrl); | ... | ... |
-
Please register or sign in to post a comment