File tree Expand file tree Collapse file tree 1 file changed +23
-23
lines changed Expand file tree Collapse file tree 1 file changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -25,35 +25,35 @@ router.beforeEach(
25
25
return
26
26
}
27
27
const { chatUser } = useStore ( )
28
- const notAuthRouteNameList = [ 'login' ]
29
- if ( ! notAuthRouteNameList . includes ( to . name ? to . name . toString ( ) : '' ) ) {
30
- if ( to . params && to . params . accessToken ) {
31
- chatUser . setAccessToken ( to . params . accessToken . toString ( ) )
32
- } else {
28
+ if ( [ 'login' , 'chat' ] . includes ( to . name ? to . name . toString ( ) : '' ) ) {
29
+ chatUser . setAccessToken ( to . params . accessToken . toString ( ) )
30
+ } else {
31
+ next ( {
32
+ path : '/404' ,
33
+ } )
34
+ return
35
+ }
36
+ const authentication = await chatUser . isAuthentication ( )
37
+ const token = chatUser . getToken ( )
38
+ if ( authentication ) {
39
+ if ( ! token && to . name != 'login' ) {
33
40
next ( {
34
- path : '/404' ,
41
+ name : 'login' ,
42
+ params : {
43
+ accessToken : to . params . accessToken ,
44
+ } ,
35
45
} )
36
46
return
37
- }
38
- const token = chatUser . getToken ( )
39
- const authentication = await chatUser . isAuthentication ( )
40
- if ( authentication ) {
41
- if ( ! token ) {
42
- next ( {
43
- name : 'login' ,
44
- params : {
45
- accessToken : to . params . accessToken ,
46
- } ,
47
- } )
48
- return
49
- }
50
47
} else {
51
- await chatUser . anonymousAuthentication ( )
48
+ next ( )
49
+ return
52
50
}
51
+ } else {
52
+ await chatUser . anonymousAuthentication ( )
53
+ }
53
54
54
- if ( ! chatUser . application ) {
55
- await chatUser . applicationProfile ( )
56
- }
55
+ if ( ! chatUser . application ) {
56
+ await chatUser . applicationProfile ( )
57
57
}
58
58
// 判断是否有菜单权限
59
59
if ( to . meta . permission ? hasPermission ( to . meta . permission as any , 'OR' ) : true ) {
You can’t perform that action at this time.
0 commit comments