Skip to content

Commit 845ba07

Browse files
authored
fix: chat route (#3280)
1 parent a93d7ca commit 845ba07

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

ui/src/router/chat/index.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,35 @@ router.beforeEach(
2525
return
2626
}
2727
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') {
3340
next({
34-
path: '/404',
41+
name: 'login',
42+
params: {
43+
accessToken: to.params.accessToken,
44+
},
3545
})
3646
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-
}
5047
} else {
51-
await chatUser.anonymousAuthentication()
48+
next()
49+
return
5250
}
51+
} else {
52+
await chatUser.anonymousAuthentication()
53+
}
5354

54-
if (!chatUser.application) {
55-
await chatUser.applicationProfile()
56-
}
55+
if (!chatUser.application) {
56+
await chatUser.applicationProfile()
5757
}
5858
// 判断是否有菜单权限
5959
if (to.meta.permission ? hasPermission(to.meta.permission as any, 'OR') : true) {

0 commit comments

Comments
 (0)