File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -13,20 +13,26 @@ const service = axios.create({
13
13
14
14
const err = ( error ) => {
15
15
if ( error . response ) {
16
- if ( error . status === 403 ) {
17
- notification . error ( { message : '拒绝访问' , description : '无权限,拒绝访问' } )
16
+ let data = error . response . data
17
+ const token = Vue . ls . get ( ACCESS_TOKEN )
18
+ if ( error . response . status === 403 ) {
19
+ notification . error ( { message : 'Forbidden' , description : data . message } )
18
20
}
19
- if ( error . status === 401 ) {
20
- notification . error ( { message : '未授权' , description : '授权验证失败' } )
21
- store . dispatch ( 'Logout' ) . then ( ( ) => {
22
- location . reload ( )
23
- } )
21
+ if ( error . response . status === 401 ) {
22
+ notification . error ( { message : 'Unauthorized' , description : 'Authorization verification failed' } )
23
+ if ( token ) {
24
+ store . dispatch ( 'Logout' ) . then ( ( ) => {
25
+ setTimeout ( ( ) => {
26
+ window . location . reload ( )
27
+ } , 1500 )
28
+ } )
29
+ }
24
30
}
25
31
}
26
32
return Promise . reject ( error )
27
33
} ;
28
34
29
- // request 拦截器
35
+ // request interceptor
30
36
service . interceptors . request . use ( config => {
31
37
const token = Vue . ls . get ( ACCESS_TOKEN )
32
38
if ( token ) {
@@ -35,7 +41,7 @@ service.interceptors.request.use(config => {
35
41
return config
36
42
} , err )
37
43
38
- // response 拦截器
44
+ // response interceptor
39
45
service . interceptors . response . use ( ( response ) => {
40
46
return response . data
41
47
} , err )
You can’t perform that action at this time.
0 commit comments